mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-15 02:04:21 +01:00
feat: Elbow arrow segment fixing & positioning (#8952)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com> Co-authored-by: David Luzar <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
@@ -61,6 +61,22 @@ export function pointFromVector<P extends GlobalPoint | LocalPoint>(
|
||||
return v as unknown as P;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the coordiante object to a point.
|
||||
*
|
||||
* @param coords The coordinate object with x and y properties
|
||||
* @returns
|
||||
*/
|
||||
export function pointFromCoords<Point extends GlobalPoint | LocalPoint>({
|
||||
x,
|
||||
y,
|
||||
}: {
|
||||
x: number;
|
||||
y: number;
|
||||
}) {
|
||||
return [x, y] as Point;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the provided value has the shape of a Point.
|
||||
*
|
||||
@@ -217,7 +233,10 @@ export function pointDistanceSq<P extends LocalPoint | GlobalPoint>(
|
||||
a: P,
|
||||
b: P,
|
||||
): number {
|
||||
return Math.hypot(b[0] - a[0], b[1] - a[1]);
|
||||
const xDiff = b[0] - a[0];
|
||||
const yDiff = b[1] - a[1];
|
||||
|
||||
return xDiff * xDiff + yDiff * yDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user