Merge branch 'master' into dwelle/oxc
# Conflicts: # packages/element/src/binding.ts # packages/element/src/elbowArrow.ts # packages/element/src/linearElementEditor.ts # packages/excalidraw/components/Actions.tsx # packages/excalidraw/components/App.tsx # packages/excalidraw/components/dropdownMenu/DropdownMenuItemLink.tsx # packages/excalidraw/components/dropdownMenu/common.ts # packages/excalidraw/tests/__snapshots__/excalidraw.test.tsx.snap
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { isPoint, pointDistance, pointFrom, pointFromVector } from "./point";
|
||||
import { vector, vectorNormal, vectorNormalize, vectorScale } from "./vector";
|
||||
import { LegendreGaussN24CValues, LegendreGaussN24TValues } from "./constants";
|
||||
import { lineSegment, lineSegmentIntersectionPoints } from "./segment";
|
||||
|
||||
import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
|
||||
|
||||
@@ -139,7 +138,7 @@ const calculate = <Point extends GlobalPoint | LocalPoint>(
|
||||
l: LineSegment<Point>,
|
||||
c: Curve<Point>,
|
||||
) => {
|
||||
const solution = solveWithAnalyticalJacobian(c, l, t0, s0, 1e-2, 3);
|
||||
const solution = solveWithAnalyticalJacobian(c, l, t0, s0, 1e-2, 4);
|
||||
|
||||
if (!solution) {
|
||||
return null;
|
||||
@@ -175,23 +174,6 @@ export function curveIntersectLineSegment<
|
||||
return [solution];
|
||||
}
|
||||
|
||||
// Fallback: approximate the curve with short segments to catch near-endpoint hits.
|
||||
const startHit = lineSegmentIntersectionPoints(
|
||||
lineSegment(bezierEquation(c, 0), bezierEquation(c, 1 / 20)),
|
||||
l,
|
||||
);
|
||||
if (startHit) {
|
||||
return [startHit];
|
||||
}
|
||||
|
||||
const endHit = lineSegmentIntersectionPoints(
|
||||
lineSegment(bezierEquation(c, 19 / 20), bezierEquation(c, 1)),
|
||||
l,
|
||||
);
|
||||
if (endHit) {
|
||||
return [endHit];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import type {
|
||||
Radians,
|
||||
Degrees,
|
||||
Vector,
|
||||
GlobalCoord,
|
||||
LocalCoord,
|
||||
} from "./types";
|
||||
|
||||
/**
|
||||
@@ -20,8 +22,23 @@ import type {
|
||||
export function pointFrom<Point extends GlobalPoint | LocalPoint>(
|
||||
x: number,
|
||||
y: number,
|
||||
): Point;
|
||||
// TODO remove the overload once we migrate to using Point tuples everywhere
|
||||
export function pointFrom<Coord extends GlobalCoord | LocalCoord>(
|
||||
coords: Coord,
|
||||
): Coord extends GlobalCoord ? GlobalPoint : LocalPoint;
|
||||
// TODO remove the overload once we migrate to using Point tuples everywhere
|
||||
export function pointFrom<Point extends GlobalPoint | LocalPoint>(coords: {
|
||||
x: number;
|
||||
y: number;
|
||||
}): Point;
|
||||
export function pointFrom<Point extends GlobalPoint | LocalPoint>(
|
||||
xOrCoords: number | { x: number; y: number },
|
||||
y?: number,
|
||||
): Point {
|
||||
return [x, y] as Point;
|
||||
return typeof xOrCoords === "object"
|
||||
? ([xOrCoords.x, xOrCoords.y] as Point)
|
||||
: ([xOrCoords, y!] as Point);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,13 +28,23 @@ export type InclusiveRange = [number, number] & { _brand: "excalimath_degree" };
|
||||
//
|
||||
|
||||
/**
|
||||
* Represents a 2D position in world or canvas space. A
|
||||
* Represents a 2D position in world/canvas/scene space. A
|
||||
* global coordinate.
|
||||
*/
|
||||
export type GlobalPoint = [x: number, y: number] & {
|
||||
_brand: "excalimath__globalpoint";
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a 2D position in world/canvas/scene space. A
|
||||
* global coordinate.
|
||||
*
|
||||
* TODO remove this once we migrate the codebase to use Point tuples everywhere
|
||||
*/
|
||||
export type GlobalCoord = { x: number; y: number } & {
|
||||
_brand: "excalimath__globalcoord";
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a 2D position in whatever local space it's
|
||||
* needed. A local coordinate.
|
||||
@@ -43,6 +53,16 @@ export type LocalPoint = [x: number, y: number] & {
|
||||
_brand: "excalimath__localpoint";
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a 2D position in whatever local space it's needed.
|
||||
* A local coordinate.
|
||||
*
|
||||
* TODO remove this once we migrate the codebase to use Point tuples everywhere
|
||||
*/
|
||||
export type LocalCoord = { x: number; y: number } & {
|
||||
_brand: "excalimath__localcoord";
|
||||
};
|
||||
|
||||
// Line
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user