@weasel-js/geom 1.10.0 → 1.11.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.
Files changed (55) hide show
  1. package/README.md +140 -16
  2. package/dist/3d/index.d.ts +29 -2
  3. package/dist/3d/index.js +49 -1
  4. package/dist/3d/index.js.map +1 -1
  5. package/dist/booleans/index.d.ts +34 -10
  6. package/dist/booleans/index.js +344 -352
  7. package/dist/booleans/index.js.map +1 -1
  8. package/dist/{chunk-MDT7F32A.js → chunk-6XSJY3TC.js} +10 -39
  9. package/dist/chunk-6XSJY3TC.js.map +1 -0
  10. package/dist/chunk-7KLJZFBY.js +573 -0
  11. package/dist/chunk-7KLJZFBY.js.map +1 -0
  12. package/dist/chunk-B53BERKG.js +386 -0
  13. package/dist/chunk-B53BERKG.js.map +1 -0
  14. package/dist/chunk-CE7IY7TB.js +104 -0
  15. package/dist/chunk-CE7IY7TB.js.map +1 -0
  16. package/dist/chunk-HGF5OVEN.js +129 -0
  17. package/dist/chunk-HGF5OVEN.js.map +1 -0
  18. package/dist/chunk-J2O2B54M.js +800 -0
  19. package/dist/chunk-J2O2B54M.js.map +1 -0
  20. package/dist/chunk-Q66NA2FU.js +174 -0
  21. package/dist/chunk-Q66NA2FU.js.map +1 -0
  22. package/dist/chunk-SASMXDBE.js +443 -0
  23. package/dist/chunk-SASMXDBE.js.map +1 -0
  24. package/dist/chunk-UI3FUWXM.js +533 -0
  25. package/dist/chunk-UI3FUWXM.js.map +1 -0
  26. package/dist/curvature-PkoLduGc.d.ts +454 -0
  27. package/dist/curves/index.d.ts +14 -5
  28. package/dist/curves/index.js +33 -111
  29. package/dist/curves/index.js.map +1 -1
  30. package/dist/index.d.ts +1697 -205
  31. package/dist/index.js +4729 -1308
  32. package/dist/index.js.map +1 -1
  33. package/dist/nd/index.d.ts +91 -27
  34. package/dist/nd/index.js +282 -0
  35. package/dist/nd/index.js.map +1 -1
  36. package/dist/path-BW8d_2RY.d.ts +157 -0
  37. package/dist/portCurve-C5HDWuuV.d.ts +30 -0
  38. package/dist/tessellate/index.d.ts +18 -4
  39. package/dist/tessellate/index.js +21 -277
  40. package/dist/tessellate/index.js.map +1 -1
  41. package/dist/warp/index.d.ts +252 -0
  42. package/dist/warp/index.js +1316 -0
  43. package/dist/warp/index.js.map +1 -0
  44. package/package.json +5 -1
  45. package/dist/chunk-MDT7F32A.js.map +0 -1
  46. package/dist/chunk-OXH3NOXC.js +0 -62
  47. package/dist/chunk-OXH3NOXC.js.map +0 -1
  48. package/dist/chunk-URQMDR6Q.js +0 -80
  49. package/dist/chunk-URQMDR6Q.js.map +0 -1
  50. package/dist/chunk-WQMYOCFB.js +0 -167
  51. package/dist/chunk-WQMYOCFB.js.map +0 -1
  52. package/dist/chunk-XS6ERH3X.js +0 -34
  53. package/dist/chunk-XS6ERH3X.js.map +0 -1
  54. package/dist/cubicMath-CFXbq6vp.d.ts +0 -116
  55. package/dist/path-Bf9KeVxC.d.ts +0 -44
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/curve.ts"],"names":[],"mappings":";AAGO,SAAS,WAAA,CACd,IAAY,EAAA,EAAY,EAAA,EAAY,IACpC,EAAA,EAAY,EAAA,EAAY,EAAA,EAAY,EAAA,EAAY,CAAA,EAC9B;AAClB,EAAA,MAAM,IAAI,CAAA,GAAI,CAAA;AACd,EAAA,MAAM,IAAI,CAAA,GAAI,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AACvE,EAAA,OAAO;AAAA,IACL,IAAI,EAAA,GAAK,CAAA,GAAI,EAAA,GAAK,CAAA,GAAI,KAAK,CAAA,GAAI,EAAA;AAAA,IAC/B,IAAI,EAAA,GAAK,CAAA,GAAI,EAAA,GAAK,CAAA,GAAI,KAAK,CAAA,GAAI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,CAAA,EACtB;AAC1B,EAAA,MAAM,EAAA,GAAK,MAAM,EAAA,GAAK,EAAA,IAAM,GAAG,EAAA,GAAK,EAAA,GAAA,CAAM,KAAK,EAAA,IAAM,CAAA;AACrD,EAAA,OAAO,CAAC,CAAC,EAAA,EAAI,EAAA,EAAI,EAAA,EAAI,EAAE,CAAA,EAAG,CAAC,EAAA,EAAI,EAAA,EAAI,EAAA,EAAI,EAAE,CAAC,CAAA;AAC5C","file":"chunk-URQMDR6Q.js","sourcesContent":["import type { Box } from './box';\n\n/** Cubic Bezier point at parameter t (de Casteljau / Bernstein form). */\nexport function cubicEvalAt(\n x0: number, y0: number, x1: number, y1: number,\n x2: number, y2: number, x3: number, y3: number, t: number,\n): [number, number] {\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 [\n a * x0 + b * x1 + c * x2 + d * x3,\n a * y0 + b * y1 + c * y2 + d * y3,\n ];\n}\n\n/**\n * Degree-elevate a quadratic (q0, ctrl, q1) to a cubic. Returns the two\n * cubic control points [c1x, c1y, c2x, c2y]; the cubic endpoints equal the\n * quadratic endpoints. c1 = q0 + 2/3(ctrl-q0), c2 = q1 + 2/3(ctrl-q1).\n */\nexport function elevateQuadraticToCubic(\n q0x: number, q0y: number, cx: number, cy: number, q1x: number, q1y: number,\n): [number, number, number, number] {\n return [\n q0x + (2 / 3) * (cx - q0x),\n q0y + (2 / 3) * (cy - q0y),\n q1x + (2 / 3) * (cx - q1x),\n q1y + (2 / 3) * (cy - q1y),\n ];\n}\n\n/** Axis-aligned extrema parameters of one cubic component (the 0,1 ends plus\n * any derivative roots in (0,1)). Used by cubicBounds. */\nfunction componentExtremaTs(p0: number, p1: number, p2: number, p3: number): number[] {\n // B'(t)=0 → quadratic a t² + b t + c = 0 with:\n const a = -p0 + 3 * p1 - 3 * p2 + p3;\n const b = 2 * (p0 - 2 * p1 + p2);\n const c = -p0 + p1;\n const ts: number[] = [];\n const push = (t: number) => { if (t > 0 && t < 1) ts.push(t); };\n if (Math.abs(a) < 1e-12) {\n if (Math.abs(b) > 1e-12) push(-c / b);\n } else {\n const disc = b * b - 4 * a * c;\n if (disc >= 0) {\n const sq = Math.sqrt(disc);\n push((-b + sq) / (2 * a));\n push((-b - sq) / (2 * a));\n }\n }\n return ts;\n}\n\n/** Tight AABB of a cubic, evaluating only extrema that lie on the curve. */\nexport function cubicBounds(\n x0: number, y0: number, x1: number, y1: number,\n x2: number, y2: number, x3: number, y3: number,\n): Box {\n let minX = Math.min(x0, x3), maxX = Math.max(x0, x3);\n let minY = Math.min(y0, y3), maxY = Math.max(y0, y3);\n for (const t of componentExtremaTs(x0, x1, x2, x3)) {\n const [ex] = cubicEvalAt(x0, y0, x1, y1, x2, y2, x3, y3, t);\n if (ex < minX) minX = ex;\n if (ex > maxX) maxX = ex;\n }\n for (const t of componentExtremaTs(y0, y1, y2, y3)) {\n const [, ey] = cubicEvalAt(x0, y0, x1, y1, x2, y2, x3, y3, t);\n if (ey < minY) minY = ey;\n if (ey > maxY) maxY = ey;\n }\n return [minX, minY, maxX, maxY];\n}\n\n/** Quadratic Bezier point at parameter t (Bernstein form). */\nexport function quadraticEvalAt(\n x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, t: number,\n): [number, number] {\n const u = 1 - t;\n const a = u * u, b = 2 * u * t, c = t * t;\n return [a * x0 + b * x1 + c * x2, a * y0 + b * y1 + c * y2];\n}\n\n/** A line segment's coords: start, end. */\nexport type LineCoords = [number, number, number, number];\n/** A quadratic Bezier's coords: start, control, end. */\nexport type QuadraticCoords = [number, number, number, number, number, number];\n/** A cubic Bezier's coords: start, two controls, end. */\nexport type CubicCoords = [number, number, number, number, number, number, number, number];\n\n/**\n * Split a cubic at parameter t (de Casteljau). The two halves share the point\n * at t and together trace the original exactly. A t outside [0, 1] splits the\n * curve's polynomial extension.\n */\nexport function splitCubicAt(\n x0: number, y0: number, x1: number, y1: number,\n x2: number, y2: number, x3: number, y3: number, t: number,\n): [CubicCoords, CubicCoords] {\n const ax = x0 + (x1 - x0) * t, ay = y0 + (y1 - y0) * t;\n const bx = x1 + (x2 - x1) * t, by = y1 + (y2 - y1) * t;\n const cx = x2 + (x3 - x2) * t, cy = y2 + (y3 - y2) * t;\n const dx = ax + (bx - ax) * t, dy = ay + (by - ay) * t;\n const ex = bx + (cx - bx) * t, ey = by + (cy - by) * t;\n const mx = dx + (ex - dx) * t, my = dy + (ey - dy) * t;\n return [[x0, y0, ax, ay, dx, dy, mx, my], [mx, my, ex, ey, cx, cy, x3, y3]];\n}\n\n/** Split a quadratic at parameter t (de Casteljau). See {@link splitCubicAt}. */\nexport function splitQuadraticAt(\n x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, t: number,\n): [QuadraticCoords, QuadraticCoords] {\n const ax = x0 + (x1 - x0) * t, ay = y0 + (y1 - y0) * t;\n const bx = x1 + (x2 - x1) * t, by = y1 + (y2 - y1) * t;\n const mx = ax + (bx - ax) * t, my = ay + (by - ay) * t;\n return [[x0, y0, ax, ay, mx, my], [mx, my, bx, by, x2, y2]];\n}\n\n/** Split a line segment at parameter t. See {@link splitCubicAt}. */\nexport function splitLineAt(\n x0: number, y0: number, x1: number, y1: number, t: number,\n): [LineCoords, LineCoords] {\n const mx = x0 + (x1 - x0) * t, my = y0 + (y1 - y0) * t;\n return [[x0, y0, mx, my], [mx, my, x1, y1]];\n}\n"]}
@@ -1,167 +0,0 @@
1
- import { sign, len2, dot } from './chunk-755Y4YZS.js';
2
-
3
- // src/flatten.ts
4
- var DEFAULT_FLATTEN_TOLERANCE = 0.5;
5
- var MIN_FLATTEN_TOLERANCE = 1e-6;
6
- var MAX_FLATTEN_DEPTH = 16;
7
- function usableTolerance(tolerance) {
8
- return tolerance > 0 ? tolerance : MIN_FLATTEN_TOLERANCE;
9
- }
10
- function finite6(a, b, c, d, e, f) {
11
- return Number.isFinite(a) && Number.isFinite(b) && Number.isFinite(c) && Number.isFinite(d) && Number.isFinite(e) && Number.isFinite(f);
12
- }
13
- function finite8(a, b, c, d, e, f, g, h) {
14
- return finite6(a, b, c, d, e, f) && Number.isFinite(g) && Number.isFinite(h);
15
- }
16
- function distPointToSegment(px, py, ax, ay, bx, by) {
17
- const dx = bx - ax;
18
- const dy = by - ay;
19
- const len22 = dx * dx + dy * dy;
20
- const along = len22 === 0 ? 0 : ((px - ax) * dx + (py - ay) * dy) / len22;
21
- if (along <= 0) return Math.hypot(px - ax, py - ay);
22
- if (along >= 1) return Math.hypot(px - bx, py - by);
23
- return Math.abs((px - ax) * dy - (py - ay) * dx) / Math.sqrt(len22);
24
- }
25
- function flattenCubic(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out) {
26
- if (!finite8(x0, y0, x1, y1, x2, y2, x3, y3)) {
27
- out.push(x3, y3);
28
- return;
29
- }
30
- flattenCubicRec(x0, y0, x1, y1, x2, y2, x3, y3, usableTolerance(tolerance), out, 0);
31
- }
32
- function flattenCubicRec(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out, depth) {
33
- const d1 = distPointToSegment(x1, y1, x0, y0, x3, y3);
34
- const d2 = distPointToSegment(x2, y2, x0, y0, x3, y3);
35
- if (Math.max(d1, d2) <= tolerance || depth >= MAX_FLATTEN_DEPTH) {
36
- out.push(x3, y3);
37
- return;
38
- }
39
- const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
40
- const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
41
- const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;
42
- const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
43
- const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;
44
- const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;
45
- flattenCubicRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, out, depth + 1);
46
- flattenCubicRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, out, depth + 1);
47
- }
48
- function flattenQuadratic(x0, y0, x1, y1, x2, y2, tolerance, out) {
49
- if (!finite6(x0, y0, x1, y1, x2, y2)) {
50
- out.push(x2, y2);
51
- return;
52
- }
53
- flattenQuadraticRec(x0, y0, x1, y1, x2, y2, usableTolerance(tolerance), out, 0);
54
- }
55
- function flattenQuadraticRec(x0, y0, x1, y1, x2, y2, tolerance, out, depth) {
56
- const d = distPointToSegment(x1, y1, x0, y0, x2, y2);
57
- if (d <= tolerance || depth >= MAX_FLATTEN_DEPTH) {
58
- out.push(x2, y2);
59
- return;
60
- }
61
- const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
62
- const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
63
- const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
64
- flattenQuadraticRec(x0, y0, x01, y01, x012, y012, tolerance, out, depth + 1);
65
- flattenQuadraticRec(x012, y012, x12, y12, x2, y2, tolerance, out, depth + 1);
66
- }
67
- function flattenCubicWithArcLen(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out, arcOut) {
68
- if (!finite8(x0, y0, x1, y1, x2, y2, x3, y3)) {
69
- out.push(x3, y3);
70
- arcOut.push(0);
71
- return 0;
72
- }
73
- return flattenCubicArcRec(x0, y0, x1, y1, x2, y2, x3, y3, usableTolerance(tolerance), out, arcOut, 0, 0);
74
- }
75
- function flattenCubicArcRec(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out, arcOut, accum, depth) {
76
- const d1 = distPointToSegment(x1, y1, x0, y0, x3, y3);
77
- const d2 = distPointToSegment(x2, y2, x0, y0, x3, y3);
78
- if (Math.max(d1, d2) <= tolerance || depth >= MAX_FLATTEN_DEPTH) {
79
- const lastX = out.length >= 2 ? out[out.length - 2] : x0;
80
- const lastY = out.length >= 2 ? out[out.length - 1] : y0;
81
- const seg = Math.hypot(x3 - lastX, y3 - lastY);
82
- accum += seg;
83
- out.push(x3, y3);
84
- arcOut.push(accum);
85
- return accum;
86
- }
87
- const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
88
- const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
89
- const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;
90
- const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
91
- const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;
92
- const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;
93
- accum = flattenCubicArcRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, out, arcOut, accum, depth + 1);
94
- accum = flattenCubicArcRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, out, arcOut, accum, depth + 1);
95
- return accum;
96
- }
97
- function flattenQuadraticWithArcLen(x0, y0, x1, y1, x2, y2, tolerance, out, arcOut) {
98
- if (!finite6(x0, y0, x1, y1, x2, y2)) {
99
- out.push(x2, y2);
100
- arcOut.push(0);
101
- return 0;
102
- }
103
- return flattenQuadraticArcRec(x0, y0, x1, y1, x2, y2, usableTolerance(tolerance), out, arcOut, 0, 0);
104
- }
105
- function flattenQuadraticArcRec(x0, y0, x1, y1, x2, y2, tolerance, out, arcOut, accum, depth) {
106
- const d = distPointToSegment(x1, y1, x0, y0, x2, y2);
107
- if (d <= tolerance || depth >= MAX_FLATTEN_DEPTH) {
108
- const lastX = out.length >= 2 ? out[out.length - 2] : x0;
109
- const lastY = out.length >= 2 ? out[out.length - 1] : y0;
110
- const seg = Math.hypot(x2 - lastX, y2 - lastY);
111
- accum += seg;
112
- out.push(x2, y2);
113
- arcOut.push(accum);
114
- return accum;
115
- }
116
- const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;
117
- const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;
118
- const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;
119
- accum = flattenQuadraticArcRec(x0, y0, x01, y01, x012, y012, tolerance, out, arcOut, accum, depth + 1);
120
- accum = flattenQuadraticArcRec(x012, y012, x12, y12, x2, y2, tolerance, out, arcOut, accum, depth + 1);
121
- return accum;
122
- }
123
-
124
- // src/polyline.ts
125
- function pointInPolygon(coords, px, py, start = 0, end = coords.length >> 1) {
126
- if (end - start < 3) return false;
127
- let inside = false;
128
- for (let i = start, j = end - 1; i < end; j = i++) {
129
- const xi = coords[i * 2], yi = coords[i * 2 + 1];
130
- const xj = coords[j * 2], yj = coords[j * 2 + 1];
131
- const crosses = yi > py !== yj > py && px < (xj - xi) * (py - yi) / (yj - yi) + xi;
132
- if (crosses) inside = !inside;
133
- }
134
- return inside;
135
- }
136
- function segmentsCross(ax, ay, bx, by, cx, cy, dx, dy) {
137
- const d1 = sign((dx - cx) * (ay - cy) - (dy - cy) * (ax - cx));
138
- const d2 = sign((dx - cx) * (by - cy) - (dy - cy) * (bx - cx));
139
- const d3 = sign((bx - ax) * (cy - ay) - (by - ay) * (cx - ax));
140
- const d4 = sign((bx - ax) * (dy - ay) - (by - ay) * (dx - ax));
141
- return d1 !== d2 && d3 !== d4;
142
- }
143
- function pointSegmentDist2(px, py, ax, ay, bx, by) {
144
- const vx = bx - ax, vy = by - ay;
145
- const wx = px - ax, wy = py - ay;
146
- const vv = len2(vx, vy);
147
- let t = vv === 0 ? 0 : dot(wx, wy, vx, vy) / vv;
148
- t = t < 0 ? 0 : t > 1 ? 1 : t;
149
- const dx = px - (ax + t * vx), dy = py - (ay + t * vy);
150
- return len2(dx, dy);
151
- }
152
-
153
- // src/openFill.ts
154
- var fallback = "close";
155
- function setDefaultOpenFill(rule) {
156
- fallback = rule;
157
- }
158
- function defaultOpenFill() {
159
- return fallback;
160
- }
161
- function fillsOpenSubpaths(path) {
162
- return (path.openFill ?? fallback) === "close";
163
- }
164
-
165
- export { DEFAULT_FLATTEN_TOLERANCE, defaultOpenFill, fillsOpenSubpaths, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, pointInPolygon, pointSegmentDist2, segmentsCross, setDefaultOpenFill };
166
- //# sourceMappingURL=chunk-WQMYOCFB.js.map
167
- //# sourceMappingURL=chunk-WQMYOCFB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/flatten.ts","../src/polyline.ts","../src/openFill.ts"],"names":["len2"],"mappings":";;;AAYO,IAAM,yBAAA,GAA4B;AAIzC,IAAM,qBAAA,GAAwB,IAAA;AAM9B,IAAM,iBAAA,GAAoB,EAAA;AAE1B,SAAS,gBAAgB,SAAA,EAA2B;AAClD,EAAA,OAAO,SAAA,GAAY,IAAI,SAAA,GAAY,qBAAA;AACrC;AAEA,SAAS,QAAQ,CAAA,EAAW,CAAA,EAAW,CAAA,EAAW,CAAA,EAAW,GAAW,CAAA,EAAoB;AAC1F,EAAA,OAAO,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,OAAO,QAAA,CAAS,CAAC,CAAA,IAAK,MAAA,CAAO,QAAA,CAAS,CAAC,KAC/D,MAAA,CAAO,QAAA,CAAS,CAAC,CAAA,IAAK,MAAA,CAAO,SAAS,CAAC,CAAA,IAAK,MAAA,CAAO,QAAA,CAAS,CAAC,CAAA;AACpE;AAEA,SAAS,OAAA,CACP,GAAW,CAAA,EAAW,CAAA,EAAW,GACjC,CAAA,EAAW,CAAA,EAAW,GAAW,CAAA,EACxB;AACT,EAAA,OAAO,OAAA,CAAQ,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAG,CAAC,CAAA,IAAK,MAAA,CAAO,QAAA,CAAS,CAAC,CAAA,IAAK,MAAA,CAAO,SAAS,CAAC,CAAA;AAC7E;AAOA,SAAS,mBAAmB,EAAA,EAAY,EAAA,EAAY,EAAA,EAAY,EAAA,EAAY,IAAY,EAAA,EAAoB;AAC1G,EAAA,MAAM,KAAK,EAAA,GAAK,EAAA;AAChB,EAAA,MAAM,KAAK,EAAA,GAAK,EAAA;AAChB,EAAA,MAAMA,KAAAA,GAAO,EAAA,GAAK,EAAA,GAAK,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T;AAIO,SAAS,kBAAkB,IAAA,EAA4B;AAC5D,EAAA,OAAA,CAAQ,IAAA,CAAK,YAAY,QAAA,MAAc,OAAA;AACzC","file":"chunk-WQMYOCFB.js","sourcesContent":["/**\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/**\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].\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): 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), 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 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 if (Math.max(d1, d2) <= tolerance || 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, out, arcOut, accum, depth + 1);\n accum = flattenCubicArcRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, 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): 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), 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 out: number[],\n arcOut: number[],\n accum: number,\n depth: number,\n): number {\n const d = distPointToSegment(x1, y1, x0, y0, x2, y2);\n if (d <= tolerance || 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, out, arcOut, accum, depth + 1);\n accum = flattenQuadraticArcRec(x012, y012, x12, y12, x2, y2, tolerance, 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,34 +0,0 @@
1
- import { cubicEvalAt, splitCubicAt } from './chunk-URQMDR6Q.js';
2
-
3
- // src/paths/cubicMath.ts
4
- function cubicPointAt(p0, p1, p2, p3, t) {
5
- const [x, y] = cubicEvalAt(p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, t);
6
- return { x, y };
7
- }
8
- function splitCubicAtT(p0, p1, p2, p3, t) {
9
- const [l, r] = splitCubicAt(p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, t);
10
- const quad = (c) => [{ x: c[0], y: c[1] }, { x: c[2], y: c[3] }, { x: c[4], y: c[5] }, { x: c[6], y: c[7] }];
11
- return { left: quad(l), right: quad(r) };
12
- }
13
- function fitCubicThroughDeletion(prev, next) {
14
- const dx = next.x - prev.x;
15
- const dy = next.y - prev.y;
16
- const dist = Math.sqrt(dx * dx + dy * dy);
17
- const c1DirX = prev.outHandle ? prev.outHandle.x - prev.x : dx;
18
- const c1DirY = prev.outHandle ? prev.outHandle.y - prev.y : dy;
19
- const c1 = controlOnSide(prev, c1DirX, c1DirY, dist, 1 / 3);
20
- const c2DirX = next.inHandle ? next.inHandle.x - next.x : -dx;
21
- const c2DirY = next.inHandle ? next.inHandle.y - next.y : -dy;
22
- const c2 = controlOnSide(next, c2DirX, c2DirY, dist, 1 / 3);
23
- return { c1, c2 };
24
- }
25
- function controlOnSide(anchor, dirX, dirY, dist, fraction) {
26
- const targetDist = dist * fraction;
27
- const len = Math.hypot(dirX, dirY) || 1;
28
- const ux = dirX / len, uy = dirY / len;
29
- return { x: anchor.x + ux * targetDist, y: anchor.y + uy * targetDist };
30
- }
31
-
32
- export { cubicPointAt, fitCubicThroughDeletion, splitCubicAtT };
33
- //# sourceMappingURL=chunk-XS6ERH3X.js.map
34
- //# sourceMappingURL=chunk-XS6ERH3X.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/paths/cubicMath.ts"],"names":[],"mappings":";;;AAQO,SAAS,YAAA,CAAa,EAAA,EAAW,EAAA,EAAW,EAAA,EAAW,IAAW,CAAA,EAAkB;AACzF,EAAA,MAAM,CAAC,GAAG,CAAC,CAAA,GAAI,YAAY,EAAA,CAAG,CAAA,EAAG,GAAG,CAAA,EAAG,EAAA,CAAG,GAAG,EAAA,CAAG,CAAA,EAAG,GAAG,CAAA,EAAG,EAAA,CAAG,GAAG,EAAA,CAAG,CAAA,EAAG,EAAA,CAAG,CAAA,EAAG,CAAC,CAAA;AAC5E,EAAA,OAAO,EAAE,GAAG,CAAA,EAAE;AAChB;AAIO,SAAS,aAAA,CACd,EAAA,EAAW,EAAA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A;AAC5D,EAAA,MAAM,KAAK,aAAA,CAAc,IAAA,EAAM,QAAQ,MAAA,EAAQ,IAAA,EAAM,IAAI,CAAC,CAAA;AAE1D,EAAA,MAAM,MAAA,GAAS,KAAK,QAAA,GAAW,IAAA,CAAK,SAAS,CAAA,GAAI,IAAA,CAAK,IAAI,CAAC,EAAA;AAC3D,EAAA,MAAM,MAAA,GAAS,KAAK,QAAA,GAAW,IAAA,CAAK,SAAS,CAAA,GAAI,IAAA,CAAK,IAAI,CAAC,EAAA;AAC3D,EAAA,MAAM,KAAK,aAAA,CAAc,IAAA,EAAM,QAAQ,MAAA,EAAQ,IAAA,EAAM,IAAI,CAAC,CAAA;AAC1D,EAAA,OAAO,EAAE,IAAI,EAAA,EAAG;AAClB;AAEA,SAAS,aAAA,CACP,MAAA,EACA,IAAA,EACA,IAAA,EACA,MACA,QAAA,EACO;AACP,EAAA,MAAM,aAAa,IAAA,GAAO,QAAA;AAC1B,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,KAAA,CAAM,IAAA,EAAM,IAAI,CAAA,IAAK,CAAA;AACtC,EAAA,MAAM,EAAA,GAAK,IAAA,GAAO,GAAA,EAAK,EAAA,GAAK,IAAA,GAAO,GAAA;AACnC,EAAA,OAAO,EAAE,CAAA,EAAG,MAAA,CAAO,CAAA,GAAI,EAAA,GAAK,YAAY,CAAA,EAAG,MAAA,CAAO,CAAA,GAAI,EAAA,GAAK,UAAA,EAAW;AACxE","file":"chunk-XS6ERH3X.js","sourcesContent":["import { cubicEvalAt, splitCubicAt, type CubicCoords } from '../curve';\nimport type { PenAnchor } from './anchors';\n\n/** A 2D point, the shape the point-taking path helpers read and return. */\nexport interface Point { x: number; y: number; }\n\n/** Point on the cubic Bezier (p0, p1, p2, p3) at parameter t. The point-shaped\n * face of geom's `cubicEvalAt`. */\nexport function cubicPointAt(p0: Point, p1: Point, p2: Point, p3: Point, t: number): Point {\n const [x, y] = cubicEvalAt(p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, t);\n return { x, y };\n}\n\n/** De Casteljau subdivision of a cubic at parameter t. The point-shaped face\n * of geom's `splitCubicAt`; `left[3]` and `right[0]` are the point at t. */\nexport function splitCubicAtT(\n p0: Point, p1: Point, p2: Point, p3: Point,\n t: number,\n): { left: [Point, Point, Point, Point]; right: [Point, Point, Point, Point] } {\n const [l, r] = splitCubicAt(p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, t);\n const quad = (c: CubicCoords): [Point, Point, Point, Point] =>\n [{ x: c[0], y: c[1] }, { x: c[2], y: c[3] }, { x: c[4], y: c[5] }, { x: c[6], y: c[7] }];\n return { left: quad(l), right: quad(r) };\n}\n\n/**\n * When an interior anchor is deleted, the two flanking segments fuse into one\n * cubic. We pick controls c1 and c2 that:\n * - lie along prev's outHandle direction (if present)\n * - lie along next's inHandle direction (if present)\n * - are placed at roughly 1/3 and 2/3 of the prev→next distance\n * Fallbacks: missing handles use prev→next as the direction.\n *\n * This is an approximate fit — the new curve will shift slightly from the\n * original two-segment path. Acceptable per spec.\n */\nexport function fitCubicThroughDeletion(\n prev: PenAnchor,\n next: PenAnchor,\n): { c1: Point; c2: Point } {\n const dx = next.x - prev.x;\n const dy = next.y - prev.y;\n const dist = Math.sqrt(dx * dx + dy * dy);\n // c1: project along outHandle direction (or prev→next fallback) at 1/3 of dist.\n const c1DirX = prev.outHandle ? prev.outHandle.x - prev.x : dx;\n const c1DirY = prev.outHandle ? prev.outHandle.y - prev.y : dy;\n const c1 = controlOnSide(prev, c1DirX, c1DirY, dist, 1 / 3);\n // c2: project along inHandle direction (or next→prev fallback) at 1/3 of dist.\n const c2DirX = next.inHandle ? next.inHandle.x - next.x : -dx;\n const c2DirY = next.inHandle ? next.inHandle.y - next.y : -dy;\n const c2 = controlOnSide(next, c2DirX, c2DirY, dist, 1 / 3);\n return { c1, c2 };\n}\n\nfunction controlOnSide(\n anchor: PenAnchor,\n dirX: number,\n dirY: number,\n dist: number,\n fraction: number,\n): Point {\n const targetDist = dist * fraction;\n const len = Math.hypot(dirX, dirY) || 1;\n const ux = dirX / len, uy = dirY / len;\n return { x: anchor.x + ux * targetDist, y: anchor.y + uy * targetDist };\n}\n"]}
@@ -1,116 +0,0 @@
1
- import { P as PolygonPath, a as Path } from './path-Bf9KeVxC.js';
2
-
3
- /**
4
- * Counts the path anchors used by the per-anchor coloring surface. An
5
- * "anchor" is the destination point of a path command: M, L, C, Q each
6
- * contribute one (the (x, y) where the pen ends up); Z contributes none
7
- * (it closes back to the subpath's first M). RectPath has four implicit
8
- * anchors — the corners — matching its M/L/L/L/Z stroke tessellation.
9
- *
10
- * Consumers use this to size their per-anchor color array; the renderer
11
- * uses it to validate the array length in dev builds.
12
- */
13
-
14
- /** One anchor of an editable path: its on-curve point plus the two control
15
- * handles that shape the segments either side of it. Handles are in the same
16
- * space as the point, and absent when the adjoining segment is straight. */
17
- interface PenAnchor {
18
- x: number;
19
- y: number;
20
- inHandle?: {
21
- x: number;
22
- y: number;
23
- };
24
- outHandle?: {
25
- x: number;
26
- y: number;
27
- };
28
- }
29
- /**
30
- * Derive a per-subpath anchor model from a PolygonPath. Subpaths split on
31
- * every `M` command; a subpath is closed iff it ends with `Z`.
32
- *
33
- * Cubic-segment control points become the outHandle of the previous anchor
34
- * and the inHandle of the next anchor. A closed subpath whose last curve ends
35
- * exactly on its first point holds that point twice; the two are one anchor,
36
- * and the curve's second control is that anchor's inHandle. Quadratic segments are upgraded to
37
- * cubics (each control reused for both adjacent handles) — this loses no
38
- * geometry. Linear segments produce anchors with no handles.
39
- */
40
- declare function pathToAnchors(path: PolygonPath): {
41
- anchors: PenAnchor[][];
42
- closed: boolean[];
43
- };
44
- /**
45
- * Serialize the per-subpath anchor model back to a PolygonPath. Inverse of
46
- * `pathToAnchors`. Curve-vs-line decision per segment:
47
- * - Both adjacent handles absent → straight L segment.
48
- * - Either handle present → C segment, with missing handles defaulting to
49
- * the anchor point itself (degenerate but valid; renders as a near-line).
50
- * Given `like`, the path being reshaped, the result keeps its fill rules.
51
- */
52
- declare function anchorsToPath(anchors: PenAnchor[][], closed: boolean[], like?: PolygonPath): PolygonPath;
53
- /**
54
- * Returns true if the anchor's in-handle and out-handle are collinear with
55
- * the anchor point, indicating "smooth" (mirror-drag) behavior. Detected via
56
- * the magnitude of the normalized cross product of the two handle vectors.
57
- *
58
- * Edge cases:
59
- * - Missing in or out handle → false (corner by definition).
60
- * - Either handle at zero distance from anchor → false.
61
- */
62
- declare function isAnchorSmooth(a: PenAnchor): boolean;
63
- /** How many anchors a path has. Matches the per-anchor arrays the renderer
64
- * expects for `vertexColors`. */
65
- declare function countPathAnchors(path: Path): number;
66
- /** The segment `(sub, segIdx)` as its two end anchors, or null when it
67
- * doesn't exist. `segIdx === sub.length - 1` names a closed subpath's
68
- * closing segment, which runs from the last anchor back to the first. */
69
- declare function segmentEnds(anchors: readonly PenAnchor[][], closed: readonly boolean[] | undefined, sub: number, segIdx: number): {
70
- a: PenAnchor;
71
- b: PenAnchor;
72
- } | null;
73
- /** Whether the segment from `a` to `b` is a straight line (no handles). */
74
- declare function isStraightSegment(a: PenAnchor, b: PenAnchor): boolean;
75
- /** The segment of a decoded path nearest `(wx, wy)`, and the parameter `t`
76
- * on it closest to that point. Pass `closed` (from `pathToAnchors`) to
77
- * include each closed subpath's closing segment, reported as
78
- * `segIdx === sub.length - 1`. `t` spans `[0, 1]`, endpoints included.
79
- * Returns `null` only when there are no segments. */
80
- declare function nearestSegmentT(anchors: PenAnchor[][], wx: number, wy: number, closed?: readonly boolean[]): {
81
- sub: number;
82
- segIdx: number;
83
- t: number;
84
- } | null;
85
-
86
- /** A 2D point, the shape the point-taking path helpers read and return. */
87
- interface Point {
88
- x: number;
89
- y: number;
90
- }
91
- /** Point on the cubic Bezier (p0, p1, p2, p3) at parameter t. The point-shaped
92
- * face of geom's `cubicEvalAt`. */
93
- declare function cubicPointAt(p0: Point, p1: Point, p2: Point, p3: Point, t: number): Point;
94
- /** De Casteljau subdivision of a cubic at parameter t. The point-shaped face
95
- * of geom's `splitCubicAt`; `left[3]` and `right[0]` are the point at t. */
96
- declare function splitCubicAtT(p0: Point, p1: Point, p2: Point, p3: Point, t: number): {
97
- left: [Point, Point, Point, Point];
98
- right: [Point, Point, Point, Point];
99
- };
100
- /**
101
- * When an interior anchor is deleted, the two flanking segments fuse into one
102
- * cubic. We pick controls c1 and c2 that:
103
- * - lie along prev's outHandle direction (if present)
104
- * - lie along next's inHandle direction (if present)
105
- * - are placed at roughly 1/3 and 2/3 of the prev→next distance
106
- * Fallbacks: missing handles use prev→next as the direction.
107
- *
108
- * This is an approximate fit — the new curve will shift slightly from the
109
- * original two-segment path. Acceptable per spec.
110
- */
111
- declare function fitCubicThroughDeletion(prev: PenAnchor, next: PenAnchor): {
112
- c1: Point;
113
- c2: Point;
114
- };
115
-
116
- export { type Point as P, type PenAnchor as a, anchorsToPath as b, countPathAnchors as c, cubicPointAt as d, isStraightSegment as e, fitCubicThroughDeletion as f, splitCubicAtT as g, isAnchorSmooth as i, nearestSegmentT as n, pathToAnchors as p, segmentEnds as s };
@@ -1,44 +0,0 @@
1
- /**
2
- * Path data model: the vector-graphics primitive every weasel package uses as
3
- * its canonical shape. An SVG-style command stream covers lines, polygons,
4
- * beziers and multi-contour shapes (the inner hole of an "O") under one type.
5
- *
6
- * Storage: command codes in a `Uint8Array`, parameters in a `Float32Array`.
7
- * Each command consumes a fixed number of coords (`PATH_CMD_LENGTHS`); walkers
8
- * step both arrays in lockstep.
9
- */
10
- /** Fill rule used by polygon path hit-testing and `ctx.fill()`. */
11
- type PathFillRule = 'nonzero' | 'evenodd';
12
- /** Whether a fill closes an open subpath with a straight edge back to its
13
- * start, as SVG and canvas do (`'close'`), or leaves it unfilled (`'none'`). */
14
- type PathOpenFill = 'close' | 'none';
15
- /**
16
- * Polygon path with arbitrary contours and optional bezier segments.
17
- * Multi-contour: each `M` opens a new subpath; `Z` closes the current one.
18
- * An open subpath (no `Z`) strokes as a polyline; `openFill` says whether it
19
- * fills.
20
- */
21
- interface PolygonPath {
22
- kind: 'polygon';
23
- commands: Uint8Array;
24
- coords: Float32Array;
25
- fillRule: PathFillRule;
26
- /** Absent, the engine default: see `setDefaultOpenFill`. */
27
- openFill?: PathOpenFill;
28
- }
29
- /**
30
- * Axis-aligned rectangle. Fast path for the (very common) case where the
31
- * shape is just a rect — preserves O(1) bounds and hit-test, avoids the
32
- * polygon kernel entirely.
33
- */
34
- interface RectPath {
35
- kind: 'rect';
36
- x: number;
37
- y: number;
38
- width: number;
39
- height: number;
40
- }
41
- /** Canonical path shape — either an axis-aligned rect (fast path) or a polygon command stream. */
42
- type Path = PolygonPath | RectPath;
43
-
44
- export type { PolygonPath as P, RectPath as R, Path as a, PathOpenFill as b, PathFillRule as c };