diff --git a/packages/math/src/types.ts b/packages/math/src/types.ts index a2a575bd7..c0b425055 100644 --- a/packages/math/src/types.ts +++ b/packages/math/src/types.ts @@ -27,6 +27,12 @@ export type InclusiveRange = [number, number] & { _brand: "excalimath_degree" }; // Point // +/** + * Represents a 2D position in world or canvas space. A + * unintified glboal, viewport, or local coordinate. + */ +export type GenericPoint = GlobalPoint | ViewportPoint | LocalPoint; + /** * Represents a 2D position in world or canvas space. A * global coordinate. @@ -35,6 +41,14 @@ export type GlobalPoint = [x: number, y: number] & { _brand: "excalimath__globalpoint"; }; +/** + * Represents a 2D position in world or viewport space. A + * viewport coordinate. + */ +export type ViewportPoint = [x: number, y: number] & { + _brand: "excalimath__viewportpoint"; +}; + /** * Represents a 2D position in whatever local space it's * needed. A local coordinate. @@ -48,7 +62,7 @@ export type LocalPoint = [x: number, y: number] & { /** * A line is an infinitely long object with no width, depth, or curvature. */ -export type Line
= [p: P, q: P] & { +export type Line
= [p: P, q: P] & { _brand: "excalimath_line"; }; @@ -57,7 +71,7 @@ export type Line
= [p: P, q: P] & { * line that is bounded by two distinct end points, and * contains every point on the line that is between its endpoints. */ -export type LineSegment
= [a: P, b: P] & { +export type LineSegment
= [a: P, b: P] & { _brand: "excalimath_linesegment"; }; @@ -77,18 +91,14 @@ export type Vector = [u: number, v: number] & { /** * A triangle represented by 3 points */ -export type Triangle
= [ - a: P, - b: P, - c: P, -] & { +export type Triangle
= [a: P, b: P, c: P] & { _brand: "excalimath__triangle"; }; /** * A rectangular shape represented by 4 points at its corners */ -export type Rectangle
= [a: P, b: P] & { +export type Rectangle
= [a: P, b: P] & { _brand: "excalimath__rectangle"; }; @@ -100,7 +110,7 @@ export type Rectangle
= [a: P, b: P] & {
* A polygon is a closed shape by connecting the given points
* rectangles and diamonds are modelled by polygons
*/
-export type Polygon