Corner snapping for diamonds no longer has dead zones

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-04-23 16:07:50 +02:00
parent 10c5ec2c7b
commit 95a2b03686
No known key found for this signature in database

View file

@ -1104,9 +1104,11 @@ export const snapToMid = (
const horizontalThrehsold = clamp(tolerance * width, 5, 80); const horizontalThrehsold = clamp(tolerance * width, 5, 80);
if ( if (
nonRotated[0] <= x + width / 2 && element.type === "diamond"
nonRotated[1] > center[1] - verticalThrehsold && ? nonRotated[0] <= x + width * (element.roundness ? 0.035 : 1)
nonRotated[1] < center[1] + verticalThrehsold : nonRotated[0] <= x + width / 2 &&
nonRotated[1] > center[1] - verticalThrehsold &&
nonRotated[1] < center[1] + verticalThrehsold
) { ) {
// LEFT // LEFT
return pointRotateRads( return pointRotateRads(
@ -1115,9 +1117,11 @@ export const snapToMid = (
angle, angle,
); );
} else if ( } else if (
nonRotated[1] <= y + height / 2 && element.type === "diamond"
nonRotated[0] > center[0] - horizontalThrehsold && ? nonRotated[1] <= y + height * (element.roundness ? 0.035 : 1)
nonRotated[0] < center[0] + horizontalThrehsold : nonRotated[1] <= y + height / 2 &&
nonRotated[0] > center[0] - horizontalThrehsold &&
nonRotated[0] < center[0] + horizontalThrehsold
) { ) {
// TOP // TOP
return pointRotateRads( return pointRotateRads(
@ -1126,9 +1130,11 @@ export const snapToMid = (
angle, angle,
); );
} else if ( } else if (
nonRotated[0] >= x + width / 2 && element.type === "diamond"
nonRotated[1] > center[1] - verticalThrehsold && ? nonRotated[0] >= x + width * (element.roundness ? 0.035 : 1)
nonRotated[1] < center[1] + verticalThrehsold : nonRotated[0] >= x + width / 2 &&
nonRotated[1] > center[1] - verticalThrehsold &&
nonRotated[1] < center[1] + verticalThrehsold
) { ) {
// RIGHT // RIGHT
return pointRotateRads( return pointRotateRads(
@ -1137,9 +1143,11 @@ export const snapToMid = (
angle, angle,
); );
} else if ( } else if (
nonRotated[1] >= y + height / 2 && element.type === "diamond"
nonRotated[0] > center[0] - horizontalThrehsold && ? nonRotated[1] >= y - height * (element.roundness ? 0.035 : 1)
nonRotated[0] < center[0] + horizontalThrehsold : nonRotated[1] >= y + height / 2 &&
nonRotated[0] > center[0] - horizontalThrehsold &&
nonRotated[0] < center[0] + horizontalThrehsold
) { ) {
// DOWN // DOWN
return pointRotateRads( return pointRotateRads(