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,5 +1,5 @@
|
|||
import { pointCenter, pointFrom, pointRotateRads } from "./point";
|
||||
import type { GlobalPoint, Line, LocalPoint, Radians } from "./types";
|
||||
import { pointFrom } from "./point";
|
||||
import type { GlobalPoint, Line, LocalPoint } from "./types";
|
||||
|
||||
/**
|
||||
* Create a line from two points.
|
||||
|
@ -11,54 +11,6 @@ export function line<P extends GlobalPoint | LocalPoint>(a: P, b: P): Line<P> {
|
|||
return [a, b] as Line<P>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient point creation from an array of two points.
|
||||
*
|
||||
* @param param0 The array with the two points to convert to a line
|
||||
* @returns The created line
|
||||
*/
|
||||
export function lineFromPointPair<P extends GlobalPoint | LocalPoint>([a, b]: [
|
||||
P,
|
||||
P,
|
||||
]): Line<P> {
|
||||
return line(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @param pointArray
|
||||
* @returns
|
||||
*/
|
||||
export function lineFromPointArray<P extends GlobalPoint | LocalPoint>(
|
||||
pointArray: P[],
|
||||
): Line<P> | undefined {
|
||||
return pointArray.length === 2
|
||||
? line<P>(pointArray[0], pointArray[1])
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the coordinates resulting from rotating the given line about an
|
||||
* origin by an angle in degrees note that when the origin is not given,
|
||||
* the midpoint of the given line is used as the origin
|
||||
*
|
||||
* @param l
|
||||
* @param angle
|
||||
* @param origin
|
||||
* @returns
|
||||
*/
|
||||
export const lineRotate = <Point extends LocalPoint | GlobalPoint>(
|
||||
l: Line<Point>,
|
||||
angle: Radians,
|
||||
origin?: Point,
|
||||
): Line<Point> => {
|
||||
return line(
|
||||
pointRotateRads(l[0], origin || pointCenter(l[0], l[1]), angle),
|
||||
pointRotateRads(l[1], origin || pointCenter(l[0], l[1]), angle),
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines the intersection point (unless the lines are parallel) of two
|
||||
* lines
|
||||
|
@ -67,10 +19,10 @@ export const lineRotate = <Point extends LocalPoint | GlobalPoint>(
|
|||
* @param b
|
||||
* @returns
|
||||
*/
|
||||
export const linesIntersectAt = <Point extends GlobalPoint | LocalPoint>(
|
||||
export function linesIntersectAt<Point extends GlobalPoint | LocalPoint>(
|
||||
a: Line<Point>,
|
||||
b: Line<Point>,
|
||||
): Point | null => {
|
||||
): Point | null {
|
||||
const A1 = a[1][1] - a[0][1];
|
||||
const B1 = a[0][0] - a[1][0];
|
||||
const A2 = b[1][1] - b[0][1];
|
||||
|
@ -83,4 +35,4 @@ export const linesIntersectAt = <Point extends GlobalPoint | LocalPoint>(
|
|||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue