mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Quarter snap points for diamonds
This commit is contained in:
parent
195a743874
commit
6baf9a93c5
1 changed files with 42 additions and 0 deletions
|
@ -1171,6 +1171,48 @@ export const snapToMid = (
|
||||||
center,
|
center,
|
||||||
angle,
|
angle,
|
||||||
);
|
);
|
||||||
|
} else if (element.type === "diamond") {
|
||||||
|
const sqrtFixedDistance = Math.sqrt(FIXED_BINDING_DISTANCE);
|
||||||
|
const topLeft = pointFrom<GlobalPoint>(
|
||||||
|
x + width / 4 - sqrtFixedDistance,
|
||||||
|
y + height / 4 - sqrtFixedDistance,
|
||||||
|
);
|
||||||
|
const topRight = pointFrom<GlobalPoint>(
|
||||||
|
x + (3 * width) / 4 + sqrtFixedDistance,
|
||||||
|
y + height / 4 - sqrtFixedDistance,
|
||||||
|
);
|
||||||
|
const bottomLeft = pointFrom<GlobalPoint>(
|
||||||
|
x + width / 4 - sqrtFixedDistance,
|
||||||
|
y + (3 * height) / 4 + sqrtFixedDistance,
|
||||||
|
);
|
||||||
|
const bottomRight = pointFrom<GlobalPoint>(
|
||||||
|
x + (3 * width) / 4 + sqrtFixedDistance,
|
||||||
|
y + (3 * height) / 4 + sqrtFixedDistance,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
pointDistance(topLeft, p) <
|
||||||
|
Math.max(horizontalThrehsold, verticalThrehsold)
|
||||||
|
) {
|
||||||
|
return pointRotateRads(topLeft, center, angle);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
pointDistance(topRight, p) <
|
||||||
|
Math.max(horizontalThrehsold, verticalThrehsold)
|
||||||
|
) {
|
||||||
|
return pointRotateRads(topRight, center, angle);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
pointDistance(bottomLeft, p) <
|
||||||
|
Math.max(horizontalThrehsold, verticalThrehsold)
|
||||||
|
) {
|
||||||
|
return pointRotateRads(bottomLeft, center, angle);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
pointDistance(bottomRight, p) <
|
||||||
|
Math.max(horizontalThrehsold, verticalThrehsold)
|
||||||
|
) {
|
||||||
|
return pointRotateRads(bottomRight, center, angle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue