refactor: point() -> pointFrom() to fix compiler issue (#8578)

This commit is contained in:
David Luzar 2024-10-01 21:27:17 +02:00 committed by GitHub
parent a977dd1bf5
commit 47ee8a0094
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 845 additions and 703 deletions

View file

@ -16,7 +16,7 @@ import { vectorFromPoint, vectorScale } from "./vector";
* @param y The Y coordinate
* @returns The branded and created point
*/
export function point<Point extends GlobalPoint | LocalPoint>(
export function pointFrom<Point extends GlobalPoint | LocalPoint>(
x: number,
y: number,
): Point {
@ -33,7 +33,7 @@ export function pointFromArray<Point extends GlobalPoint | LocalPoint>(
numberArray: number[],
): Point | undefined {
return numberArray.length === 2
? point<Point>(numberArray[0], numberArray[1])
? pointFrom<Point>(numberArray[0], numberArray[1])
: undefined;
}
@ -107,7 +107,7 @@ export function pointRotateRads<Point extends GlobalPoint | LocalPoint>(
[cx, cy]: Point,
angle: Radians,
): Point {
return point(
return pointFrom(
(x - cx) * Math.cos(angle) - (y - cy) * Math.sin(angle) + cx,
(x - cx) * Math.sin(angle) + (y - cy) * Math.cos(angle) + cy,
);
@ -146,7 +146,7 @@ export function pointTranslate<
From extends GlobalPoint | LocalPoint,
To extends GlobalPoint | LocalPoint,
>(p: From, v: Vector = [0, 0] as Vector): To {
return point(p[0] + v[0], p[1] + v[1]);
return pointFrom(p[0] + v[0], p[1] + v[1]);
}
/**
@ -157,7 +157,7 @@ export function pointTranslate<
* @returns The middle point
*/
export function pointCenter<P extends LocalPoint | GlobalPoint>(a: P, b: P): P {
return point((a[0] + b[0]) / 2, (a[1] + b[1]) / 2);
return pointFrom((a[0] + b[0]) / 2, (a[1] + b[1]) / 2);
}
/**
@ -172,7 +172,7 @@ export function pointAdd<Point extends LocalPoint | GlobalPoint>(
a: Point,
b: Point,
): Point {
return point(a[0] + b[0], a[1] + b[1]);
return pointFrom(a[0] + b[0], a[1] + b[1]);
}
/**
@ -187,7 +187,7 @@ export function pointSubtract<Point extends LocalPoint | GlobalPoint>(
a: Point,
b: Point,
): Point {
return point(a[0] - b[0], a[1] - b[1]);
return pointFrom(a[0] - b[0], a[1] - b[1]);
}
/**