mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Fix diamond intersection
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
parent
6baf9a93c5
commit
92ca773f85
1 changed files with 7 additions and 15 deletions
|
@ -44,7 +44,6 @@ import { intersectElementWithLineSegment } from "./collision";
|
||||||
import { distanceToBindableElement } from "./distance";
|
import { distanceToBindableElement } from "./distance";
|
||||||
import {
|
import {
|
||||||
headingForPointFromElement,
|
headingForPointFromElement,
|
||||||
headingIsHorizontal,
|
|
||||||
vectorToHeading,
|
vectorToHeading,
|
||||||
type Heading,
|
type Heading,
|
||||||
} from "./heading";
|
} from "./heading";
|
||||||
|
@ -947,23 +946,16 @@ export const bindPointToSnapToElementOutline = (
|
||||||
|
|
||||||
let intersection: GlobalPoint | null = null;
|
let intersection: GlobalPoint | null = null;
|
||||||
if (elbowed) {
|
if (elbowed) {
|
||||||
const isHorizontal = headingIsHorizontal(
|
|
||||||
headingForPointFromElement(bindableElement, aabb, globalP),
|
|
||||||
);
|
|
||||||
const otherPoint = pointFrom<GlobalPoint>(
|
|
||||||
isHorizontal ? center[0] : edgePoint[0],
|
|
||||||
!isHorizontal ? center[1] : edgePoint[1],
|
|
||||||
);
|
|
||||||
intersection = intersectElementWithLineSegment(
|
intersection = intersectElementWithLineSegment(
|
||||||
bindableElement,
|
bindableElement,
|
||||||
lineSegment(
|
lineSegment(
|
||||||
otherPoint,
|
center,
|
||||||
pointFromVector(
|
pointFromVector(
|
||||||
vectorScale(
|
vectorScale(
|
||||||
vectorNormalize(vectorFromPoint(edgePoint, otherPoint)),
|
vectorNormalize(vectorFromPoint(edgePoint, center)),
|
||||||
Math.max(bindableElement.width, bindableElement.height) * 2,
|
Math.max(bindableElement.width, bindableElement.height) * 2,
|
||||||
),
|
),
|
||||||
otherPoint,
|
center,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)[0];
|
)[0];
|
||||||
|
@ -1190,25 +1182,25 @@ export const snapToMid = (
|
||||||
y + (3 * height) / 4 + sqrtFixedDistance,
|
y + (3 * height) / 4 + sqrtFixedDistance,
|
||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
pointDistance(topLeft, p) <
|
pointDistance(topLeft, nonRotated) <
|
||||||
Math.max(horizontalThrehsold, verticalThrehsold)
|
Math.max(horizontalThrehsold, verticalThrehsold)
|
||||||
) {
|
) {
|
||||||
return pointRotateRads(topLeft, center, angle);
|
return pointRotateRads(topLeft, center, angle);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
pointDistance(topRight, p) <
|
pointDistance(topRight, nonRotated) <
|
||||||
Math.max(horizontalThrehsold, verticalThrehsold)
|
Math.max(horizontalThrehsold, verticalThrehsold)
|
||||||
) {
|
) {
|
||||||
return pointRotateRads(topRight, center, angle);
|
return pointRotateRads(topRight, center, angle);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
pointDistance(bottomLeft, p) <
|
pointDistance(bottomLeft, nonRotated) <
|
||||||
Math.max(horizontalThrehsold, verticalThrehsold)
|
Math.max(horizontalThrehsold, verticalThrehsold)
|
||||||
) {
|
) {
|
||||||
return pointRotateRads(bottomLeft, center, angle);
|
return pointRotateRads(bottomLeft, center, angle);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
pointDistance(bottomRight, p) <
|
pointDistance(bottomRight, nonRotated) <
|
||||||
Math.max(horizontalThrehsold, verticalThrehsold)
|
Math.max(horizontalThrehsold, verticalThrehsold)
|
||||||
) {
|
) {
|
||||||
return pointRotateRads(bottomRight, center, angle);
|
return pointRotateRads(bottomRight, center, angle);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue