Fix errorneous corner snap for sharp diamonds

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-04-24 21:44:07 +02:00
parent 1f6cb8d576
commit 086d012b05
No known key found for this signature in database
2 changed files with 10 additions and 11 deletions

View file

@ -108,7 +108,6 @@ export const isBindingEnabled = (appState: AppState): boolean => {
export const FIXED_BINDING_DISTANCE = 5;
const BINDING_HIGHLIGHT_THICKNESS = 10;
export const BINDING_HIGHLIGHT_OFFSET = 4;
const getNonDeletedElements = (
scene: Scene,
@ -1105,7 +1104,7 @@ export const snapToMid = (
if (
element.type === "diamond"
? nonRotated[0] <= x + width * (element.roundness ? 0.035 : 1)
? nonRotated[0] <= x + width * (element.roundness ? 0.035 : 0)
: nonRotated[0] <= x + width / 2 &&
nonRotated[1] > center[1] - verticalThrehsold &&
nonRotated[1] < center[1] + verticalThrehsold
@ -1118,7 +1117,7 @@ export const snapToMid = (
);
} else if (
element.type === "diamond"
? nonRotated[1] <= y + height * (element.roundness ? 0.035 : 1)
? nonRotated[1] <= y + height * (element.roundness ? 0.035 : 0)
: nonRotated[1] <= y + height / 2 &&
nonRotated[0] > center[0] - horizontalThrehsold &&
nonRotated[0] < center[0] + horizontalThrehsold
@ -1528,7 +1527,7 @@ export const maxBindingGap = (
// bigger bindable boundary for bigger elements
Math.min(0.25 * smallerDimension, 32),
// keep in sync with the zoomed highlight
BINDING_HIGHLIGHT_THICKNESS / zoomValue + BINDING_HIGHLIGHT_OFFSET,
BINDING_HIGHLIGHT_THICKNESS / zoomValue + FIXED_BINDING_DISTANCE,
);
};