mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Remove GA code from binding (#9042)
Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
parent
31e8476c78
commit
0ffeaeaecf
44 changed files with 2112 additions and 1832 deletions
|
@ -1,3 +1,4 @@
|
|||
import { line, linesIntersectAt } from "./line";
|
||||
import {
|
||||
isPoint,
|
||||
pointCenter,
|
||||
|
@ -27,14 +28,6 @@ export function lineSegment<P extends GlobalPoint | LocalPoint>(
|
|||
return [a, b] as LineSegment<P>;
|
||||
}
|
||||
|
||||
export function lineSegmentFromPointArray<P extends GlobalPoint | LocalPoint>(
|
||||
pointArray: P[],
|
||||
): LineSegment<P> | undefined {
|
||||
return pointArray.length === 2
|
||||
? lineSegment<P>(pointArray[0], pointArray[1])
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param segment
|
||||
|
@ -156,3 +149,26 @@ export const distanceToLineSegment = <Point extends LocalPoint | GlobalPoint>(
|
|||
const dy = y - yy;
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the intersection point of a segment and a line
|
||||
*
|
||||
* @param l
|
||||
* @param s
|
||||
* @returns
|
||||
*/
|
||||
export function lineSegmentIntersectionPoints<
|
||||
Point extends GlobalPoint | LocalPoint,
|
||||
>(l: LineSegment<Point>, s: LineSegment<Point>): Point | null {
|
||||
const candidate = linesIntersectAt(line(l[0], l[1]), line(s[0], s[1]));
|
||||
|
||||
if (
|
||||
!candidate ||
|
||||
!pointOnLineSegment(candidate, s) ||
|
||||
!pointOnLineSegment(candidate, l)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue