@weasel-js/geom 1.9.2 → 1.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d/index.js +1 -1
- package/dist/booleans/index.d.ts +8 -1
- package/dist/booleans/index.js +348 -304
- package/dist/booleans/index.js.map +1 -1
- package/dist/{chunk-HEZTRG2M.js → chunk-E4TJRGJD.js} +10 -3
- package/dist/chunk-E4TJRGJD.js.map +1 -0
- package/dist/{chunk-7ROQRYOA.js → chunk-N5SYTHMR.js} +6 -3
- package/dist/chunk-N5SYTHMR.js.map +1 -0
- package/dist/{chunk-6T5I3PR5.js → chunk-NL423YYZ.js} +16 -5
- package/dist/chunk-NL423YYZ.js.map +1 -0
- package/dist/{chunk-RQYCDPU5.js → chunk-X6GJRIQD.js} +14 -17
- package/dist/chunk-X6GJRIQD.js.map +1 -0
- package/dist/curves/index.js +17 -70
- package/dist/curves/index.js.map +1 -1
- package/dist/index.d.ts +44 -4
- package/dist/index.js +39 -26
- package/dist/index.js.map +1 -1
- package/dist/tessellate/index.js +19 -10
- package/dist/tessellate/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6T5I3PR5.js.map +0 -1
- package/dist/chunk-7ROQRYOA.js.map +0 -1
- package/dist/chunk-HEZTRG2M.js.map +0 -1
- package/dist/chunk-RQYCDPU5.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { PORT_REACH } from './nd/index.js';
|
|
|
13
13
|
*/
|
|
14
14
|
/** Base relative epsilon, sized for Float32 storage (~1 part in 1e-6). */
|
|
15
15
|
declare const EPS = 0.000001;
|
|
16
|
+
/** `v` held to `lo`..`hi`. `lo` wins when the bounds cross; `NaN` passes through. */
|
|
17
|
+
declare function clamp(v: number, lo: number, hi: number): number;
|
|
16
18
|
/** 2D cross (wedge) product of vectors (ax,ay) and (bx,by). */
|
|
17
19
|
declare function cross(ax: number, ay: number, bx: number, by: number): number;
|
|
18
20
|
/** 2D dot product. */
|
|
@@ -37,6 +39,38 @@ declare function sign(n: number): -1 | 0 | 1;
|
|
|
37
39
|
*/
|
|
38
40
|
declare function approxEq(a: number, b: number, eps?: number): boolean;
|
|
39
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Viewport state. `(view.x, view.y)` is the world point currently rendered at
|
|
44
|
+
* the canvas top-left; `view.scale.x` / `view.scale.y` is pixels per world
|
|
45
|
+
* unit on each axis.
|
|
46
|
+
*
|
|
47
|
+
* A `View` names no orientation, so a kernel with a camera cannot express its
|
|
48
|
+
* viewport as one.
|
|
49
|
+
*/
|
|
50
|
+
interface View {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
scale: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The smallest zoom magnitude a view can hold, in `View.scale` units.
|
|
60
|
+
*
|
|
61
|
+
* A view's zoom is always finite and at least this far from 0. Nothing can be
|
|
62
|
+
* drawn or picked through a zoom of 0, and every screen↔world conversion
|
|
63
|
+
* divides by it, so it is ruled out where views are made rather than handled
|
|
64
|
+
* by each conversion.
|
|
65
|
+
*/
|
|
66
|
+
declare const ZOOM_FLOOR = 1e-9;
|
|
67
|
+
/**
|
|
68
|
+
* The one rule for a zoom magnitude: a finite number no smaller than
|
|
69
|
+
* {@link ZOOM_FLOOR}. Anything else (0, negative, NaN, ±Infinity) becomes the
|
|
70
|
+
* floor.
|
|
71
|
+
*/
|
|
72
|
+
declare function normalizeZoom(zoom: number): number;
|
|
73
|
+
|
|
40
74
|
/** `[a, b, c, d, e, f]`: `x' = a·x + c·y + e`, `y' = b·x + d·y + f`. */
|
|
41
75
|
type Mat3 = readonly [number, number, number, number, number, number];
|
|
42
76
|
/** The transform that leaves a point where it is. */
|
|
@@ -150,10 +184,14 @@ declare function pathCommandCoordCount(cmd: number): number;
|
|
|
150
184
|
* returns it to the subpath's opening `M`, so a command following a `Z`
|
|
151
185
|
* without an intervening `M` starts where SVG says it does.
|
|
152
186
|
*
|
|
187
|
+
* Such a command opens a new subpath at the pen, as does a drawing command
|
|
188
|
+
* no `M` precedes at all. The visitor is told with `opensSubpath`, and has to
|
|
189
|
+
* start its contour at `(penX, penY)` then: there is no `M` to do it.
|
|
190
|
+
*
|
|
153
191
|
* A code `PATH_COMMANDS` does not declare throws once the visitor has seen it,
|
|
154
192
|
* since the walker cannot tell how many coords it consumes.
|
|
155
193
|
*/
|
|
156
|
-
declare function forEachSegment(commands: ArrayLike<number>, coords: ArrayLike<number>, visit: (cmd: number, coordIndex: number, penX: number, penY: number, commandIndex: number) => void | boolean): void;
|
|
194
|
+
declare function forEachSegment(commands: ArrayLike<number>, coords: ArrayLike<number>, visit: (cmd: number, coordIndex: number, penX: number, penY: number, commandIndex: number, opensSubpath: boolean) => void | boolean): void;
|
|
157
195
|
|
|
158
196
|
/** Cubic Bezier point at parameter t (de Casteljau / Bernstein form). */
|
|
159
197
|
declare function cubicEvalAt(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, t: number): [number, number];
|
|
@@ -440,7 +478,7 @@ declare function scalePathToBounds(path: Path, target: RectPath): Path;
|
|
|
440
478
|
|
|
441
479
|
/** Apply an affine `Mat3` to a path's geometry.
|
|
442
480
|
*
|
|
443
|
-
* Axis-aligned maps (no rotation/shear
|
|
481
|
+
* Axis-aligned maps (no rotation/shear: `m[1]` and `m[2]` within 1e-9 of 0) keep a
|
|
444
482
|
* `RectPath` a rect — the four corners stay axis-aligned, so we transform the
|
|
445
483
|
* two diagonal corners and normalize negative extent (mirror). Rotation or
|
|
446
484
|
* shear promotes the rect's four corners to a `PolygonPath`. Polygon paths map
|
|
@@ -537,7 +575,9 @@ declare function reversePath(path: PolygonPath): PolygonPath;
|
|
|
537
575
|
/**
|
|
538
576
|
* Build a weasel `PolygonPath` from an SVG path-data (`d`) string. Unknown
|
|
539
577
|
* command letters are skipped (and reported via `onWarn` when provided); the
|
|
540
|
-
* builder still returns whatever valid commands preceded them.
|
|
578
|
+
* builder still returns whatever valid commands preceded them. Data that does
|
|
579
|
+
* not begin with a moveto builds an empty path, and a command with the wrong
|
|
580
|
+
* number of arguments ends the path before it, as SVG renders both.
|
|
541
581
|
*/
|
|
542
582
|
declare function pathFromD(d: string, onWarn?: (message: string) => void): ReturnType<PathBuilder['build']>;
|
|
543
583
|
|
|
@@ -867,4 +907,4 @@ declare function cubicBezierEasing(x1: number, y1: number, x2: number, y2: numbe
|
|
|
867
907
|
/** Resolve a spec to the function that shapes progress. `undefined` is linear. */
|
|
868
908
|
declare function resolveEasing(spec?: EasingSpec): EasingFn;
|
|
869
909
|
|
|
870
|
-
export { type BezierEasing, type Box, type CubicCoords, type CurveNearest, DEFAULT_FLATTEN_TOLERANCE, EASINGS, EPS, type EasingFn, type EasingName, type EasingSpec, type LineCoords, type Mat3, PATH_C, PATH_CMD_LENGTHS, PATH_COMMANDS, PATH_L, PATH_M, PATH_Q, PATH_Z, Path, PathBuilder, type PathCommandCode, type PathCommandName, PathFillRule, type PathNearest, type PathStation, type PlaceRectOptions, type PlacedRect, type Placement, type PlacementAlign, type PlacementSide, Point, type PointAlongPathOptions, type PointInPathOptions, PolygonPath, type QuadraticCoords, type Rect, RectPath, SPRING_PRESETS, type SpringPreset, type SpringPresetName, type StrokeHitTestOptions, applyToPoint, approxEq, boundsOfCoords, boundsOfPath, boxContainsBox, boxContainsPoint, boxToBox, clampRectWithin, composePath, cross, cubicBezierEasing, cubicBounds, cubicEvalAt, decomposePath, dot, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, elevateQuadraticToCubic, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, forEachSegment, identity, invert, len2, linePath, linear, multiply, nearestOnCubic, nearestOnLine, nearestOnPath, nearestOnQuadratic, pathCommandCoordCount, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathFromD, pathIntersectsPolygon, pathIntersectsRect, pathSignedArea, placeRect, pointAlongPath, pointInPath, pointInPolygon, pointSegmentDist2, polygonContainsPath, polygonFromPoints, polygonIntersectsPath, polylineFromPoints, portControls, portCurvePoints, quadraticEvalAt, rectPath, rectToContour, regularPolygonPath, resolveEasing, reversePath, rotate, rotateAboutPoint, scale, scalePathToBounds, schneiderFit, segmentsCross, sign, splitCubicAt, splitLineAt, splitQuadraticAt, splitSubpaths, starPath, strokeHitTest, sub, transformCoords, transformPath, translate, translatePath, unionBoundsPath, unionBox };
|
|
910
|
+
export { type BezierEasing, type Box, type CubicCoords, type CurveNearest, DEFAULT_FLATTEN_TOLERANCE, EASINGS, EPS, type EasingFn, type EasingName, type EasingSpec, type LineCoords, type Mat3, PATH_C, PATH_CMD_LENGTHS, PATH_COMMANDS, PATH_L, PATH_M, PATH_Q, PATH_Z, Path, PathBuilder, type PathCommandCode, type PathCommandName, PathFillRule, type PathNearest, type PathStation, type PlaceRectOptions, type PlacedRect, type Placement, type PlacementAlign, type PlacementSide, Point, type PointAlongPathOptions, type PointInPathOptions, PolygonPath, type QuadraticCoords, type Rect, RectPath, SPRING_PRESETS, type SpringPreset, type SpringPresetName, type StrokeHitTestOptions, type View, ZOOM_FLOOR, applyToPoint, approxEq, boundsOfCoords, boundsOfPath, boxContainsBox, boxContainsPoint, boxToBox, clamp, clampRectWithin, composePath, cross, cubicBezierEasing, cubicBounds, cubicEvalAt, decomposePath, dot, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, elevateQuadraticToCubic, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, forEachSegment, identity, invert, len2, linePath, linear, multiply, nearestOnCubic, nearestOnLine, nearestOnPath, nearestOnQuadratic, normalizeZoom, pathCommandCoordCount, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathFromD, pathIntersectsPolygon, pathIntersectsRect, pathSignedArea, placeRect, pointAlongPath, pointInPath, pointInPolygon, pointSegmentDist2, polygonContainsPath, polygonFromPoints, polygonIntersectsPath, polylineFromPoints, portControls, portCurvePoints, quadraticEvalAt, rectPath, rectToContour, regularPolygonPath, resolveEasing, reversePath, rotate, rotateAboutPoint, scale, scalePathToBounds, schneiderFit, segmentsCross, sign, splitCubicAt, splitLineAt, splitQuadraticAt, splitSubpaths, starPath, strokeHitTest, sub, transformCoords, transformPath, translate, translatePath, unionBoundsPath, unionBox };
|
package/dist/index.js
CHANGED
|
@@ -4,14 +4,20 @@ import { cubicPointAt } from './chunk-HPVINMOM.js';
|
|
|
4
4
|
export { cubicPointAt, fitCubicThroughDeletion, splitCubicAtT } from './chunk-HPVINMOM.js';
|
|
5
5
|
import { cubicEvalAt, elevateQuadraticToCubic, cubicBounds } from './chunk-URQMDR6Q.js';
|
|
6
6
|
export { cubicBounds, cubicEvalAt, elevateQuadraticToCubic, quadraticEvalAt, splitCubicAt, splitLineAt, splitQuadraticAt } from './chunk-URQMDR6Q.js';
|
|
7
|
-
import { extractPolylines } from './chunk-
|
|
8
|
-
export { boundsOfCoords, boxContainsBox, boxContainsPoint, rectToContour, unionBox } from './chunk-
|
|
9
|
-
import { DEFAULT_FLATTEN_TOLERANCE, pointInPolygon, pointSegmentDist2, flattenQuadratic, flattenCubic, segmentsCross } from './chunk-
|
|
10
|
-
export { DEFAULT_FLATTEN_TOLERANCE, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, pointInPolygon, pointSegmentDist2, segmentsCross } from './chunk-
|
|
11
|
-
import { SINGULAR_RATIO } from './chunk-
|
|
12
|
-
export { EPS, approxEq, cross, dot, len2, sign, sub } from './chunk-
|
|
13
|
-
import { forEachSegment, PATH_M, PATH_L, PATH_Q, PATH_C, PATH_Z, pathCommandCoordCount } from './chunk-
|
|
14
|
-
export { PATH_C, PATH_CMD_LENGTHS, PATH_COMMANDS, PATH_L, PATH_M, PATH_Q, PATH_Z, forEachSegment, pathCommandCoordCount } from './chunk-
|
|
7
|
+
import { extractPolylines } from './chunk-NL423YYZ.js';
|
|
8
|
+
export { boundsOfCoords, boxContainsBox, boxContainsPoint, rectToContour, unionBox } from './chunk-NL423YYZ.js';
|
|
9
|
+
import { DEFAULT_FLATTEN_TOLERANCE, pointInPolygon, pointSegmentDist2, flattenQuadratic, flattenCubic, segmentsCross } from './chunk-X6GJRIQD.js';
|
|
10
|
+
export { DEFAULT_FLATTEN_TOLERANCE, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, pointInPolygon, pointSegmentDist2, segmentsCross } from './chunk-X6GJRIQD.js';
|
|
11
|
+
import { SINGULAR_RATIO } from './chunk-N5SYTHMR.js';
|
|
12
|
+
export { EPS, approxEq, clamp, cross, dot, len2, sign, sub } from './chunk-N5SYTHMR.js';
|
|
13
|
+
import { forEachSegment, PATH_M, PATH_L, PATH_Q, PATH_C, PATH_Z, pathCommandCoordCount } from './chunk-E4TJRGJD.js';
|
|
14
|
+
export { PATH_C, PATH_CMD_LENGTHS, PATH_COMMANDS, PATH_L, PATH_M, PATH_Q, PATH_Z, forEachSegment, pathCommandCoordCount } from './chunk-E4TJRGJD.js';
|
|
15
|
+
|
|
16
|
+
// src/view.ts
|
|
17
|
+
var ZOOM_FLOOR = 1e-9;
|
|
18
|
+
function normalizeZoom(zoom) {
|
|
19
|
+
return zoom >= ZOOM_FLOOR && zoom < Infinity ? zoom : ZOOM_FLOOR;
|
|
20
|
+
}
|
|
15
21
|
|
|
16
22
|
// src/mat3.ts
|
|
17
23
|
function identity() {
|
|
@@ -404,10 +410,11 @@ function transformCoords(coords, m) {
|
|
|
404
410
|
}
|
|
405
411
|
|
|
406
412
|
// src/paths/transformPath.ts
|
|
413
|
+
var AXIS_ALIGNED_EPSILON = 1e-9;
|
|
407
414
|
function transformPath(path, m) {
|
|
408
415
|
const [a, b, c, d, e, f] = m;
|
|
409
416
|
if (path.kind === "rect") {
|
|
410
|
-
if (b
|
|
417
|
+
if (Math.abs(b) < AXIS_ALIGNED_EPSILON && Math.abs(c) < AXIS_ALIGNED_EPSILON) {
|
|
411
418
|
const x0 = a * path.x + e;
|
|
412
419
|
const y0 = d * path.y + f;
|
|
413
420
|
const x1 = a * (path.x + path.width) + e;
|
|
@@ -470,16 +477,8 @@ function decomposePath(parent, world) {
|
|
|
470
477
|
return translatePath(world, -origin.x, -origin.y);
|
|
471
478
|
}
|
|
472
479
|
function pathOrigin(path) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
let minY = Infinity;
|
|
476
|
-
const { coords } = path;
|
|
477
|
-
for (let i = 0; i < coords.length; i += 2) {
|
|
478
|
-
if (coords[i] < minX) minX = coords[i];
|
|
479
|
-
if (coords[i + 1] < minY) minY = coords[i + 1];
|
|
480
|
-
}
|
|
481
|
-
if (minX === Infinity) return { x: 0, y: 0 };
|
|
482
|
-
return { x: minX, y: minY };
|
|
480
|
+
const { x, y } = boundsOfPath(path);
|
|
481
|
+
return { x, y };
|
|
483
482
|
}
|
|
484
483
|
|
|
485
484
|
// src/paths/splitSubpaths.ts
|
|
@@ -724,6 +723,7 @@ function pathFromD(d, onWarn) {
|
|
|
724
723
|
lastCubicCtrl: null,
|
|
725
724
|
lastQuadCtrl: null
|
|
726
725
|
};
|
|
726
|
+
let started = false;
|
|
727
727
|
for (const { cmd, args } of tokens) {
|
|
728
728
|
const upper = cmd.toUpperCase();
|
|
729
729
|
const relative = cmd !== upper;
|
|
@@ -732,6 +732,10 @@ function pathFromD(d, onWarn) {
|
|
|
732
732
|
onWarn?.(`unknown path command: ${cmd}`);
|
|
733
733
|
continue;
|
|
734
734
|
}
|
|
735
|
+
if (!started && upper !== "M") {
|
|
736
|
+
onWarn?.(`path data does not begin with a moveto ("${cmd}" comes first); nothing is drawn`);
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
735
739
|
if (upper === "Z") {
|
|
736
740
|
b.close();
|
|
737
741
|
st.x = st.startX;
|
|
@@ -740,11 +744,16 @@ function pathFromD(d, onWarn) {
|
|
|
740
744
|
st.lastQuadCtrl = null;
|
|
741
745
|
continue;
|
|
742
746
|
}
|
|
743
|
-
const groups =
|
|
747
|
+
const groups = Math.floor(args.length / argCount);
|
|
744
748
|
for (let g = 0; g < groups; g++) {
|
|
745
749
|
const a = args.slice(g * argCount, (g + 1) * argCount);
|
|
746
750
|
const effectiveUpper = upper === "M" && g > 0 ? "L" : upper;
|
|
747
751
|
runCommand(effectiveUpper, relative, a, st, b);
|
|
752
|
+
started = true;
|
|
753
|
+
}
|
|
754
|
+
if (groups === 0 || args.length % argCount !== 0) {
|
|
755
|
+
onWarn?.(`path command "${cmd}" takes ${argCount} arguments at a time and has ${args.length}; the path ends before it`);
|
|
756
|
+
break;
|
|
748
757
|
}
|
|
749
758
|
}
|
|
750
759
|
return b.build();
|
|
@@ -1042,8 +1051,7 @@ function measureError(samples, fit) {
|
|
|
1042
1051
|
let worstError = 0;
|
|
1043
1052
|
const a = samples[0];
|
|
1044
1053
|
for (let i = 1; i < samples.length - 1; i++) {
|
|
1045
|
-
const
|
|
1046
|
-
const q = cubicPointAt(a, fit.cp1, fit.cp2, fit.end, t);
|
|
1054
|
+
const q = cubicPointAt(a, fit.cp1, fit.cp2, fit.end, fit.ts[i]);
|
|
1047
1055
|
const dx = samples[i].x - q.x;
|
|
1048
1056
|
const dy = samples[i].y - q.y;
|
|
1049
1057
|
const sq = dx * dx + dy * dy;
|
|
@@ -1061,7 +1069,7 @@ function fitOneCubic(samples) {
|
|
|
1061
1069
|
const tStart = unit(sub2(samples[1], a));
|
|
1062
1070
|
const tEnd = unit(sub2(samples[n - 2], e));
|
|
1063
1071
|
const ts = chordLengthParam(samples);
|
|
1064
|
-
if (ts === null) return { cp1: { ...a }, cp2: { ...e }, end: e };
|
|
1072
|
+
if (ts === null) return { cp1: { ...a }, cp2: { ...e }, end: e, ts: samples.map(() => 0) };
|
|
1065
1073
|
let fit = solveLS(samples, ts, a, e, tStart, tEnd);
|
|
1066
1074
|
for (let pass = 0; pass < 4; pass++) {
|
|
1067
1075
|
reparameterize(samples, ts, a, e, fit);
|
|
@@ -1121,7 +1129,8 @@ function solveLS(samples, ts, a, e, tStart, tEnd) {
|
|
|
1121
1129
|
return {
|
|
1122
1130
|
cp1: { x: a.x + tStart.x * alpha1, y: a.y + tStart.y * alpha1 },
|
|
1123
1131
|
cp2: { x: e.x + tEnd.x * alpha2, y: e.y + tEnd.y * alpha2 },
|
|
1124
|
-
end: e
|
|
1132
|
+
end: e,
|
|
1133
|
+
ts
|
|
1125
1134
|
};
|
|
1126
1135
|
}
|
|
1127
1136
|
function reparameterize(samples, ts, a, e, fit) {
|
|
@@ -1273,7 +1282,8 @@ function flatSubpaths(path, tolerance) {
|
|
|
1273
1282
|
const closed = [];
|
|
1274
1283
|
const open = [];
|
|
1275
1284
|
let sub3 = [];
|
|
1276
|
-
forEachSegment(commands, coords, (cmd, ci, curX, curY) => {
|
|
1285
|
+
forEachSegment(commands, coords, (cmd, ci, curX, curY, _i, opensSubpath) => {
|
|
1286
|
+
if (opensSubpath) sub3 = [curX, curY];
|
|
1277
1287
|
switch (cmd) {
|
|
1278
1288
|
case PATH_M:
|
|
1279
1289
|
if (sub3.length >= 2) open.push(sub3);
|
|
@@ -1349,6 +1359,7 @@ function strokeHitTest(path, x, y, threshold, opts = {}) {
|
|
|
1349
1359
|
const [a, b, c, d] = slop.transform;
|
|
1350
1360
|
const m = { a, b, c, d };
|
|
1351
1361
|
const st = stretchOf(m);
|
|
1362
|
+
if (st.s1 === 0) return false;
|
|
1352
1363
|
if (isSimilarity(st)) {
|
|
1353
1364
|
return strokeHitTest(path, x, y, threshold + slop.px / st.s1, { tolerance: opts.tolerance });
|
|
1354
1365
|
}
|
|
@@ -1764,6 +1775,7 @@ function cubicBezierEasing(x1, y1, x2, y2) {
|
|
|
1764
1775
|
};
|
|
1765
1776
|
}
|
|
1766
1777
|
var bezierCache = /* @__PURE__ */ new Map();
|
|
1778
|
+
var BEZIER_CACHE_LIMIT = 256;
|
|
1767
1779
|
function isBezier(spec) {
|
|
1768
1780
|
return typeof spec === "object" && spec !== null && "bezier" in spec;
|
|
1769
1781
|
}
|
|
@@ -1781,6 +1793,7 @@ function resolveEasing(spec) {
|
|
|
1781
1793
|
let fn = bezierCache.get(key);
|
|
1782
1794
|
if (!fn) {
|
|
1783
1795
|
fn = cubicBezierEasing(x1, y1, x2, y2);
|
|
1796
|
+
if (bezierCache.size >= BEZIER_CACHE_LIMIT) bezierCache.delete(bezierCache.keys().next().value);
|
|
1784
1797
|
bezierCache.set(key, fn);
|
|
1785
1798
|
}
|
|
1786
1799
|
return fn;
|
|
@@ -1788,6 +1801,6 @@ function resolveEasing(spec) {
|
|
|
1788
1801
|
throw new Error("resolveEasing: unrecognized easing spec");
|
|
1789
1802
|
}
|
|
1790
1803
|
|
|
1791
|
-
export { EASINGS, PathBuilder, SPRING_PRESETS, applyToPoint, boundsOfPath, boxToBox, clampRectWithin, composePath, cubicBezierEasing, decomposePath, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, ellipsePath, identity, invert, linePath, linear, multiply, nearestOnCubic, nearestOnLine, nearestOnPath, nearestOnQuadratic, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathFromD, pathIntersectsPolygon, pathIntersectsRect, pathSignedArea, placeRect, pointAlongPath, pointInPath, polygonContainsPath, polygonFromPoints, polygonIntersectsPath, polylineFromPoints, portControls2 as portControls, portCurvePoints2 as portCurvePoints, rectPath, regularPolygonPath, resolveEasing, reversePath, rotate, rotateAboutPoint, scale, scalePathToBounds, schneiderFit, splitSubpaths, starPath, strokeHitTest, transformCoords, transformPath, translate, translatePath, unionBoundsPath };
|
|
1804
|
+
export { EASINGS, PathBuilder, SPRING_PRESETS, ZOOM_FLOOR, applyToPoint, boundsOfPath, boxToBox, clampRectWithin, composePath, cubicBezierEasing, decomposePath, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, ellipsePath, identity, invert, linePath, linear, multiply, nearestOnCubic, nearestOnLine, nearestOnPath, nearestOnQuadratic, normalizeZoom, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathFromD, pathIntersectsPolygon, pathIntersectsRect, pathSignedArea, placeRect, pointAlongPath, pointInPath, polygonContainsPath, polygonFromPoints, polygonIntersectsPath, polylineFromPoints, portControls2 as portControls, portCurvePoints2 as portCurvePoints, rectPath, regularPolygonPath, resolveEasing, reversePath, rotate, rotateAboutPoint, scale, scalePathToBounds, schneiderFit, splitSubpaths, starPath, strokeHitTest, transformCoords, transformPath, translate, translatePath, unionBoundsPath };
|
|
1792
1805
|
//# sourceMappingURL=index.js.map
|
|
1793
1806
|
//# sourceMappingURL=index.js.map
|