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,7 +1104,9 @@ 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[0] <= x + width * (element.roundness ? 0.035 : 1)
: nonRotated[0] <= x + width / 2 &&
nonRotated[1] > center[1] - verticalThrehsold && nonRotated[1] > center[1] - verticalThrehsold &&
nonRotated[1] < center[1] + verticalThrehsold nonRotated[1] < center[1] + verticalThrehsold
) { ) {
@ -1115,7 +1117,9 @@ export const snapToMid = (
angle, angle,
); );
} else if ( } else if (
nonRotated[1] <= y + height / 2 && element.type === "diamond"
? nonRotated[1] <= y + height * (element.roundness ? 0.035 : 1)
: nonRotated[1] <= y + height / 2 &&
nonRotated[0] > center[0] - horizontalThrehsold && nonRotated[0] > center[0] - horizontalThrehsold &&
nonRotated[0] < center[0] + horizontalThrehsold nonRotated[0] < center[0] + horizontalThrehsold
) { ) {
@ -1126,7 +1130,9 @@ export const snapToMid = (
angle, angle,
); );
} else if ( } else if (
nonRotated[0] >= x + width / 2 && element.type === "diamond"
? nonRotated[0] >= x + width * (element.roundness ? 0.035 : 1)
: nonRotated[0] >= x + width / 2 &&
nonRotated[1] > center[1] - verticalThrehsold && nonRotated[1] > center[1] - verticalThrehsold &&
nonRotated[1] < center[1] + verticalThrehsold nonRotated[1] < center[1] + verticalThrehsold
) { ) {
@ -1137,7 +1143,9 @@ export const snapToMid = (
angle, angle,
); );
} else if ( } else if (
nonRotated[1] >= y + height / 2 && element.type === "diamond"
? nonRotated[1] >= y - height * (element.roundness ? 0.035 : 1)
: nonRotated[1] >= y + height / 2 &&
nonRotated[0] > center[0] - horizontalThrehsold && nonRotated[0] > center[0] - horizontalThrehsold &&
nonRotated[0] < center[0] + horizontalThrehsold nonRotated[0] < center[0] + horizontalThrehsold
) { ) {