mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-15 18:25:58 +01:00
refactor: point() -> pointFrom() to fix compiler issue (#8578)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { point, pointRotateRads } from "./point";
|
||||
import { pointFrom, pointRotateRads } from "./point";
|
||||
import type { Curve, GlobalPoint, LocalPoint, Radians } from "./types";
|
||||
|
||||
/**
|
||||
@@ -43,10 +43,10 @@ export function curveToBezier<Point extends LocalPoint | GlobalPoint>(
|
||||
const out: Point[] = [];
|
||||
if (len === 3) {
|
||||
out.push(
|
||||
point(pointsIn[0][0], pointsIn[0][1]), // Points need to be cloned
|
||||
point(pointsIn[1][0], pointsIn[1][1]), // Points need to be cloned
|
||||
point(pointsIn[2][0], pointsIn[2][1]), // Points need to be cloned
|
||||
point(pointsIn[2][0], pointsIn[2][1]), // Points need to be cloned
|
||||
pointFrom(pointsIn[0][0], pointsIn[0][1]), // Points need to be cloned
|
||||
pointFrom(pointsIn[1][0], pointsIn[1][1]), // Points need to be cloned
|
||||
pointFrom(pointsIn[2][0], pointsIn[2][1]), // Points need to be cloned
|
||||
pointFrom(pointsIn[2][0], pointsIn[2][1]), // Points need to be cloned
|
||||
);
|
||||
} else {
|
||||
const points: Point[] = [];
|
||||
@@ -59,19 +59,19 @@ export function curveToBezier<Point extends LocalPoint | GlobalPoint>(
|
||||
}
|
||||
const b: Point[] = [];
|
||||
const s = 1 - curveTightness;
|
||||
out.push(point(points[0][0], points[0][1]));
|
||||
out.push(pointFrom(points[0][0], points[0][1]));
|
||||
for (let i = 1; i + 2 < points.length; i++) {
|
||||
const cachedVertArray = points[i];
|
||||
b[0] = point(cachedVertArray[0], cachedVertArray[1]);
|
||||
b[1] = point(
|
||||
b[0] = pointFrom(cachedVertArray[0], cachedVertArray[1]);
|
||||
b[1] = pointFrom(
|
||||
cachedVertArray[0] + (s * points[i + 1][0] - s * points[i - 1][0]) / 6,
|
||||
cachedVertArray[1] + (s * points[i + 1][1] - s * points[i - 1][1]) / 6,
|
||||
);
|
||||
b[2] = point(
|
||||
b[2] = pointFrom(
|
||||
points[i + 1][0] + (s * points[i][0] - s * points[i + 2][0]) / 6,
|
||||
points[i + 1][1] + (s * points[i][1] - s * points[i + 2][1]) / 6,
|
||||
);
|
||||
b[3] = point(points[i + 1][0], points[i + 1][1]);
|
||||
b[3] = pointFrom(points[i + 1][0], points[i + 1][1]);
|
||||
out.push(b[1], b[2], b[3]);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export const cubicBezierPoint = <Point extends LocalPoint | GlobalPoint>(
|
||||
3 * (1 - t) * Math.pow(t, 2) * p2[1] +
|
||||
Math.pow(t, 3) * p3[1];
|
||||
|
||||
return point(x, y);
|
||||
return pointFrom(x, y);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user