@weasel-js/geom 1.11.1 → 1.12.0
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/booleans/index.js +2 -2
- package/dist/{chunk-EAKE3N7W.js → chunk-2PKPKU4P.js} +178 -178
- package/dist/chunk-2PKPKU4P.js.map +1 -0
- package/dist/{chunk-6FGQML7D.js → chunk-STGSBIOL.js} +3 -3
- package/dist/{chunk-6FGQML7D.js.map → chunk-STGSBIOL.js.map} +1 -1
- package/dist/{chunk-LRVPK7HI.js → chunk-UGE57OTX.js} +3 -3
- package/dist/{chunk-LRVPK7HI.js.map → chunk-UGE57OTX.js.map} +1 -1
- package/dist/{chunk-7F66PQCJ.js → chunk-VHXOCDZ2.js} +3 -3
- package/dist/{chunk-7F66PQCJ.js.map → chunk-VHXOCDZ2.js.map} +1 -1
- package/dist/{chunk-4Y67BZL5.js → chunk-YPWFGFQX.js} +3 -3
- package/dist/{chunk-4Y67BZL5.js.map → chunk-YPWFGFQX.js.map} +1 -1
- package/dist/index.d.ts +231 -56
- package/dist/index.js +531 -172
- package/dist/index.js.map +1 -1
- package/dist/tessellate/index.js +3 -3
- package/dist/warp/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-EAKE3N7W.js.map +0 -1
package/dist/booleans/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { orientBoundaries, parseContours, contoursIntersect, assembleRegions, signedArea, negligibleArea, regionArea, toPath, parseSubpaths, writePath, signChanges, sideCoeffs, evalSeg, extentOf, keepCorners, windingAt, reverseContour, sampleContour, subSeg, endSide } from '../chunk-
|
|
1
|
+
import { orientBoundaries, parseContours, contoursIntersect, assembleRegions, signedArea, negligibleArea, regionArea, toPath, parseSubpaths, writePath, signChanges, sideCoeffs, evalSeg, extentOf, keepCorners, windingAt, reverseContour, sampleContour, subSeg, endSide } from '../chunk-YPWFGFQX.js';
|
|
2
2
|
import '../chunk-CE7IY7TB.js';
|
|
3
|
-
import { resolveCorners, DEFAULT_FLATTEN_TOLERANCE, fillsOpenSubpaths, flattenCubic, flattenQuadratic, pointInPolygon } from '../chunk-
|
|
3
|
+
import { resolveCorners, DEFAULT_FLATTEN_TOLERANCE, fillsOpenSubpaths, flattenCubic, flattenQuadratic, pointInPolygon } from '../chunk-2PKPKU4P.js';
|
|
4
4
|
import '../chunk-755Y4YZS.js';
|
|
5
5
|
import { PATH_Z, PATH_Q, elevateQuadraticToCubic, PATH_C, PATH_L, PATH_M } from '../chunk-B53BERKG.js';
|
|
6
6
|
import polygonClipping from 'polygon-clipping';
|
|
@@ -1,182 +1,6 @@
|
|
|
1
1
|
import { sign, len2, dot } from './chunk-755Y4YZS.js';
|
|
2
2
|
import { PathBuilder, cubicPointAt, forEachSegment, PATH_Z, PATH_Q, PATH_C, PATH_L, PATH_M, hasCorners, withoutCorners, cornerAt, cubicEvalAt, splitCubicAt } from './chunk-B53BERKG.js';
|
|
3
3
|
|
|
4
|
-
// src/flatten.ts
|
|
5
|
-
var DEFAULT_FLATTEN_TOLERANCE = 0.5;
|
|
6
|
-
var MIN_FLATTEN_TOLERANCE = 1e-6;
|
|
7
|
-
var MAX_FLATTEN_DEPTH = 16;
|
|
8
|
-
function usableTolerance(tolerance) {
|
|
9
|
-
return tolerance > 0 ? tolerance : MIN_FLATTEN_TOLERANCE;
|
|
10
|
-
}
|
|
11
|
-
function finite6(a, b, c, d, e, f) {
|
|
12
|
-
return Number.isFinite(a) && Number.isFinite(b) && Number.isFinite(c) && Number.isFinite(d) && Number.isFinite(e) && Number.isFinite(f);
|
|
13
|
-
}
|
|
14
|
-
function finite8(a, b, c, d, e, f, g, h) {
|
|
15
|
-
return finite6(a, b, c, d, e, f) && Number.isFinite(g) && Number.isFinite(h);
|
|
16
|
-
}
|
|
17
|
-
function distPointToSegment(px, py, ax, ay, bx, by) {
|
|
18
|
-
const dx = bx - ax;
|
|
19
|
-
const dy = by - ay;
|
|
20
|
-
const len22 = dx * dx + dy * dy;
|
|
21
|
-
const along = len22 === 0 ? 0 : ((px - ax) * dx + (py - ay) * dy) / len22;
|
|
22
|
-
if (along <= 0) return Math.hypot(px - ax, py - ay);
|
|
23
|
-
if (along >= 1) return Math.hypot(px - bx, py - by);
|
|
24
|
-
return Math.abs((px - ax) * dy - (py - ay) * dx) / Math.sqrt(len22);
|
|
25
|
-
}
|
|
26
|
-
function turnsWithin(x0, y0, x1, y1, x2, y2, x3, y3, maxTurn) {
|
|
27
|
-
let turn = legTurn(x1 - x0, y1 - y0, x2 - x1, y2 - y1);
|
|
28
|
-
if (turn > maxTurn) return false;
|
|
29
|
-
turn += legTurn(x2 - x1, y2 - y1, x3 - x2, y3 - y2);
|
|
30
|
-
if (x2 === x1 && y2 === y1) turn += legTurn(x1 - x0, y1 - y0, x3 - x2, y3 - y2);
|
|
31
|
-
return turn <= maxTurn;
|
|
32
|
-
}
|
|
33
|
-
function legTurn(ax, ay, bx, by) {
|
|
34
|
-
const lens = Math.sqrt((ax * ax + ay * ay) * (bx * bx + by * by));
|
|
35
|
-
if (lens === 0) return 0;
|
|
36
|
-
return Math.acos(Math.max(-1, Math.min(1, (ax * bx + ay * by) / lens)));
|
|
37
|
-
}
|
|
38
|
-
function flattenCubic(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out) {
|
|
39
|
-
if (!finite8(x0, y0, x1, y1, x2, y2, x3, y3)) {
|
|
40
|
-
out.push(x3, y3);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
flattenCubicRec(x0, y0, x1, y1, x2, y2, x3, y3, usableTolerance(tolerance), out, 0);
|
|
44
|
-
}
|
|
45
|
-
function flattenCubicRec(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out, depth) {
|
|
46
|
-
const d1 = distPointToSegment(x1, y1, x0, y0, x3, y3);
|
|
47
|
-
const d2 = distPointToSegment(x2, y2, x0, y0, x3, y3);
|
|
48
|
-
if (Math.max(d1, d2) <= tolerance || depth >= MAX_FLATTEN_DEPTH) {
|
|
49
|
-
out.push(x3, y3);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
|
|
53
|
-
const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
|
|
54
|
-
const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;
|
|
55
|
-
const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
|
|
56
|
-
const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;
|
|
57
|
-
const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;
|
|
58
|
-
flattenCubicRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, out, depth + 1);
|
|
59
|
-
flattenCubicRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, out, depth + 1);
|
|
60
|
-
}
|
|
61
|
-
function flattenQuadratic(x0, y0, x1, y1, x2, y2, tolerance, out) {
|
|
62
|
-
if (!finite6(x0, y0, x1, y1, x2, y2)) {
|
|
63
|
-
out.push(x2, y2);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
flattenQuadraticRec(x0, y0, x1, y1, x2, y2, usableTolerance(tolerance), out, 0);
|
|
67
|
-
}
|
|
68
|
-
function flattenQuadraticRec(x0, y0, x1, y1, x2, y2, tolerance, out, depth) {
|
|
69
|
-
const d = distPointToSegment(x1, y1, x0, y0, x2, y2);
|
|
70
|
-
if (d <= tolerance || depth >= MAX_FLATTEN_DEPTH) {
|
|
71
|
-
out.push(x2, y2);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
|
|
75
|
-
const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
|
|
76
|
-
const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
|
|
77
|
-
flattenQuadraticRec(x0, y0, x01, y01, x012, y012, tolerance, out, depth + 1);
|
|
78
|
-
flattenQuadraticRec(x012, y012, x12, y12, x2, y2, tolerance, out, depth + 1);
|
|
79
|
-
}
|
|
80
|
-
function flattenCubicWithArcLen(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out, arcOut, maxTurn = Infinity) {
|
|
81
|
-
if (!finite8(x0, y0, x1, y1, x2, y2, x3, y3)) {
|
|
82
|
-
out.push(x3, y3);
|
|
83
|
-
arcOut.push(0);
|
|
84
|
-
return 0;
|
|
85
|
-
}
|
|
86
|
-
return flattenCubicArcRec(x0, y0, x1, y1, x2, y2, x3, y3, usableTolerance(tolerance), maxTurn, out, arcOut, 0, 0);
|
|
87
|
-
}
|
|
88
|
-
function flattenCubicArcRec(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, maxTurn, out, arcOut, accum, depth) {
|
|
89
|
-
const d1 = distPointToSegment(x1, y1, x0, y0, x3, y3);
|
|
90
|
-
const d2 = distPointToSegment(x2, y2, x0, y0, x3, y3);
|
|
91
|
-
const flat = Math.max(d1, d2) <= tolerance && (maxTurn === Infinity || turnsWithin(x0, y0, x1, y1, x2, y2, x3, y3, maxTurn));
|
|
92
|
-
if (flat || depth >= MAX_FLATTEN_DEPTH) {
|
|
93
|
-
const lastX = out.length >= 2 ? out[out.length - 2] : x0;
|
|
94
|
-
const lastY = out.length >= 2 ? out[out.length - 1] : y0;
|
|
95
|
-
const seg = Math.hypot(x3 - lastX, y3 - lastY);
|
|
96
|
-
accum += seg;
|
|
97
|
-
out.push(x3, y3);
|
|
98
|
-
arcOut.push(accum);
|
|
99
|
-
return accum;
|
|
100
|
-
}
|
|
101
|
-
const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
|
|
102
|
-
const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
|
|
103
|
-
const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;
|
|
104
|
-
const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
|
|
105
|
-
const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;
|
|
106
|
-
const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;
|
|
107
|
-
accum = flattenCubicArcRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, maxTurn, out, arcOut, accum, depth + 1);
|
|
108
|
-
accum = flattenCubicArcRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, maxTurn, out, arcOut, accum, depth + 1);
|
|
109
|
-
return accum;
|
|
110
|
-
}
|
|
111
|
-
function flattenQuadraticWithArcLen(x0, y0, x1, y1, x2, y2, tolerance, out, arcOut, maxTurn = Infinity) {
|
|
112
|
-
if (!finite6(x0, y0, x1, y1, x2, y2)) {
|
|
113
|
-
out.push(x2, y2);
|
|
114
|
-
arcOut.push(0);
|
|
115
|
-
return 0;
|
|
116
|
-
}
|
|
117
|
-
return flattenQuadraticArcRec(x0, y0, x1, y1, x2, y2, usableTolerance(tolerance), maxTurn, out, arcOut, 0, 0);
|
|
118
|
-
}
|
|
119
|
-
function flattenQuadraticArcRec(x0, y0, x1, y1, x2, y2, tolerance, maxTurn, out, arcOut, accum, depth) {
|
|
120
|
-
const d = distPointToSegment(x1, y1, x0, y0, x2, y2);
|
|
121
|
-
const flat = d <= tolerance && (maxTurn === Infinity || turnsWithin(x0, y0, x1, y1, x2, y2, x2, y2, maxTurn));
|
|
122
|
-
if (flat || depth >= MAX_FLATTEN_DEPTH) {
|
|
123
|
-
const lastX = out.length >= 2 ? out[out.length - 2] : x0;
|
|
124
|
-
const lastY = out.length >= 2 ? out[out.length - 1] : y0;
|
|
125
|
-
const seg = Math.hypot(x2 - lastX, y2 - lastY);
|
|
126
|
-
accum += seg;
|
|
127
|
-
out.push(x2, y2);
|
|
128
|
-
arcOut.push(accum);
|
|
129
|
-
return accum;
|
|
130
|
-
}
|
|
131
|
-
const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
|
|
132
|
-
const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
|
|
133
|
-
const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
|
|
134
|
-
accum = flattenQuadraticArcRec(x0, y0, x01, y01, x012, y012, tolerance, maxTurn, out, arcOut, accum, depth + 1);
|
|
135
|
-
accum = flattenQuadraticArcRec(x012, y012, x12, y12, x2, y2, tolerance, maxTurn, out, arcOut, accum, depth + 1);
|
|
136
|
-
return accum;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/polyline.ts
|
|
140
|
-
function pointInPolygon(coords, px, py, start = 0, end = coords.length >> 1) {
|
|
141
|
-
if (end - start < 3) return false;
|
|
142
|
-
let inside = false;
|
|
143
|
-
for (let i = start, j = end - 1; i < end; j = i++) {
|
|
144
|
-
const xi = coords[i * 2], yi = coords[i * 2 + 1];
|
|
145
|
-
const xj = coords[j * 2], yj = coords[j * 2 + 1];
|
|
146
|
-
const crosses = yi > py !== yj > py && px < (xj - xi) * (py - yi) / (yj - yi) + xi;
|
|
147
|
-
if (crosses) inside = !inside;
|
|
148
|
-
}
|
|
149
|
-
return inside;
|
|
150
|
-
}
|
|
151
|
-
function segmentsCross(ax, ay, bx, by, cx, cy, dx, dy) {
|
|
152
|
-
const d1 = sign((dx - cx) * (ay - cy) - (dy - cy) * (ax - cx));
|
|
153
|
-
const d2 = sign((dx - cx) * (by - cy) - (dy - cy) * (bx - cx));
|
|
154
|
-
const d3 = sign((bx - ax) * (cy - ay) - (by - ay) * (cx - ax));
|
|
155
|
-
const d4 = sign((bx - ax) * (dy - ay) - (by - ay) * (dx - ax));
|
|
156
|
-
return d1 !== d2 && d3 !== d4;
|
|
157
|
-
}
|
|
158
|
-
function pointSegmentDist2(px, py, ax, ay, bx, by) {
|
|
159
|
-
const vx = bx - ax, vy = by - ay;
|
|
160
|
-
const wx = px - ax, wy = py - ay;
|
|
161
|
-
const vv = len2(vx, vy);
|
|
162
|
-
let t = vv === 0 ? 0 : dot(wx, wy, vx, vy) / vv;
|
|
163
|
-
t = t < 0 ? 0 : t > 1 ? 1 : t;
|
|
164
|
-
const dx = px - (ax + t * vx), dy = py - (ay + t * vy);
|
|
165
|
-
return len2(dx, dy);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// src/openFill.ts
|
|
169
|
-
var fallback = "close";
|
|
170
|
-
function setDefaultOpenFill(rule) {
|
|
171
|
-
fallback = rule;
|
|
172
|
-
}
|
|
173
|
-
function defaultOpenFill() {
|
|
174
|
-
return fallback;
|
|
175
|
-
}
|
|
176
|
-
function fillsOpenSubpaths(path) {
|
|
177
|
-
return (path.openFill ?? fallback) === "close";
|
|
178
|
-
}
|
|
179
|
-
|
|
180
4
|
// src/paths/schneiderFit.ts
|
|
181
5
|
function schneiderFit(samples, errorTolerance) {
|
|
182
6
|
if (samples.length === 0) {
|
|
@@ -799,6 +623,182 @@ function tangentMeet(a, ta, b, tb) {
|
|
|
799
623
|
return { x: a.x + ta.x * s, y: a.y + ta.y * s };
|
|
800
624
|
}
|
|
801
625
|
|
|
626
|
+
// src/flatten.ts
|
|
627
|
+
var DEFAULT_FLATTEN_TOLERANCE = 0.5;
|
|
628
|
+
var MIN_FLATTEN_TOLERANCE = 1e-6;
|
|
629
|
+
var MAX_FLATTEN_DEPTH = 16;
|
|
630
|
+
function usableTolerance(tolerance) {
|
|
631
|
+
return tolerance > 0 ? tolerance : MIN_FLATTEN_TOLERANCE;
|
|
632
|
+
}
|
|
633
|
+
function finite6(a, b, c, d, e, f) {
|
|
634
|
+
return Number.isFinite(a) && Number.isFinite(b) && Number.isFinite(c) && Number.isFinite(d) && Number.isFinite(e) && Number.isFinite(f);
|
|
635
|
+
}
|
|
636
|
+
function finite8(a, b, c, d, e, f, g, h) {
|
|
637
|
+
return finite6(a, b, c, d, e, f) && Number.isFinite(g) && Number.isFinite(h);
|
|
638
|
+
}
|
|
639
|
+
function distPointToSegment(px, py, ax, ay, bx, by) {
|
|
640
|
+
const dx = bx - ax;
|
|
641
|
+
const dy = by - ay;
|
|
642
|
+
const len22 = dx * dx + dy * dy;
|
|
643
|
+
const along = len22 === 0 ? 0 : ((px - ax) * dx + (py - ay) * dy) / len22;
|
|
644
|
+
if (along <= 0) return Math.hypot(px - ax, py - ay);
|
|
645
|
+
if (along >= 1) return Math.hypot(px - bx, py - by);
|
|
646
|
+
return Math.abs((px - ax) * dy - (py - ay) * dx) / Math.sqrt(len22);
|
|
647
|
+
}
|
|
648
|
+
function turnsWithin(x0, y0, x1, y1, x2, y2, x3, y3, maxTurn) {
|
|
649
|
+
let turn = legTurn(x1 - x0, y1 - y0, x2 - x1, y2 - y1);
|
|
650
|
+
if (turn > maxTurn) return false;
|
|
651
|
+
turn += legTurn(x2 - x1, y2 - y1, x3 - x2, y3 - y2);
|
|
652
|
+
if (x2 === x1 && y2 === y1) turn += legTurn(x1 - x0, y1 - y0, x3 - x2, y3 - y2);
|
|
653
|
+
return turn <= maxTurn;
|
|
654
|
+
}
|
|
655
|
+
function legTurn(ax, ay, bx, by) {
|
|
656
|
+
const lens = Math.sqrt((ax * ax + ay * ay) * (bx * bx + by * by));
|
|
657
|
+
if (lens === 0) return 0;
|
|
658
|
+
return Math.acos(Math.max(-1, Math.min(1, (ax * bx + ay * by) / lens)));
|
|
659
|
+
}
|
|
660
|
+
function flattenCubic(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out) {
|
|
661
|
+
if (!finite8(x0, y0, x1, y1, x2, y2, x3, y3)) {
|
|
662
|
+
out.push(x3, y3);
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
flattenCubicRec(x0, y0, x1, y1, x2, y2, x3, y3, usableTolerance(tolerance), out, 0);
|
|
666
|
+
}
|
|
667
|
+
function flattenCubicRec(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out, depth) {
|
|
668
|
+
const d1 = distPointToSegment(x1, y1, x0, y0, x3, y3);
|
|
669
|
+
const d2 = distPointToSegment(x2, y2, x0, y0, x3, y3);
|
|
670
|
+
if (Math.max(d1, d2) <= tolerance || depth >= MAX_FLATTEN_DEPTH) {
|
|
671
|
+
out.push(x3, y3);
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
|
|
675
|
+
const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
|
|
676
|
+
const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;
|
|
677
|
+
const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
|
|
678
|
+
const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;
|
|
679
|
+
const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;
|
|
680
|
+
flattenCubicRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, out, depth + 1);
|
|
681
|
+
flattenCubicRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, out, depth + 1);
|
|
682
|
+
}
|
|
683
|
+
function flattenQuadratic(x0, y0, x1, y1, x2, y2, tolerance, out) {
|
|
684
|
+
if (!finite6(x0, y0, x1, y1, x2, y2)) {
|
|
685
|
+
out.push(x2, y2);
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
flattenQuadraticRec(x0, y0, x1, y1, x2, y2, usableTolerance(tolerance), out, 0);
|
|
689
|
+
}
|
|
690
|
+
function flattenQuadraticRec(x0, y0, x1, y1, x2, y2, tolerance, out, depth) {
|
|
691
|
+
const d = distPointToSegment(x1, y1, x0, y0, x2, y2);
|
|
692
|
+
if (d <= tolerance || depth >= MAX_FLATTEN_DEPTH) {
|
|
693
|
+
out.push(x2, y2);
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
|
|
697
|
+
const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
|
|
698
|
+
const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
|
|
699
|
+
flattenQuadraticRec(x0, y0, x01, y01, x012, y012, tolerance, out, depth + 1);
|
|
700
|
+
flattenQuadraticRec(x012, y012, x12, y12, x2, y2, tolerance, out, depth + 1);
|
|
701
|
+
}
|
|
702
|
+
function flattenCubicWithArcLen(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out, arcOut, maxTurn = Infinity) {
|
|
703
|
+
if (!finite8(x0, y0, x1, y1, x2, y2, x3, y3)) {
|
|
704
|
+
out.push(x3, y3);
|
|
705
|
+
arcOut.push(0);
|
|
706
|
+
return 0;
|
|
707
|
+
}
|
|
708
|
+
return flattenCubicArcRec(x0, y0, x1, y1, x2, y2, x3, y3, usableTolerance(tolerance), maxTurn, out, arcOut, 0, 0);
|
|
709
|
+
}
|
|
710
|
+
function flattenCubicArcRec(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, maxTurn, out, arcOut, accum, depth) {
|
|
711
|
+
const d1 = distPointToSegment(x1, y1, x0, y0, x3, y3);
|
|
712
|
+
const d2 = distPointToSegment(x2, y2, x0, y0, x3, y3);
|
|
713
|
+
const flat = Math.max(d1, d2) <= tolerance && (maxTurn === Infinity || turnsWithin(x0, y0, x1, y1, x2, y2, x3, y3, maxTurn));
|
|
714
|
+
if (flat || depth >= MAX_FLATTEN_DEPTH) {
|
|
715
|
+
const lastX = out.length >= 2 ? out[out.length - 2] : x0;
|
|
716
|
+
const lastY = out.length >= 2 ? out[out.length - 1] : y0;
|
|
717
|
+
const seg = Math.hypot(x3 - lastX, y3 - lastY);
|
|
718
|
+
accum += seg;
|
|
719
|
+
out.push(x3, y3);
|
|
720
|
+
arcOut.push(accum);
|
|
721
|
+
return accum;
|
|
722
|
+
}
|
|
723
|
+
const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
|
|
724
|
+
const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
|
|
725
|
+
const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;
|
|
726
|
+
const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
|
|
727
|
+
const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;
|
|
728
|
+
const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;
|
|
729
|
+
accum = flattenCubicArcRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, maxTurn, out, arcOut, accum, depth + 1);
|
|
730
|
+
accum = flattenCubicArcRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, maxTurn, out, arcOut, accum, depth + 1);
|
|
731
|
+
return accum;
|
|
732
|
+
}
|
|
733
|
+
function flattenQuadraticWithArcLen(x0, y0, x1, y1, x2, y2, tolerance, out, arcOut, maxTurn = Infinity) {
|
|
734
|
+
if (!finite6(x0, y0, x1, y1, x2, y2)) {
|
|
735
|
+
out.push(x2, y2);
|
|
736
|
+
arcOut.push(0);
|
|
737
|
+
return 0;
|
|
738
|
+
}
|
|
739
|
+
return flattenQuadraticArcRec(x0, y0, x1, y1, x2, y2, usableTolerance(tolerance), maxTurn, out, arcOut, 0, 0);
|
|
740
|
+
}
|
|
741
|
+
function flattenQuadraticArcRec(x0, y0, x1, y1, x2, y2, tolerance, maxTurn, out, arcOut, accum, depth) {
|
|
742
|
+
const d = distPointToSegment(x1, y1, x0, y0, x2, y2);
|
|
743
|
+
const flat = d <= tolerance && (maxTurn === Infinity || turnsWithin(x0, y0, x1, y1, x2, y2, x2, y2, maxTurn));
|
|
744
|
+
if (flat || depth >= MAX_FLATTEN_DEPTH) {
|
|
745
|
+
const lastX = out.length >= 2 ? out[out.length - 2] : x0;
|
|
746
|
+
const lastY = out.length >= 2 ? out[out.length - 1] : y0;
|
|
747
|
+
const seg = Math.hypot(x2 - lastX, y2 - lastY);
|
|
748
|
+
accum += seg;
|
|
749
|
+
out.push(x2, y2);
|
|
750
|
+
arcOut.push(accum);
|
|
751
|
+
return accum;
|
|
752
|
+
}
|
|
753
|
+
const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
|
|
754
|
+
const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
|
|
755
|
+
const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
|
|
756
|
+
accum = flattenQuadraticArcRec(x0, y0, x01, y01, x012, y012, tolerance, maxTurn, out, arcOut, accum, depth + 1);
|
|
757
|
+
accum = flattenQuadraticArcRec(x012, y012, x12, y12, x2, y2, tolerance, maxTurn, out, arcOut, accum, depth + 1);
|
|
758
|
+
return accum;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// src/polyline.ts
|
|
762
|
+
function pointInPolygon(coords, px, py, start = 0, end = coords.length >> 1) {
|
|
763
|
+
if (end - start < 3) return false;
|
|
764
|
+
let inside = false;
|
|
765
|
+
for (let i = start, j = end - 1; i < end; j = i++) {
|
|
766
|
+
const xi = coords[i * 2], yi = coords[i * 2 + 1];
|
|
767
|
+
const xj = coords[j * 2], yj = coords[j * 2 + 1];
|
|
768
|
+
const crosses = yi > py !== yj > py && px < (xj - xi) * (py - yi) / (yj - yi) + xi;
|
|
769
|
+
if (crosses) inside = !inside;
|
|
770
|
+
}
|
|
771
|
+
return inside;
|
|
772
|
+
}
|
|
773
|
+
function segmentsCross(ax, ay, bx, by, cx, cy, dx, dy) {
|
|
774
|
+
const d1 = sign((dx - cx) * (ay - cy) - (dy - cy) * (ax - cx));
|
|
775
|
+
const d2 = sign((dx - cx) * (by - cy) - (dy - cy) * (bx - cx));
|
|
776
|
+
const d3 = sign((bx - ax) * (cy - ay) - (by - ay) * (cx - ax));
|
|
777
|
+
const d4 = sign((bx - ax) * (dy - ay) - (by - ay) * (dx - ax));
|
|
778
|
+
return d1 !== d2 && d3 !== d4;
|
|
779
|
+
}
|
|
780
|
+
function pointSegmentDist2(px, py, ax, ay, bx, by) {
|
|
781
|
+
const vx = bx - ax, vy = by - ay;
|
|
782
|
+
const wx = px - ax, wy = py - ay;
|
|
783
|
+
const vv = len2(vx, vy);
|
|
784
|
+
let t = vv === 0 ? 0 : dot(wx, wy, vx, vy) / vv;
|
|
785
|
+
t = t < 0 ? 0 : t > 1 ? 1 : t;
|
|
786
|
+
const dx = px - (ax + t * vx), dy = py - (ay + t * vy);
|
|
787
|
+
return len2(dx, dy);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// src/openFill.ts
|
|
791
|
+
var fallback = "close";
|
|
792
|
+
function setDefaultOpenFill(rule) {
|
|
793
|
+
fallback = rule;
|
|
794
|
+
}
|
|
795
|
+
function defaultOpenFill() {
|
|
796
|
+
return fallback;
|
|
797
|
+
}
|
|
798
|
+
function fillsOpenSubpaths(path) {
|
|
799
|
+
return (path.openFill ?? fallback) === "close";
|
|
800
|
+
}
|
|
801
|
+
|
|
802
802
|
export { CORNER_FIT_TOLERANCE, CORNER_KEYWORDS, DEFAULT_FLATTEN_TOLERANCE, cornerCenter, cornerCuts, cornerFrameAt, cornerFrames, cornerKeywordOf, cornerShapeK, cornerShapePieces, cornerShapePoint, decodeContours, defaultOpenFill, fillsOpenSubpaths, fitCubicWithTangents, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, isCornerShape, nextCornerShape, pointInPolygon, pointSegmentDist2, remapPerAnchor, resolveCorners, resolveCornersWithSources, schneiderFit, segmentsCross, setDefaultOpenFill };
|
|
803
|
-
//# sourceMappingURL=chunk-
|
|
804
|
-
//# sourceMappingURL=chunk-
|
|
803
|
+
//# sourceMappingURL=chunk-2PKPKU4P.js.map
|
|
804
|
+
//# sourceMappingURL=chunk-2PKPKU4P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/paths/schneiderFit.ts","../src/paths/cornerShape.ts","../src/paths/cornerSegments.ts","../src/paths/corners.ts","../src/flatten.ts","../src/polyline.ts","../src/openFill.ts"],"names":["fit","sub","unit","len2"],"mappings":";;;;AAaO,SAAS,YAAA,CACd,SACA,cAAA,EACa;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AAA,GAAA,CAAO,EAAA,GAAK,EAAA,KAAO,EAAA,GAAK,EAAA,CAAG,CAAA;AAC7D,EAAA,OAAO,EAAA,KAAO,MAAM,EAAA,KAAO,EAAA;AAC7B;AAGO,SAAS,kBACd,EAAA,EAAY,EAAA,EAAY,EAAA,EAAY,EAAA,EAAY,IAAY,EAAA,EACpD;AACR,EAAA,MAAM,EAAA,GAAK,EAAA,GAAK,EAAA,EAAI,EAAA,GAAK,EAAA,GAAK,EAAA;AAC9B,EAAA,MAAM,EAAA,GAAK,EAAA,GAAK,EAAA,EAAI,EAAA,GAAK,EAAA,GAAK,EAAA;AAC9B,EAAA,MAAM,EAAA,GAAK,IAAA,CAAK,EAAA,EAAI,EAAE,CAAA;AACtB,EAAA,IAAI,CAAA,GAAI,OAAO,CAAA,GAAI,CAAA,GAAI,IAAI,EAAA,EAAI,EAAA,EAAI,EAAA,EAAI,EAAE,CAAA,GAAI,EAAA;AAC7C,EAAA,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AAC5B,EAAA,MAAM,EAAA,GAAK,MAAM,EAAA,GAAK,CAAA,GAAI,KAAK,EAAA,GAAK,EAAA,IAAM,KAAK,CAAA,GAAI,EAAA,CAAA;AACnD,EAAA,OAAO,IAAA,CAAK,IAAI,EAAE,CAAA;AACpB;;;ACxDA,IAAI,QAAA,GAAyB,OAAA;AAItB,SAAS,mBAAmB,IAAA,EAA0B;AAC3D,EAAA,QAAA,GAAW,IAAA;AACb;AAGO,SAAS,eAAA,GAAgC;AAC9C,EAAA,OAAO,QAAA;AACT;AAIO,SAAS,kBAAkB,IAAA,EAA4B;AAC5D,EAAA,OAAA,CAAQ,IAAA,CAAK,YAAY,QAAA,MAAc,OAAA;AACzC","file":"chunk-2PKPKU4P.js","sourcesContent":["import { PathBuilder } from './builder';\nimport { cubicPointAt, type Point } from './cubicMath';\nimport type { PolygonPath } from '../path';\n\n/**\n * Schneider (1990, Graphics Gems I) adaptive cubic-Bezier fitter.\n * Given a sequence of sample points, returns a `PolygonPath` whose `C`\n * segments approximate the samples within `errorTolerance` world units.\n *\n * Output shape: an initial `M` to the first sample, followed by N\n * `C` cubic segments. For colinear / two-point inputs, returns a single\n * degenerate cubic. For empty input, returns an empty polygon path.\n */\nexport function schneiderFit(\n samples: ReadonlyArray<Point>,\n errorTolerance: number,\n): PolygonPath {\n if (samples.length === 0) {\n return {\n kind: 'polygon',\n commands: new Uint8Array(),\n coords: new Float32Array(),\n fillRule: 'nonzero',\n };\n }\n\n const b = new PathBuilder();\n b.moveTo(samples[0].x, samples[0].y);\n\n if (samples.length === 1) {\n return b.build();\n }\n\n if (samples.length === 2) {\n emitStraightCubic(b, samples[0], samples[1]);\n return b.build();\n }\n\n fitRecursive(samples, errorTolerance, b);\n return b.build();\n}\n\nfunction fitRecursive(\n samples: ReadonlyArray<Point>,\n errorTolerance: number,\n b: PathBuilder,\n): void {\n if (samples.length === 2) {\n const fit = fitOneCubic(samples);\n b.curveTo(fit.cp1.x, fit.cp1.y, fit.cp2.x, fit.cp2.y, fit.end.x, fit.end.y);\n return;\n }\n const fit = fitOneCubic(samples);\n const { worstIndex, worstError } = measureError(samples, fit);\n if (worstError <= errorTolerance * errorTolerance) {\n b.curveTo(fit.cp1.x, fit.cp1.y, fit.cp2.x, fit.cp2.y, fit.end.x, fit.end.y);\n return;\n }\n // Split. Both halves include the split sample so endpoints meet.\n const left = samples.slice(0, worstIndex + 1);\n const right = samples.slice(worstIndex);\n fitRecursive(left, errorTolerance, b);\n fitRecursive(right, errorTolerance, b);\n}\n\nfunction measureError(\n samples: ReadonlyArray<Point>,\n fit: CubicFit,\n): { worstIndex: number; worstError: number } {\n let worstIndex = 1;\n let worstError = 0;\n const a = samples[0];\n for (let i = 1; i < samples.length - 1; i++) {\n const q = cubicPointAt(a, fit.cp1, fit.cp2, fit.end, fit.ts[i]);\n const dx = samples[i].x - q.x;\n const dy = samples[i].y - q.y;\n const sq = dx * dx + dy * dy;\n if (sq > worstError) {\n worstError = sq;\n worstIndex = i;\n }\n }\n return { worstIndex, worstError };\n}\n\ninterface CubicFit {\n cp1: Point;\n cp2: Point;\n end: Point;\n /** The curve parameter each sample was fitted at: where its error is measured. */\n ts: ReadonlyArray<number>;\n}\n\nfunction fitOneCubic(samples: ReadonlyArray<Point>): CubicFit {\n const n = samples.length;\n return fitWithTangents(\n samples,\n unit(sub(samples[1], samples[0])),\n unit(sub(samples[n - 2], samples[n - 1])),\n 4,\n );\n}\n\n/**\n * The single cubic from the first sample to the last that best fits the\n * samples between, with its control points held to the given unit tangents:\n * `tStart` leaving the first sample, `tEnd` leaving the last one backward.\n * Only the two handle lengths are solved for.\n *\n * `params` is the curve parameter each sample starts at, chord length when\n * omitted; `passes` is how many times those are refined and the lengths\n * solved again.\n */\nexport function fitCubicWithTangents(\n samples: ReadonlyArray<Point>,\n tStart: Point,\n tEnd: Point,\n opts: { params?: ReadonlyArray<number>; passes?: number } = {},\n): { cp1: Point; cp2: Point } {\n const { cp1, cp2 } = fitWithTangents(samples, tStart, tEnd, opts.passes ?? 4, opts.params);\n return { cp1, cp2 };\n}\n\nfunction fitWithTangents(\n samples: ReadonlyArray<Point>,\n tStart: Point,\n tEnd: Point,\n passes: number,\n params?: ReadonlyArray<number>,\n): CubicFit {\n const n = samples.length;\n const a = samples[0];\n const e = samples[n - 1];\n const ts = params ? [...params] : chordLengthParam(samples);\n if (ts === null) return { cp1: { ...a }, cp2: { ...e }, end: e, ts: samples.map(() => 0) };\n\n let fit = solveLS(samples, ts, a, e, tStart, tEnd);\n for (let pass = 0; pass < passes; pass++) {\n reparameterize(samples, ts, a, e, fit);\n fit = solveLS(samples, ts, a, e, tStart, tEnd);\n }\n return fit;\n}\n\nfunction chordLengthParam(samples: ReadonlyArray<Point>): number[] | null {\n const n = samples.length;\n const ts = new Array<number>(n);\n ts[0] = 0;\n let total = 0;\n for (let i = 1; i < n; i++) {\n total += dist(samples[i - 1], samples[i]);\n ts[i] = total;\n }\n if (total === 0) return null;\n for (let i = 0; i < n; i++) ts[i] /= total;\n return ts;\n}\n\nfunction solveLS(\n samples: ReadonlyArray<Point>,\n ts: ReadonlyArray<number>,\n a: Point,\n e: Point,\n tStart: Point,\n tEnd: Point,\n): CubicFit {\n const n = samples.length;\n let c11 = 0, c12 = 0, c22 = 0, x1 = 0, x2 = 0;\n for (let i = 0; i < n; i++) {\n const t = ts[i];\n const u = 1 - t;\n const b0 = u * u * u;\n const b1 = 3 * u * u * t;\n const b2 = 3 * u * t * t;\n const b3 = t * t * t;\n const A1x = b1 * tStart.x;\n const A1y = b1 * tStart.y;\n const A2x = b2 * tEnd.x;\n const A2y = b2 * tEnd.y;\n c11 += A1x * A1x + A1y * A1y;\n c12 += A1x * A2x + A1y * A2y;\n c22 += A2x * A2x + A2y * A2y;\n const targetX = samples[i].x - (b0 + b1) * a.x - (b2 + b3) * e.x;\n const targetY = samples[i].y - (b0 + b1) * a.y - (b2 + b3) * e.y;\n x1 += A1x * targetX + A1y * targetY;\n x2 += A2x * targetX + A2y * targetY;\n }\n const det = c11 * c22 - c12 * c12;\n let alpha1: number;\n let alpha2: number;\n if (Math.abs(det) < 1e-12) {\n const chord = dist(a, e);\n alpha1 = alpha2 = chord / 3;\n } else {\n alpha1 = (c22 * x1 - c12 * x2) / det;\n alpha2 = (c11 * x2 - c12 * x1) / det;\n if (alpha1 < 1e-6 || alpha2 < 1e-6) {\n const chord = dist(a, e);\n alpha1 = alpha2 = chord / 3;\n }\n }\n return {\n cp1: { x: a.x + tStart.x * alpha1, y: a.y + tStart.y * alpha1 },\n cp2: { x: e.x + tEnd.x * alpha2, y: e.y + tEnd.y * alpha2 },\n end: e,\n ts,\n };\n}\n\nfunction reparameterize(\n samples: ReadonlyArray<Point>,\n ts: number[],\n a: Point,\n e: Point,\n fit: CubicFit,\n): void {\n void a; void e;\n for (let i = 1; i < samples.length - 1; i++) {\n ts[i] = newtonRefineT(samples[i], ts[i], samples[0], fit.cp1, fit.cp2, samples[samples.length - 1]);\n }\n}\n\nfunction newtonRefineT(\n p: Point,\n t: number,\n p0: Point,\n p1: Point,\n p2: Point,\n p3: Point,\n): number {\n // Q(t) - p, where Q is the cubic. Newton step uses Q'(t)·(Q(t)-p) and\n // a second-derivative correction.\n const u = 1 - t;\n const { x: qx, y: qy } = cubicPointAt(p0, p1, p2, p3, t);\n const qpx = 3*u*u*(p1.x - p0.x) + 6*u*t*(p2.x - p1.x) + 3*t*t*(p3.x - p2.x);\n const qpy = 3*u*u*(p1.y - p0.y) + 6*u*t*(p2.y - p1.y) + 3*t*t*(p3.y - p2.y);\n const qppx = 6*u*(p2.x - 2*p1.x + p0.x) + 6*t*(p3.x - 2*p2.x + p1.x);\n const qppy = 6*u*(p2.y - 2*p1.y + p0.y) + 6*t*(p3.y - 2*p2.y + p1.y);\n const dx = qx - p.x;\n const dy = qy - p.y;\n const numerator = dx * qpx + dy * qpy;\n const denominator = qpx * qpx + qpy * qpy + dx * qppx + dy * qppy;\n if (Math.abs(denominator) < 1e-12) return t;\n const next = t - numerator / denominator;\n if (next < 0) return 0;\n if (next > 1) return 1;\n return next;\n}\n\nfunction sub(a: Point, b: Point): Point {\n return { x: a.x - b.x, y: a.y - b.y };\n}\nfunction dist(a: Point, b: Point): number {\n return Math.hypot(a.x - b.x, a.y - b.y);\n}\nfunction unit(v: Point): Point {\n const m = Math.hypot(v.x, v.y);\n if (m === 0) return { x: 0, y: 0 };\n return { x: v.x / m, y: v.y / m };\n}\n\nfunction emitStraightCubic(\n b: PathBuilder,\n a: Point,\n c: Point,\n): void {\n // cp1 at 1/3 along chord, cp2 at 2/3 — the canonical straight cubic.\n const cp1x = a.x + (c.x - a.x) / 3;\n const cp1y = a.y + (c.y - a.y) / 3;\n const cp2x = a.x + (2 * (c.x - a.x)) / 3;\n const cp2y = a.y + (2 * (c.y - a.y)) / 3;\n b.curveTo(cp1x, cp1y, cp2x, cp2y, c.x, c.y);\n}\n","/**\n * Corner shapes as the CSS `corner-shape` property defines them: one curve,\n * `superellipse(k)`, whose keywords are points on its parameter. With\n * `n = 2^|k|`, a convex corner (`k > 0`) is the quarter of `|u|^n + |v|^n = 1`\n * spanned from the corner's center (the point across the cut from the outer\n * corner), and a concave one (`k < 0`) is the same curve spanned from the\n * outer corner instead, so `-k` mirrors `k` through the cut. `k = 1` is an\n * ellipse, `0` the straight bevel, and `±∞` the square corner and the notch.\n */\nimport { fitCubicWithTangents } from './schneiderFit';\nimport type { Point } from './cubicMath';\n\n/** The six `corner-shape` keywords, from most convex to most concave. */\nexport type CornerKeyword = 'square' | 'squircle' | 'round' | 'bevel' | 'scoop' | 'notch';\n\n/** A corner's shape: a keyword, or a finite `superellipse()` parameter. */\nexport type CornerShape = CornerKeyword | number;\n\n/** The keywords in the order cycling through them steps. */\nexport const CORNER_KEYWORDS: readonly CornerKeyword[] = ['square', 'squircle', 'round', 'bevel', 'scoop', 'notch'];\n\nconst K_OF: Record<CornerKeyword, number> = {\n square: Infinity, squircle: 2, round: 1, bevel: 0, scoop: -1, notch: -Infinity,\n};\n\n/** The `superellipse()` parameter of `shape`. */\nexport function cornerShapeK(shape: CornerShape): number {\n return typeof shape === 'number' ? shape : K_OF[shape];\n}\n\n/** The keyword whose parameter is exactly `k`, or null. */\nexport function cornerKeywordOf(k: number): CornerKeyword | null {\n return CORNER_KEYWORDS.find((w) => K_OF[w] === k) ?? null;\n}\n\n/** Whether `v` is a keyword or a finite number. */\nexport function isCornerShape(v: unknown): v is CornerShape {\n return (typeof v === 'number' && Number.isFinite(v)) || CORNER_KEYWORDS.includes(v as CornerKeyword);\n}\n\n/** The keyword after `shape` in {@link CORNER_KEYWORDS}, wrapping; from a\n * number, the first keyword less convex than it. */\nexport function nextCornerShape(shape: CornerShape): CornerKeyword {\n if (typeof shape !== 'number') {\n return CORNER_KEYWORDS[(CORNER_KEYWORDS.indexOf(shape) + 1) % CORNER_KEYWORDS.length];\n }\n return CORNER_KEYWORDS.find((w) => K_OF[w] < shape) ?? CORNER_KEYWORDS[0];\n}\n\n/** Largest distance, in units of the corner's setback, the fitted cubics may\n * stray from the true superellipse. */\nexport const CORNER_FIT_TOLERANCE = 1e-3;\n\n/** The cut a corner shape spans: from `start` to `end`, the two points where\n * it leaves the edges, around `outer`, the corner the edges meet at. */\nexport interface CornerShapeFrame {\n start: Point;\n end: Point;\n outer: Point;\n}\n\n/** One piece of a corner's outline, continuing from where the last ended. */\nexport type CornerPiece =\n | { kind: 'line'; to: Point }\n | { kind: 'cubic'; c1: Point; c2: Point; to: Point };\n\n/** Kappa of the cubic quarter circle, the one the kit draws every arc with. */\nconst KAPPA = (4 / 3) * Math.tan(Math.PI / 8);\n\n/** The exponent `2^|k|`, or Infinity once the curve is a right angle within\n * the fit tolerance. */\nfunction exponentOf(k: number): number {\n const n = 2 ** Math.abs(k);\n return 1 - 0.5 ** (1 / n) < CORNER_FIT_TOLERANCE / 4 ? Infinity : n;\n}\n\n/** The point at `theta` on the unit curve `u^n + v^n = 1`: `π/2` is\n * `(0, 1)`, where the corner starts, and `0` is `(1, 0)`, where it ends. */\nfunction unitPoint(n: number, theta: number): Point {\n const p = 2 / n;\n return { x: Math.cos(theta) ** p, y: Math.sin(theta) ** p };\n}\n\n/** The unit direction of travel from start to end at `theta`. */\nfunction unitTangent(n: number, theta: number): Point {\n const q = 2 - 2 / n;\n const x = Math.sin(theta) ** q, y = -(Math.cos(theta) ** q);\n const l = Math.hypot(x, y);\n return { x: x / l, y: y / l };\n}\n\ntype UnitCubic = [Point, Point, Point];\n\nconst sub = (a: Point, b: Point): Point => ({ x: a.x - b.x, y: a.y - b.y });\n\nfunction cubicAt(p0: Point, [c1, c2, p3]: UnitCubic, t: number): Point {\n const u = 1 - t;\n const a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;\n return { x: a * p0.x + b * c1.x + c * c2.x + d * p3.x, y: a * p0.y + b * c1.y + c * c2.y + d * p3.y };\n}\n\n/** The distance from `q` to the cubic `p0, piece`: the nearest of a coarse\n * scan, refined by bisecting the parameter around it. */\nfunction distanceToCubic(q: Point, p0: Point, piece: UnitCubic): number {\n const d = (t: number) => { const c = cubicAt(p0, piece, t); return Math.hypot(c.x - q.x, c.y - q.y); };\n let best = 0;\n for (let i = 1; i <= 32; i++) if (d(i / 32) < d(best / 32)) best = i;\n let lo = Math.max(0, (best - 1) / 32), hi = Math.min(1, (best + 1) / 32);\n for (let i = 0; i < 30; i++) {\n const a = lo + (hi - lo) / 3, b = hi - (hi - lo) / 3;\n if (d(a) < d(b)) hi = b; else lo = a;\n }\n return d((lo + hi) / 2);\n}\n\n/** The farthest any point of the true curve between `a` and `b` lies from\n * the cubic `p0, piece`. */\nfunction fitError(n: number, a: number, b: number, p0: Point, piece: UnitCubic): number {\n let worst = 0;\n for (let i = 1; i < 16; i++) worst = Math.max(worst, distanceToCubic(unitPoint(n, a + (b - a) * (i / 16)), p0, piece));\n return worst;\n}\n\n/** Cubics through the unit curve from `theta = a` down to `b`, split until\n * each is within `tol`. */\nfunction fitUnit(n: number, a: number, b: number, tol: number, depth: number, out: UnitCubic[]): void {\n const p0 = unitPoint(n, a), p3 = unitPoint(n, b);\n const samples: Point[] = [];\n const params: number[] = [];\n for (let i = 0; i <= 12; i++) {\n samples.push(unitPoint(n, a + (b - a) * (i / 12)));\n params.push(i / 12);\n }\n const tEnd = unitTangent(n, b);\n const { cp1, cp2 } = fitCubicWithTangents(samples, unitTangent(n, a), { x: -tEnd.x, y: -tEnd.y }, { params });\n const piece: UnitCubic = [cp1, cp2, p3];\n if (depth >= 10 || fitError(n, a, b, p0, piece) <= tol) { out.push(piece); return; }\n const mid = (a + b) / 2;\n fitUnit(n, a, mid, tol, depth + 1, out);\n fitUnit(n, mid, b, tol, depth + 1, out);\n}\n\nconst unitCache = new Map<string, UnitCubic[]>();\n\n/** The unit curve of exponent `n` as cubics, `(0, 1)` to `(1, 0)`. */\nfunction unitCubics(n: number, tol: number): UnitCubic[] {\n if (n === 2) return [[{ x: KAPPA, y: 1 }, { x: 1, y: KAPPA }, { x: 1, y: 0 }]];\n const key = `${n}:${tol}`;\n let hit = unitCache.get(key);\n if (!hit) {\n hit = [];\n fitUnit(n, Math.PI / 2, 0, tol, 0, hit);\n if (unitCache.size > 256) unitCache.clear();\n unitCache.set(key, hit);\n }\n return hit;\n}\n\n/** `frame` mapped from the unit square spanned at `center`. */\nfunction mapperFor(frame: CornerShapeFrame, center: Point): (p: Point) => Point {\n const ex = sub(frame.end, center), sy = sub(frame.start, center);\n return (p) => ({ x: center.x + p.x * ex.x + p.y * sy.x, y: center.y + p.x * ex.y + p.y * sy.y });\n}\n\n/** The center the convex curves are spanned from: across the cut from `outer`. */\nexport function cornerCenter(frame: CornerShapeFrame): Point {\n return { x: frame.start.x + frame.end.x - frame.outer.x, y: frame.start.y + frame.end.y - frame.outer.y };\n}\n\n/**\n * The outline of a corner of parameter `k` across `frame`, from its start to\n * its end. Exact at `k = 0` (a line), `±1` (the cubic quarter arc the kit\n * draws circles with) and `±∞` (two lines, through the outer corner or the\n * center); fitted with cubics within `tolerance` of the setback elsewhere.\n */\nexport function cornerShapePieces(k: number, frame: CornerShapeFrame, tolerance = CORNER_FIT_TOLERANCE): CornerPiece[] {\n if (k === 0) return [{ kind: 'line', to: frame.end }];\n const n = exponentOf(k);\n if (n === Infinity) {\n const via = k > 0 ? frame.outer : cornerCenter(frame);\n return [{ kind: 'line', to: via }, { kind: 'line', to: frame.end }];\n }\n const map = mapperFor(frame, k > 0 ? cornerCenter(frame) : frame.outer);\n return unitCubics(n, tolerance).map(([c1, c2, to]) => ({ kind: 'cubic', c1: map(c1), c2: map(c2), to: map(to) }));\n}\n\n/** The point on the true curve of parameter `k` across `frame` at `s`, from\n * 0 at its start to 1 at its end. Finite `k` only. */\nexport function cornerShapePoint(k: number, frame: CornerShapeFrame, s: number): Point {\n const n = 2 ** Math.abs(k);\n const map = mapperFor(frame, k > 0 ? cornerCenter(frame) : frame.outer);\n return map(unitPoint(n, (Math.PI / 2) * (1 - s)));\n}\n","/**\n * A path decoded into contours of anchors and the exact segments between\n * them, for corner expansion: lines stay lines, a quadratic is elevated to\n * the cubic it equals, and a closing curve that ends on its subpath's first\n * point folds onto that anchor the way `enumerateAnchors` counts it.\n */\nimport { forEachSegment, PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z } from '../commands';\nimport { cubicEvalAt, splitCubicAt } from '../curve';\nimport type { PolygonPath } from '../path';\nimport type { Point } from './cubicMath';\n\n/** One segment as a cubic; a line has its controls on its ends. */\nexport interface Seg {\n line: boolean;\n p0: Point; c1: Point; c2: Point; p3: Point;\n}\n\n/** One subpath. Segment `k` runs from anchor `k` to anchor `k + 1`, wrapping\n * when closed, so a closed contour has as many segments as anchors. */\nexport interface Contour {\n anchors: Point[];\n segs: Seg[];\n closed: boolean;\n /** Flat index of `anchors[0]`. */\n first: number;\n /** For each anchor, the index of the command that drew it among the\n * path's M, L, C, and Q commands: the numbering `countPathAnchors` sizes\n * per-anchor arrays by. */\n sources: number[];\n}\n\nconst lineSeg = (a: Point, b: Point): Seg => ({ line: true, p0: a, c1: a, c2: b, p3: b });\n\n/** `path` as contours, or null when a command opens a subpath with no `M`,\n * where the anchor walkers and this one would count differently. */\nexport function decodeContours(path: PolygonPath): Contour[] | null {\n const { commands, coords } = path;\n const out: Contour[] = [];\n let cur: Contour | null = null;\n let flat = 0;\n let drawn = 0;\n let bad = false;\n const last = (): Point => cur!.anchors[cur!.anchors.length - 1];\n const push = (p: Point, seg: Seg): void => {\n cur!.segs.push(seg);\n cur!.anchors.push(p);\n cur!.sources.push(drawn++);\n flat++;\n };\n forEachSegment(commands, coords, (cmd, ci, _px, _py, _i, opens) => {\n if (opens) { bad = true; return false; }\n const at = (k: number): Point => ({ x: coords[ci + k], y: coords[ci + k + 1] });\n switch (cmd) {\n case PATH_M:\n if (cur) out.push(cur);\n cur = { anchors: [at(0)], segs: [], closed: false, first: flat++, sources: [drawn++] };\n break;\n case PATH_L:\n push(at(0), lineSeg(last(), at(0)));\n break;\n case PATH_C:\n push(at(4), { line: false, p0: last(), c1: at(0), c2: at(2), p3: at(4) });\n break;\n case PATH_Q: {\n const p0 = last(), q = at(0), p3 = at(2);\n const c1 = { x: p0.x + (2 / 3) * (q.x - p0.x), y: p0.y + (2 / 3) * (q.y - p0.y) };\n const c2 = { x: p3.x + (2 / 3) * (q.x - p3.x), y: p3.y + (2 / 3) * (q.y - p3.y) };\n push(p3, { line: false, p0, c1, c2, p3 });\n break;\n }\n case PATH_Z:\n if (cur) closeContour(cur, () => flat--);\n if (cur) out.push(cur);\n cur = null;\n break;\n }\n return undefined;\n });\n if (bad) return null;\n if (cur) out.push(cur);\n return out;\n}\n\nfunction closeContour(c: Contour, unfold: () => void): void {\n c.closed = true;\n const n = c.anchors.length;\n const a0 = c.anchors[0];\n const end = c.anchors[n - 1];\n if (n > 1 && !c.segs[n - 2].line && end.x === a0.x && end.y === a0.y) {\n c.anchors.pop();\n c.sources.pop();\n unfold();\n return;\n }\n c.segs.push(lineSeg(end, a0));\n}\n\nconst LUT_STEPS = 32;\n\n/** Arc length of `seg`. */\nexport function segLength(seg: Seg): number {\n if (seg.line) return Math.hypot(seg.p3.x - seg.p0.x, seg.p3.y - seg.p0.y);\n return lut(seg)[LUT_STEPS];\n}\n\nconst lutCache = new WeakMap<Seg, Float64Array>();\n\nfunction lut(seg: Seg): Float64Array {\n let table = lutCache.get(seg);\n if (table) return table;\n table = new Float64Array(LUT_STEPS + 1);\n let prev = seg.p0;\n for (let i = 1; i <= LUT_STEPS; i++) {\n const p = pointAt(seg, i / LUT_STEPS);\n table[i] = table[i - 1] + Math.hypot(p.x - prev.x, p.y - prev.y);\n prev = p;\n }\n lutCache.set(seg, table);\n return table;\n}\n\n/** Parameter of the point `s` along `seg` from its start. */\nexport function paramAtLength(seg: Seg, s: number): number {\n const total = segLength(seg);\n if (total <= 0) return 0;\n if (seg.line) return Math.min(1, Math.max(0, s / total));\n const table = lut(seg);\n if (s <= 0) return 0;\n if (s >= total) return 1;\n let i = 1;\n while (table[i] < s) i++;\n const span = table[i] - table[i - 1];\n const f = span > 0 ? (s - table[i - 1]) / span : 0;\n return (i - 1 + f) / LUT_STEPS;\n}\n\nexport function pointAt(seg: Seg, t: number): Point {\n if (seg.line) {\n return { x: seg.p0.x + (seg.p3.x - seg.p0.x) * t, y: seg.p0.y + (seg.p3.y - seg.p0.y) * t };\n }\n const { p0, c1, c2, p3 } = seg;\n const [x, y] = cubicEvalAt(p0.x, p0.y, c1.x, c1.y, c2.x, c2.y, p3.x, p3.y, t);\n return { x, y };\n}\n\nfunction unit(x: number, y: number): Point | null {\n const l = Math.hypot(x, y);\n return l > 1e-12 ? { x: x / l, y: y / l } : null;\n}\n\n/** Unit direction of travel along `seg` at `t`, or null for a segment of no length. */\nexport function tangentAt(seg: Seg, t: number): Point | null {\n const { p0, c1, c2, p3 } = seg;\n if (seg.line) return unit(p3.x - p0.x, p3.y - p0.y);\n const u = 1 - t;\n const dx = 3 * (u * u * (c1.x - p0.x) + 2 * u * t * (c2.x - c1.x) + t * t * (p3.x - c2.x));\n const dy = 3 * (u * u * (c1.y - p0.y) + 2 * u * t * (c2.y - c1.y) + t * t * (p3.y - c2.y));\n const d = unit(dx, dy);\n if (d) return d;\n // A control on its end point: the tangent there runs to the next point.\n if (t < 0.5) return unit(c2.x - p0.x, c2.y - p0.y) ?? unit(p3.x - p0.x, p3.y - p0.y);\n return unit(p3.x - c1.x, p3.y - c1.y) ?? unit(p3.x - p0.x, p3.y - p0.y);\n}\n\n/** The piece of cubic `seg` between parameters `t0 < t1`, as `[c1, c2, p3]`. */\nexport function subCubic(seg: Seg, t0: number, t1: number): [Point, Point, Point] {\n const { p0, c1, c2, p3 } = seg;\n let c = [p0.x, p0.y, c1.x, c1.y, c2.x, c2.y, p3.x, p3.y];\n if (t0 > 0) c = [...splitCubicAt(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], t0)[1]];\n const t = t0 < 1 ? (t1 - t0) / (1 - t0) : 1;\n if (t < 1) c = [...splitCubicAt(c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], t)[0]];\n return [{ x: c[2], y: c[3] }, { x: c[4], y: c[5] }, { x: c[6], y: c[7] }];\n}\n","/**\n * Corner expansion: a path's corner specs turned into the plain geometry\n * that every reader draws, hits, bounds, and exports.\n */\nimport type { Path, PolygonPath } from '../path';\nimport { PathBuilder } from './builder';\nimport { cornerAt, hasCorners, withoutCorners, type CornerSpec } from './cornerSpec';\nimport { cornerShapeK, cornerShapePieces, type CornerPiece, type CornerShapeFrame } from './cornerShape';\nimport {\n decodeContours, paramAtLength, pointAt, segLength, subCubic, tangentAt,\n type Contour,\n} from './cornerSegments';\nimport type { Point } from './cubicMath';\n\n/** Below this turn (radians) an anchor is smooth, and no corner can be cut. */\nconst MIN_TURN = 1e-3;\n\n/** Where and how a corner anchor can be cut. */\nexport interface CornerFrame {\n /** Flat anchor index. */\n index: number;\n /** The anchor. */\n x: number;\n y: number;\n /** Unit direction from the anchor into the wedge the cut is taken from. */\n bisector: Point;\n /** Half the angle between the two edges at the anchor. */\n halfAngle: number;\n /** How far along each edge the stored spec cuts, its setback, after clamping. */\n trim: number;\n /** The longest cut the edges allow while the neighbors keep theirs. */\n maxTrim: number;\n}\n\ninterface AnchorCut {\n frame: Omit<CornerFrame, 'trim' | 'maxTrim'>;\n spec: CornerSpec | null;\n want: number;\n trim: number;\n}\n\n/** The cut each anchor of `c` takes, clamped so that the two cuts on any\n * segment never meet past each other. Null for an anchor that cannot be cut. */\nfunction contourCuts(path: PolygonPath, c: Contour): (AnchorCut | null)[] {\n const n = c.anchors.length;\n const lengths = c.segs.map(segLength);\n const cuts: (AnchorCut | null)[] = c.anchors.map((a, i) => {\n const inSeg = i > 0 ? c.segs[i - 1] : c.closed ? c.segs[n - 1] : null;\n const outSeg = i < c.segs.length ? c.segs[i] : null;\n if (!inSeg || !outSeg || inSeg === outSeg) return null;\n const tIn = tangentAt(inSeg, 1);\n const tOut = tangentAt(outSeg, 0);\n if (!tIn || !tOut) return null;\n const turn = Math.acos(Math.max(-1, Math.min(1, tIn.x * tOut.x + tIn.y * tOut.y)));\n if (turn < MIN_TURN || turn > Math.PI - MIN_TURN) return null;\n const bx = tOut.x - tIn.x, by = tOut.y - tIn.y;\n const bl = Math.hypot(bx, by);\n const halfAngle = (Math.PI - turn) / 2;\n const spec = cornerAt(path, c.first + i);\n const want = spec ? spec.radius : 0;\n return {\n frame: { index: c.first + i, x: a.x, y: a.y, bisector: { x: bx / bl, y: by / bl }, halfAngle },\n spec,\n want,\n trim: want,\n };\n });\n const scale = cuts.map(() => 1);\n c.segs.forEach((_seg, k) => {\n const a = k, b = (k + 1) % n;\n const sum = (cuts[a]?.want ?? 0) + (cuts[b]?.want ?? 0);\n if (sum <= lengths[k]) return;\n const f = lengths[k] / sum;\n scale[a] = Math.min(scale[a], f);\n scale[b] = Math.min(scale[b], f);\n });\n cuts.forEach((cut, i) => { if (cut) cut.trim = cut.want * scale[i]; });\n return cuts;\n}\n\n/** Every anchor of `path` that can take a corner, with the cut its spec\n * makes now. */\nexport function cornerFrames(path: PolygonPath): CornerFrame[] {\n const contours = decodeContours(path);\n if (!contours) return [];\n const out: CornerFrame[] = [];\n for (const c of contours) {\n const cuts = contourCuts(path, c);\n const n = c.anchors.length;\n cuts.forEach((cut, i) => {\n if (!cut) return;\n const prev = (i - 1 + n) % n;\n const next = (i + 1) % n;\n const inLen = segLength(c.segs[prev]);\n const outLen = segLength(c.segs[i]);\n const room = (len: number, j: number): number => len - Math.min(len, cuts[j]?.want ?? 0);\n out.push({\n ...cut.frame,\n trim: cut.trim,\n maxTrim: Math.max(0, Math.min(room(inLen, prev), room(outLen, next))),\n });\n });\n }\n return out;\n}\n\n/** The frame of the corner at flat anchor `index`, or null when that anchor\n * cannot take one. */\nexport function cornerFrameAt(path: PolygonPath, index: number): CornerFrame | null {\n return cornerFrames(path).find((f) => f.index === index) ?? null;\n}\n\n/** A path with its corners expanded, and where its anchors came from. */\nexport interface ResolvedCorners {\n path: PolygonPath;\n /**\n * For each anchor of `path` (each M, L, C, or Q, as `countPathAnchors`\n * counts them), the anchor of the source path it belongs to, in the same\n * numbering. Every point a corner's cut adds belongs to that corner's\n * anchor. Null when the expansion added none.\n */\n anchorSources: Uint32Array | null;\n}\n\nconst expanded = new WeakMap<PolygonPath, ResolvedCorners>();\n\n/** {@link resolveCorners}, also answering which source anchor each anchor of\n * the result came from, so an array kept per anchor (`vertexColors`) can be\n * carried onto it with {@link remapPerAnchor}. */\nexport function resolveCornersWithSources(path: PolygonPath): ResolvedCorners {\n if (path.corners === undefined) return { path, anchorSources: null };\n const hit = expanded.get(path);\n if (hit) return hit;\n const out = hasCorners(path) ? expand(path) : { path: withoutCorners(path), anchorSources: null };\n expanded.set(path, out);\n return out;\n}\n\n/**\n * `path` with its corner specs expanded into plain geometry and dropped: each\n * corner is cut `radius` along both edges and spans the cut with its shape's\n * superellipse (`cornerShapePieces`). Each cut is clamped so the cuts on\n * either end of a segment never overlap. A path with no corners comes back\n * as itself, and so does a rect.\n */\nexport function resolveCorners<P extends Path>(path: P): P;\nexport function resolveCorners(path: Path): Path {\n if (path.kind !== 'polygon') return path;\n return resolveCornersWithSources(path).path;\n}\n\n/** `values`, `stride` numbers per source anchor, as `stride` per anchor of\n * the expanded path that `sources` describes. */\nexport function remapPerAnchor<T>(values: readonly T[], sources: Uint32Array, stride: number): T[] {\n const out = new Array<T>(sources.length * stride);\n for (let i = 0; i < sources.length; i++) {\n for (let k = 0; k < stride; k++) out[i * stride + k] = values[sources[i] * stride + k];\n }\n return out;\n}\n\n/** A `PathBuilder` that records, for each anchor it writes, the source anchor `src`. */\nclass Emitter {\n readonly b = new PathBuilder();\n readonly sources: number[] = [];\n src = 0;\n moveTo(x: number, y: number): void { this.b.moveTo(x, y); this.sources.push(this.src); }\n lineTo(x: number, y: number): void { this.b.lineTo(x, y); this.sources.push(this.src); }\n curveTo(a: number, b: number, c: number, d: number, x: number, y: number): void {\n this.b.curveTo(a, b, c, d, x, y);\n this.sources.push(this.src);\n }\n close(): void { this.b.close(); }\n}\n\nfunction expand(path: PolygonPath): ResolvedCorners {\n const contours = decodeContours(path);\n if (!contours) return { path: withoutCorners(path), anchorSources: null };\n const e = new Emitter();\n for (const c of contours) emitContour(e, c, contourCuts(path, c));\n const { commands, coords } = e.b.build();\n return {\n path: { ...withoutCorners(path), commands, coords },\n anchorSources: Uint32Array.from(e.sources),\n };\n}\n\n/** Parameter on segment `k` where the cut at its start ends, and where the\n * cut at its end begins. */\nfunction segSpan(c: Contour, cuts: readonly (AnchorCut | null)[], k: number): [number, number] {\n const seg = c.segs[k];\n const len = segLength(seg);\n const t0 = paramAtLength(seg, cuts[k]?.trim ?? 0);\n const t1 = paramAtLength(seg, len - (cuts[(k + 1) % c.anchors.length]?.trim ?? 0));\n return [t0, Math.max(t0, t1)];\n}\n\n/** The corner cut at the anchor segment `k` runs into, as the expansion\n * draws it, or null when that anchor takes none. */\nfunction cutAfter(\n c: Contour, cuts: readonly (AnchorCut | null)[], spans: readonly [number, number][], k: number,\n): { cut: AnchorCut; start: Point; end: Point; pieces: CornerPiece[] } | null {\n const j = (k + 1) % c.anchors.length;\n const cut = cuts[j];\n const next = c.segs[j];\n if (!cut?.spec || cut.trim <= 0 || !next) return null;\n const seg = c.segs[k];\n const start = pointAt(seg, spans[k][1]);\n const end = pointAt(next, spans[j][0]);\n const frame = shapeFrame({ x: cut.frame.x, y: cut.frame.y }, start, tangentAt(seg, spans[k][1]), end, tangentAt(next, spans[j][0]));\n return { cut, start, end, pieces: cornerShapePieces(cornerShapeK(cut.spec.shape), frame) };\n}\n\n/** One corner of a path as its expansion draws it. */\nexport interface CornerCut {\n /** Flat anchor index. */\n index: number;\n anchor: Point;\n spec: CornerSpec;\n /** Where the cut leaves the edge into the anchor, and where it rejoins the edge out of it. */\n start: Point;\n end: Point;\n /** The outline from `start` to `end`. */\n pieces: CornerPiece[];\n}\n\n/** Every corner `path` cuts, in path order. */\nexport function cornerCuts(path: PolygonPath): CornerCut[] {\n if (!hasCorners(path)) return [];\n const out: CornerCut[] = [];\n for (const c of decodeContours(path) ?? []) {\n const cuts = contourCuts(path, c);\n const spans = c.segs.map((_s, k) => segSpan(c, cuts, k));\n c.segs.forEach((_seg, k) => {\n const at = cutAfter(c, cuts, spans, k);\n if (!at) return;\n const { frame } = at.cut;\n out.push({ index: frame.index, anchor: { x: frame.x, y: frame.y }, spec: at.cut.spec!, start: at.start, end: at.end, pieces: at.pieces });\n });\n }\n return out;\n}\n\nfunction emitContour(b: Emitter, c: Contour, cuts: readonly (AnchorCut | null)[]): void {\n const n = c.anchors.length;\n const spans = c.segs.map((_s, k) => segSpan(c, cuts, k));\n const start = c.closed && c.segs.length > 0 ? pointAt(c.segs[0], spans[0][0]) : c.anchors[0];\n b.src = c.sources[0];\n b.moveTo(start.x, start.y);\n c.segs.forEach((seg, k) => {\n const [t0, t1] = spans[k];\n // Both the run up to the next anchor and the cut at it belong to that anchor.\n b.src = c.sources[(k + 1) % n];\n const closing = c.closed && k === n - 1 && !(cuts[0]?.spec && cuts[0].trim > 0);\n if (t1 > t0 && !(closing && seg.line)) {\n if (seg.line) {\n const p = pointAt(seg, t1);\n b.lineTo(p.x, p.y);\n } else {\n const [c1, c2, p3] = subCubic(seg, t0, t1);\n b.curveTo(c1.x, c1.y, c2.x, c2.y, p3.x, p3.y);\n }\n }\n const at = cutAfter(c, cuts, spans, k);\n if (!at) return;\n const pieces = [...at.pieces];\n // A closing line that ends where the contour started is drawn by the close.\n if ((k + 1) % n === 0 && pieces.at(-1)?.kind === 'line') pieces.pop();\n for (const piece of pieces) {\n if (piece.kind === 'line') b.lineTo(piece.to.x, piece.to.y);\n else b.curveTo(piece.c1.x, piece.c1.y, piece.c2.x, piece.c2.y, piece.to.x, piece.to.y);\n }\n });\n if (c.closed) b.close();\n}\n\n/** The frame a corner's shape spans: from `p1` to `p2`, around where the two\n * edges' tangents there meet. That is the anchor itself between straight\n * edges; between curves it keeps every convex shape tangent to both. */\nfunction shapeFrame(v: Point, p1: Point, t1: Point | null, p2: Point, t2: Point | null): CornerShapeFrame {\n const outer = t1 && t2 ? tangentMeet(p1, t1, p2, t2) : null;\n const chord = Math.hypot(p2.x - p1.x, p2.y - p1.y);\n const far = !outer || Math.hypot(outer.x - v.x, outer.y - v.y) > 4 * chord;\n return { start: p1, end: p2, outer: far ? v : outer };\n}\n\n/** Where the line through `a` along `ta` meets the one through `b` along\n * `tb`, or null when they are parallel. */\nfunction tangentMeet(a: Point, ta: Point, b: Point, tb: Point): Point | null {\n const den = ta.x * tb.y - ta.y * tb.x;\n if (Math.abs(den) < 1e-9) return null;\n const s = ((b.x - a.x) * tb.y - (b.y - a.y) * tb.x) / den;\n return { x: a.x + ta.x * s, y: a.y + ta.y * s };\n}\n","/**\n * Bezier flattening — subdivide cubic and quadratic segments into polyline\n * approximations within a flatness tolerance.\n *\n * The flatness metric is the maximum distance from any control point to the\n * chord between endpoints.\n *\n * Tolerance is in world units. 0.5 is a sensible default for screen-rate\n * rendering at 1× zoom; consumers that zoom in heavily should pass a\n * tighter tolerance.\n */\n\nexport const DEFAULT_FLATTEN_TOLERANCE = 0.5;\n\n/** Floor for a non-positive or NaN tolerance. Without it the flatness test can\n * never be satisfied and the subdivision recurses until the stack blows. */\nconst MIN_FLATTEN_TOLERANCE = 1e-6;\n\n/** Subdivision ceiling. The tolerance floor bounds the common runaway; this\n * bounds the other one, coordinates large enough that reaching 1e-6 takes\n * hundreds of levels. Error falls roughly 4x per level, so 16 is far beyond\n * any tolerance a caller can mean. */\nconst MAX_FLATTEN_DEPTH = 16;\n\nfunction usableTolerance(tolerance: number): number {\n return tolerance > 0 ? tolerance : MIN_FLATTEN_TOLERANCE;\n}\n\nfunction finite6(a: number, b: number, c: number, d: number, e: number, f: number): boolean {\n return Number.isFinite(a) && Number.isFinite(b) && Number.isFinite(c)\n && Number.isFinite(d) && Number.isFinite(e) && Number.isFinite(f);\n}\n\nfunction finite8(\n a: number, b: number, c: number, d: number,\n e: number, f: number, g: number, h: number,\n): boolean {\n return finite6(a, b, c, d, e, f) && Number.isFinite(g) && Number.isFinite(h);\n}\n\n/**\n * Distance from point P to segment AB. To the segment, not the line through\n * it: a control point on that line but past an end still pulls the curve out\n * beyond the chord, and measures zero against the line.\n */\nfunction distPointToSegment(px: number, py: number, ax: number, ay: number, bx: number, by: number): number {\n const dx = bx - ax;\n const dy = by - ay;\n const len2 = dx * dx + dy * dy;\n const along = len2 === 0 ? 0 : ((px - ax) * dx + (py - ay) * dy) / len2;\n if (along <= 0) return Math.hypot(px - ax, py - ay);\n if (along >= 1) return Math.hypot(px - bx, py - by);\n return Math.abs((px - ax) * dy - (py - ay) * dx) / Math.sqrt(len2);\n}\n\n/** Whether a control polygon turns `maxTurn` radians or less in all, skipping\n * zero-length legs. Its turn bounds the turn of the curve it controls, so it\n * bounds the corner a chord standing in for that curve can leave. */\nfunction turnsWithin(\n x0: number, y0: number, x1: number, y1: number,\n x2: number, y2: number, x3: number, y3: number,\n maxTurn: number,\n): boolean {\n let turn = legTurn(x1 - x0, y1 - y0, x2 - x1, y2 - y1);\n if (turn > maxTurn) return false;\n turn += legTurn(x2 - x1, y2 - y1, x3 - x2, y3 - y2);\n if (x2 === x1 && y2 === y1) turn += legTurn(x1 - x0, y1 - y0, x3 - x2, y3 - y2);\n return turn <= maxTurn;\n}\n\n/** Angle between two legs; zero when either has no length. */\nfunction legTurn(ax: number, ay: number, bx: number, by: number): number {\n const lens = Math.sqrt((ax * ax + ay * ay) * (bx * bx + by * by));\n if (lens === 0) return 0;\n return Math.acos(Math.max(-1, Math.min(1, (ax * bx + ay * by) / lens)));\n}\n\n/**\n * Recursively subdivide a cubic bezier (P0..P3) and append `lineTo`-style\n * vertices to `out` (interleaved x,y). The starting endpoint is *not*\n * appended — callers usually emitted it as the segment's previous vertex.\n */\nexport function flattenCubic(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n x3: number, y3: number,\n tolerance: number,\n out: number[],\n): void {\n if (!finite8(x0, y0, x1, y1, x2, y2, x3, y3)) {\n out.push(x3, y3);\n return;\n }\n flattenCubicRec(x0, y0, x1, y1, x2, y2, x3, y3, usableTolerance(tolerance), out, 0);\n}\n\nfunction flattenCubicRec(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n x3: number, y3: number,\n tolerance: number,\n out: number[],\n depth: number,\n): void {\n const d1 = distPointToSegment(x1, y1, x0, y0, x3, y3);\n const d2 = distPointToSegment(x2, y2, x0, y0, x3, y3);\n if (Math.max(d1, d2) <= tolerance || depth >= MAX_FLATTEN_DEPTH) {\n out.push(x3, y3);\n return;\n }\n // De Casteljau split at t=0.5\n const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;\n const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;\n const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;\n const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;\n const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;\n const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;\n flattenCubicRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, out, depth + 1);\n flattenCubicRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, out, depth + 1);\n}\n\n/** Recursively subdivide a quadratic bezier (P0, P1, P2). */\nexport function flattenQuadratic(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n tolerance: number,\n out: number[],\n): void {\n if (!finite6(x0, y0, x1, y1, x2, y2)) {\n out.push(x2, y2);\n return;\n }\n flattenQuadraticRec(x0, y0, x1, y1, x2, y2, usableTolerance(tolerance), out, 0);\n}\n\nfunction flattenQuadraticRec(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n tolerance: number,\n out: number[],\n depth: number,\n): void {\n const d = distPointToSegment(x1, y1, x0, y0, x2, y2);\n if (d <= tolerance || depth >= MAX_FLATTEN_DEPTH) {\n out.push(x2, y2);\n return;\n }\n const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;\n const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;\n const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;\n flattenQuadraticRec(x0, y0, x01, y01, x012, y012, tolerance, out, depth + 1);\n flattenQuadraticRec(x012, y012, x12, y12, x2, y2, tolerance, out, depth + 1);\n}\n\n/**\n * Like `flattenCubic` but also appends to `arcOut`, for each new flattened\n * point, its *cumulative distance from the segment start* — not a normalized\n * fraction. The caller divides each by the segment's total flattened arc\n * length to yield t ∈ (0, 1]. `maxTurn`, in radians, also bounds how far each\n * piece's control polygon may turn.\n */\nexport function flattenCubicWithArcLen(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n x3: number, y3: number,\n tolerance: number,\n out: number[],\n arcOut: number[],\n maxTurn = Infinity,\n): number {\n if (!finite8(x0, y0, x1, y1, x2, y2, x3, y3)) {\n out.push(x3, y3);\n arcOut.push(0);\n return 0;\n }\n return flattenCubicArcRec(x0, y0, x1, y1, x2, y2, x3, y3, usableTolerance(tolerance), maxTurn, out, arcOut, 0, 0);\n}\n\nfunction flattenCubicArcRec(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n x3: number, y3: number,\n tolerance: number,\n maxTurn: number,\n out: number[],\n arcOut: number[],\n accum: number,\n depth: number,\n): number {\n const d1 = distPointToSegment(x1, y1, x0, y0, x3, y3);\n const d2 = distPointToSegment(x2, y2, x0, y0, x3, y3);\n const flat = Math.max(d1, d2) <= tolerance\n && (maxTurn === Infinity || turnsWithin(x0, y0, x1, y1, x2, y2, x3, y3, maxTurn));\n if (flat || depth >= MAX_FLATTEN_DEPTH) {\n const lastX = out.length >= 2 ? out[out.length - 2] : x0;\n const lastY = out.length >= 2 ? out[out.length - 1] : y0;\n const seg = Math.hypot(x3 - lastX, y3 - lastY);\n accum += seg;\n out.push(x3, y3);\n arcOut.push(accum);\n return accum;\n }\n const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;\n const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;\n const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;\n const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;\n const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;\n const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;\n accum = flattenCubicArcRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, maxTurn, out, arcOut, accum, depth + 1);\n accum = flattenCubicArcRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, maxTurn, out, arcOut, accum, depth + 1);\n return accum;\n}\n\n/** Flatten a quadratic bezier into line segments within `tolerance`, appending\n * points to `out` and their cumulative arc lengths to `arcOut`. The arc\n * lengths are what lets per-anchor color and dash phase be interpolated\n * evenly along the curve rather than per segment. */\nexport function flattenQuadraticWithArcLen(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n tolerance: number,\n out: number[],\n arcOut: number[],\n maxTurn = Infinity,\n): number {\n if (!finite6(x0, y0, x1, y1, x2, y2)) {\n out.push(x2, y2);\n arcOut.push(0);\n return 0;\n }\n return flattenQuadraticArcRec(x0, y0, x1, y1, x2, y2, usableTolerance(tolerance), maxTurn, out, arcOut, 0, 0);\n}\n\nfunction flattenQuadraticArcRec(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n tolerance: number,\n maxTurn: number,\n out: number[],\n arcOut: number[],\n accum: number,\n depth: number,\n): number {\n const d = distPointToSegment(x1, y1, x0, y0, x2, y2);\n const flat = d <= tolerance\n && (maxTurn === Infinity || turnsWithin(x0, y0, x1, y1, x2, y2, x2, y2, maxTurn));\n if (flat || depth >= MAX_FLATTEN_DEPTH) {\n const lastX = out.length >= 2 ? out[out.length - 2] : x0;\n const lastY = out.length >= 2 ? out[out.length - 1] : y0;\n const seg = Math.hypot(x2 - lastX, y2 - lastY);\n accum += seg;\n out.push(x2, y2);\n arcOut.push(accum);\n return accum;\n }\n const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;\n const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;\n const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;\n accum = flattenQuadraticArcRec(x0, y0, x01, y01, x012, y012, tolerance, maxTurn, out, arcOut, accum, depth + 1);\n accum = flattenQuadraticArcRec(x012, y012, x12, y12, x2, y2, tolerance, maxTurn, out, arcOut, accum, depth + 1);\n return accum;\n}\n\n","import { sign, dot, len2 } from './scalar';\n\n/**\n * Even-odd ray-cast point-in-polygon over an interleaved, unclosed contour\n * [x0,y0,x1,y1,…]. The closing edge (last→first) is implicit.\n *\n * `start`/`end` are vertex indices, not float offsets, and bound one contour\n * inside a buffer holding several.\n */\nexport function pointInPolygon(\n coords: ArrayLike<number>,\n px: number,\n py: number,\n start = 0,\n end = coords.length >> 1,\n): boolean {\n if (end - start < 3) return false;\n let inside = false;\n for (let i = start, j = end - 1; i < end; j = i++) {\n const xi = coords[i * 2], yi = coords[i * 2 + 1];\n const xj = coords[j * 2], yj = coords[j * 2 + 1];\n const crosses =\n (yi > py) !== (yj > py) &&\n px < ((xj - xi) * (py - yi)) / (yj - yi) + xi;\n if (crosses) inside = !inside;\n }\n return inside;\n}\n\n/**\n * True if segments (ax,ay)-(bx,by) and (cx,cy)-(dx,dy) intersect at a single\n * point. An endpoint landing on the other segment counts (a T-junction and a\n * shared endpoint both answer true) — hit-testing wants a grazing edge to\n * register. Collinear overlap answers false: there is no single crossing\n * point, so the sign test both segments rely on is zero on all four sides.\n */\nexport function segmentsCross(\n ax: number, ay: number, bx: number, by: number,\n cx: number, cy: number, dx: number, dy: number,\n): boolean {\n const d1 = sign((dx - cx) * (ay - cy) - (dy - cy) * (ax - cx));\n const d2 = sign((dx - cx) * (by - cy) - (dy - cy) * (bx - cx));\n const d3 = sign((bx - ax) * (cy - ay) - (by - ay) * (cx - ax));\n const d4 = sign((bx - ax) * (dy - ay) - (by - ay) * (dx - ax));\n return d1 !== d2 && d3 !== d4;\n}\n\n/** Squared distance from (px,py) to segment (ax,ay)-(bx,by), endpoint-clamped. */\nexport function pointSegmentDist2(\n px: number, py: number, ax: number, ay: number, bx: number, by: number,\n): number {\n const vx = bx - ax, vy = by - ay;\n const wx = px - ax, wy = py - ay;\n const vv = len2(vx, vy);\n let t = vv === 0 ? 0 : dot(wx, wy, vx, vy) / vv;\n t = t < 0 ? 0 : t > 1 ? 1 : t;\n const dx = px - (ax + t * vx), dy = py - (ay + t * vy);\n return len2(dx, dy);\n}\n","import type { PathOpenFill, PolygonPath } from './path';\n\nlet fallback: PathOpenFill = 'close';\n\n/** Set whether a fill closes an open subpath, for every path that names no\n * `openFill` of its own. Starts at `'close'`. */\nexport function setDefaultOpenFill(rule: PathOpenFill): void {\n fallback = rule;\n}\n\n/** The rule a path with no `openFill` of its own follows. */\nexport function defaultOpenFill(): PathOpenFill {\n return fallback;\n}\n\n/** Whether `path`'s open subpaths fill, each closed by a straight edge back to\n * its start. What painting, area, and the filled-region hit tests all ask. */\nexport function fillsOpenSubpaths(path: PolygonPath): boolean {\n return (path.openFill ?? fallback) === 'close';\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { nearestOnLine, nearestOnCubic } from './chunk-CE7IY7TB.js';
|
|
2
|
-
import { resolveCorners, fitCubicWithTangents } from './chunk-
|
|
2
|
+
import { resolveCorners, fitCubicWithTangents } from './chunk-2PKPKU4P.js';
|
|
3
3
|
import { forEachSegment, PATH_Z, PATH_Q, elevateQuadraticToCubic, cubicBounds, PATH_C, PATH_L, PATH_M, cubicPointAt } from './chunk-B53BERKG.js';
|
|
4
4
|
|
|
5
5
|
// src/paths/bounds.ts
|
|
@@ -148,5 +148,5 @@ function unit(p) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
export { boundsOfPath, fitPointRun, keepCorner };
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
152
|
-
//# sourceMappingURL=chunk-
|
|
151
|
+
//# sourceMappingURL=chunk-STGSBIOL.js.map
|
|
152
|
+
//# sourceMappingURL=chunk-STGSBIOL.js.map
|