mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Unify on GenericPoint type
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
parent
0c47bd0004
commit
017047d15e
7 changed files with 68 additions and 115 deletions
|
@ -1,4 +1,4 @@
|
|||
import type { GlobalPoint, LocalPoint, Vector, ViewportPoint } from "./types";
|
||||
import type { GenericPoint, Vector } from "./types";
|
||||
|
||||
/**
|
||||
* Create a vector from the x and y coordiante elements.
|
||||
|
@ -23,9 +23,10 @@ export function vector(
|
|||
* @param origin The origin point in a given coordiante system
|
||||
* @returns The created vector from the point and the origin
|
||||
*/
|
||||
export function vectorFromPoint<
|
||||
Point extends GlobalPoint | LocalPoint | ViewportPoint,
|
||||
>(p: Point, origin: Point = [0, 0] as Point): Vector {
|
||||
export function vectorFromPoint<Point extends GenericPoint>(
|
||||
p: Point,
|
||||
origin: Point = [0, 0] as Point,
|
||||
): Vector {
|
||||
return vector(p[0] - origin[0], p[1] - origin[1]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue