@weasel-js/geom 1.11.0 → 1.11.1
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.d.ts +3 -1
- package/dist/booleans/index.js +138 -11
- package/dist/booleans/index.js.map +1 -1
- package/dist/{chunk-7KLJZFBY.js → chunk-4Y67BZL5.js} +3 -3
- package/dist/{chunk-7KLJZFBY.js.map → chunk-4Y67BZL5.js.map} +1 -1
- package/dist/{chunk-HGF5OVEN.js → chunk-6FGQML7D.js} +29 -6
- package/dist/chunk-6FGQML7D.js.map +1 -0
- package/dist/{chunk-6XSJY3TC.js → chunk-7F66PQCJ.js} +3 -3
- package/dist/{chunk-6XSJY3TC.js.map → chunk-7F66PQCJ.js.map} +1 -1
- package/dist/{chunk-J2O2B54M.js → chunk-EAKE3N7W.js} +13 -9
- package/dist/chunk-EAKE3N7W.js.map +1 -0
- package/dist/{chunk-SASMXDBE.js → chunk-LRVPK7HI.js} +83 -35
- package/dist/chunk-LRVPK7HI.js.map +1 -0
- package/dist/index.d.ts +47 -3
- package/dist/index.js +331 -28
- package/dist/index.js.map +1 -1
- package/dist/nd/index.d.ts +2 -1
- package/dist/nd/index.js +44 -29
- package/dist/nd/index.js.map +1 -1
- package/dist/tessellate/index.js +3 -3
- package/dist/warp/index.d.ts +7 -5
- package/dist/warp/index.js +145 -13
- package/dist/warp/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-HGF5OVEN.js.map +0 -1
- package/dist/chunk-J2O2B54M.js.map +0 -1
- package/dist/chunk-SASMXDBE.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flatten.ts","../src/polyline.ts","../src/openFill.ts","../src/paths/schneiderFit.ts","../src/paths/cornerShape.ts","../src/paths/cornerSegments.ts","../src/paths/corners.ts"],"names":["len2","fit","sub","unit"],"mappings":";;;;AAYO,IAAM,yBAAA,GAA4B;AAIzC,IAAM,qBAAA,GAAw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I,EAAA,EAAI,EAAE,CAAA,GAAI,IAAA;AACvD,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,EAAA,CAAG,CAAA,GAAI,GAAG,CAAA,EAAG,EAAA,CAAG,CAAA,GAAI,EAAA,CAAG,CAAC,CAAA;AACjD,EAAA,MAAM,GAAA,GAAM,CAAC,KAAA,IAAS,IAAA,CAAK,MAAM,KAAA,CAAM,CAAA,GAAI,CAAA,CAAE,CAAA,EAAG,KAAA,CAAM,CAAA,GAAI,CAAA,CAAE,CAAC,IAAI,CAAA,GAAI,KAAA;AACrE,EAAA,OAAO,EAAE,OAAO,EAAA,EAAI,GAAA,EAAK,IAAI,KAAA,EAAO,GAAA,GAAM,IAAI,KAAA,EAAM;AACtD;AAIA,SAAS,WAAA,CAAY,CAAA,EAAU,EAAA,EAAW,CAAA,EAAU,EAAA,EAAyB;AAC3E,EAAA,MAAM,MAAM,EAAA,CAAG,CAAA,GAAI,GAAG,CAAA,GAAI,EAAA,CAAG,IAAI,EAAA,CAAG,CAAA;AACpC,EAAA,IAAI,IAAA,CAAK,GAAA,CAAI,GAAG,CAAA,GAAI,MAAM,OAAO,IAAA;AACjC,EAAA,MAAM,CAAA,GAAA,CAAA,CAAM,CAAA,CAAE,CAAA,GAAI,CAAA,CAAE,CAAA,IAAK,EAAA,CAAG,CAAA,GAAA,CAAK,CAAA,CAAE,CAAA,GAAI,CAAA,CAAE,CAAA,IAAK,EAAA,CAAG,CAAA,IAAK,GAAA;AACtD,EAAA,OAAO,EAAE,CAAA,EAAG,CAAA,CAAE,CAAA,GAAI,EAAA,CAAG,CAAA,GAAI,CAAA,EAAG,CAAA,EAAG,CAAA,CAAE,CAAA,GAAI,EAAA,CAAG,CAAA,GAAI,CAAA,EAAE;AAChD","file":"chunk-EAKE3N7W.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/** 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","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"]}
|
|
@@ -1,15 +1,82 @@
|
|
|
1
|
-
import { pointInPolygon, resolveCorners, fillsOpenSubpaths, flattenCubicWithArcLen, flattenQuadraticWithArcLen, DEFAULT_FLATTEN_TOLERANCE } from './chunk-
|
|
1
|
+
import { pointInPolygon, resolveCorners, fillsOpenSubpaths, flattenCubicWithArcLen, flattenQuadraticWithArcLen, DEFAULT_FLATTEN_TOLERANCE } from './chunk-EAKE3N7W.js';
|
|
2
2
|
import { rectToContour, forEachSegment, PATH_Z, PATH_C, PATH_Q, PATH_L, PATH_M } from './chunk-B53BERKG.js';
|
|
3
3
|
import earcut from 'earcut';
|
|
4
4
|
|
|
5
|
+
// src/tessellate/sweep.ts
|
|
6
|
+
var LOW_WORD = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1 ? 0 : 1;
|
|
7
|
+
var KEY_SLACK = 2 ** -19;
|
|
8
|
+
function forEachCrossing(ends, n, visit) {
|
|
9
|
+
const keys = sortedMinX(ends, n);
|
|
10
|
+
const index = new Uint32Array(keys.buffer);
|
|
11
|
+
for (let i = 0; i < n; i++) {
|
|
12
|
+
const ei = index[i * 2 + LOW_WORD], e = ei * 4;
|
|
13
|
+
const ex0 = ends[e], ey0 = ends[e + 1], ex1 = ends[e + 2], ey1 = ends[e + 3];
|
|
14
|
+
const maxX = Math.max(ex0, ex1);
|
|
15
|
+
const stop = maxX + Math.abs(maxX) * KEY_SLACK + 1e-300;
|
|
16
|
+
for (let j = i + 1; j < n; j++) {
|
|
17
|
+
if (keys[j] > stop) break;
|
|
18
|
+
const fi = index[j * 2 + LOW_WORD], f = fi * 4;
|
|
19
|
+
const fx0 = ends[f], fy0 = ends[f + 1], fx1 = ends[f + 2], fy1 = ends[f + 3];
|
|
20
|
+
if (Math.max(ey0, ey1) < Math.min(fy0, fy1)) continue;
|
|
21
|
+
if (Math.max(fy0, fy1) < Math.min(ey0, ey1)) continue;
|
|
22
|
+
const hit = crossingParams(ex0, ey0, ex1, ey1, fx0, fy0, fx1, fy1);
|
|
23
|
+
if (hit && visit(ei, fi, hit[0], hit[1])) return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function sortedMinX(ends, n) {
|
|
28
|
+
const keys = new Float64Array(n);
|
|
29
|
+
const index = new Uint32Array(keys.buffer);
|
|
30
|
+
for (let e = 0; e < n; e++) {
|
|
31
|
+
keys[e] = Math.min(ends[e * 4], ends[e * 4 + 2]);
|
|
32
|
+
index[e * 2 + LOW_WORD] = e;
|
|
33
|
+
}
|
|
34
|
+
return keys.sort();
|
|
35
|
+
}
|
|
36
|
+
function crossingParams(ex0, ey0, ex1, ey1, fx0, fy0, fx1, fy1) {
|
|
37
|
+
const rx = ex1 - ex0, ry = ey1 - ey0;
|
|
38
|
+
const qx = fx1 - fx0, qy = fy1 - fy0;
|
|
39
|
+
const den = rx * qy - ry * qx;
|
|
40
|
+
if (den === 0) return null;
|
|
41
|
+
const dx = fx0 - ex0, dy = fy0 - ey0;
|
|
42
|
+
const s = (dx * qy - dy * qx) / den;
|
|
43
|
+
const u = (dx * ry - dy * rx) / den;
|
|
44
|
+
const lo = 1e-9, hi = 1 - 1e-9;
|
|
45
|
+
if (s <= lo || s >= hi || u <= lo || u >= hi) return null;
|
|
46
|
+
return [s, u];
|
|
47
|
+
}
|
|
48
|
+
|
|
5
49
|
// src/tessellate/crossings.ts
|
|
6
50
|
var keyOf = (n) => `${n.x},${n.y}`;
|
|
7
51
|
function resolveCrossings(flat, always = false) {
|
|
52
|
+
if (!always && !anyCrossing(flat)) return null;
|
|
8
53
|
const edges = edgesOf(flat);
|
|
9
|
-
|
|
54
|
+
cutAtCrossings(edges);
|
|
10
55
|
const pieces = boundaryPieces(edges);
|
|
11
56
|
return loopsToContours(chainLoops(pieces));
|
|
12
57
|
}
|
|
58
|
+
function anyCrossing(flat) {
|
|
59
|
+
const { coords, contourStarts } = flat;
|
|
60
|
+
const total = coords.length / 2;
|
|
61
|
+
const ends = new Float64Array(total * 4);
|
|
62
|
+
let n = 0;
|
|
63
|
+
contourStarts.forEach((start, c) => {
|
|
64
|
+
const end = c + 1 < contourStarts.length ? contourStarts[c + 1] : total;
|
|
65
|
+
for (let i = start; i < end; i++) {
|
|
66
|
+
const j = i + 1 < end ? i + 1 : start;
|
|
67
|
+
const x0 = coords[i * 2], y0 = coords[i * 2 + 1], x1 = coords[j * 2], y1 = coords[j * 2 + 1];
|
|
68
|
+
if (x0 === x1 && y0 === y1) continue;
|
|
69
|
+
ends[n * 4] = x0;
|
|
70
|
+
ends[n * 4 + 1] = y0;
|
|
71
|
+
ends[n * 4 + 2] = x1;
|
|
72
|
+
ends[n * 4 + 3] = y1;
|
|
73
|
+
n++;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
let found = false;
|
|
77
|
+
forEachCrossing(ends, n, () => found = true);
|
|
78
|
+
return found;
|
|
79
|
+
}
|
|
13
80
|
function edgesOf(flat) {
|
|
14
81
|
const { coords, contourStarts, anchorA, anchorB, anchorT } = flat;
|
|
15
82
|
const total = coords.length / 2;
|
|
@@ -25,37 +92,18 @@ function edgesOf(flat) {
|
|
|
25
92
|
return edges;
|
|
26
93
|
}
|
|
27
94
|
function cutAtCrossings(edges) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const e =
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
e.cuts.push({ s: hit.s, node: hit.node });
|
|
41
|
-
f.cuts.push({ s: hit.u, node: hit.node });
|
|
42
|
-
found = true;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return found;
|
|
46
|
-
}
|
|
47
|
-
function crossing(e, f) {
|
|
48
|
-
const rx = e.to.x - e.from.x, ry = e.to.y - e.from.y;
|
|
49
|
-
const qx = f.to.x - f.from.x, qy = f.to.y - f.from.y;
|
|
50
|
-
const den = rx * qy - ry * qx;
|
|
51
|
-
if (den === 0) return null;
|
|
52
|
-
const dx = f.from.x - e.from.x, dy = f.from.y - e.from.y;
|
|
53
|
-
const s = (dx * qy - dy * qx) / den;
|
|
54
|
-
const u = (dx * ry - dy * rx) / den;
|
|
55
|
-
const lo = 1e-9, hi = 1 - 1e-9;
|
|
56
|
-
if (s <= lo || s >= hi || u <= lo || u >= hi) return null;
|
|
57
|
-
const x = e.from.x + rx * s, y = e.from.y + ry * s;
|
|
58
|
-
return { s, u, node: { x, y, ...anchorsAlong(e, s) } };
|
|
95
|
+
const ends = new Float64Array(edges.length * 4);
|
|
96
|
+
edges.forEach(({ from, to }, i) => ends.set([from.x, from.y, to.x, to.y], i * 4));
|
|
97
|
+
forEachCrossing(ends, edges.length, (ei, fi, s, u) => {
|
|
98
|
+
const e = edges[ei];
|
|
99
|
+
const node = {
|
|
100
|
+
x: e.from.x + (e.to.x - e.from.x) * s,
|
|
101
|
+
y: e.from.y + (e.to.y - e.from.y) * s,
|
|
102
|
+
...anchorsAlong(e, s)
|
|
103
|
+
};
|
|
104
|
+
e.cuts.push({ s, node });
|
|
105
|
+
edges[fi].cuts.push({ s: u, node });
|
|
106
|
+
});
|
|
59
107
|
}
|
|
60
108
|
function anchorsAlong(e, s) {
|
|
61
109
|
const { from, to } = e;
|
|
@@ -439,5 +487,5 @@ function tessellateEvenoddWithAnchors(coords, contourStarts, anchorA, anchorB, a
|
|
|
439
487
|
}
|
|
440
488
|
|
|
441
489
|
export { flattenPolygon, nestRings, resolveCrossings, tessellate };
|
|
442
|
-
//# sourceMappingURL=chunk-
|
|
443
|
-
//# sourceMappingURL=chunk-
|
|
490
|
+
//# sourceMappingURL=chunk-LRVPK7HI.js.map
|
|
491
|
+
//# sourceMappingURL=chunk-LRVPK7HI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tessellate/sweep.ts","../src/tessellate/crossings.ts","../src/tessellate/nesting.ts","../src/tessellate/tessellate.ts"],"names":[],"mappings":";;;;;AAEA,IAAM,QAAA,GAAW,IAAI,UAAA,CAAW,IAAI,YAAY,CAAC,CAAC,CAAC,CAAA,CAAE,MAAM,CAAA,CAAE,CAAC,CAAA,KAAM,IAAI,CAAA,GAAI,CAAA;AAG5E,IAAM,YAAY,CAAA,IAAK,GAAA;AAQhB,SAAS,eAAA,CACd,IAAA,EACA,CAAA,EACA,KAAA,EACM;AACN,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,IAAA,EAAM,CAAC,CAAA;AAC/B,EAAA,MAAM,KAAA,GAAQ,IAAI,WAAA,CAAY,IAAA,CAAK,MAAM,CAAA;AACzC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,CAAA,EA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AACF","file":"chunk-LRVPK7HI.js","sourcesContent":["/** Finding where straight segments cross, by a sweep along x. */\n\nconst LOW_WORD = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1 ? 0 : 1;\n/** How far, relative to itself, writing an index into a key's low word can\n * move it. A zero key becomes a subnormal, which the sweep's 1e-300 covers. */\nconst KEY_SLACK = 2 ** -19;\n\n/**\n * Call `visit` for every pair of segments that cross inside both, with how far\n * along each the crossing lies; `visit` returns `true` to stop. `ends` holds\n * `n` segments as `x0, y0, x1, y1`. Of each pair, `e` is the one whose\n * smallest x is smaller.\n */\nexport function forEachCrossing(\n ends: Float64Array,\n n: number,\n visit: (e: number, f: number, s: number, u: number) => boolean | void,\n): void {\n const keys = sortedMinX(ends, n);\n const index = new Uint32Array(keys.buffer);\n for (let i = 0; i < n; i++) {\n const ei = index[i * 2 + LOW_WORD], e = ei * 4;\n const ex0 = ends[e], ey0 = ends[e + 1], ex1 = ends[e + 2], ey1 = ends[e + 3];\n const maxX = Math.max(ex0, ex1);\n const stop = maxX + Math.abs(maxX) * KEY_SLACK + 1e-300;\n for (let j = i + 1; j < n; j++) {\n if (keys[j] > stop) break;\n const fi = index[j * 2 + LOW_WORD], f = fi * 4;\n const fx0 = ends[f], fy0 = ends[f + 1], fx1 = ends[f + 2], fy1 = ends[f + 3];\n if (Math.max(ey0, ey1) < Math.min(fy0, fy1)) continue;\n if (Math.max(fy0, fy1) < Math.min(ey0, ey1)) continue;\n const hit = crossingParams(ex0, ey0, ex1, ey1, fx0, fy0, fx1, fy1);\n if (hit && visit(ei, fi, hit[0], hit[1])) return;\n }\n }\n}\n\n/**\n * Each segment's smallest x in ascending order, with the segment's index\n * written into the key's low 32 bits, read back through a `Uint32Array` view.\n * A native numeric sort runs about three times as fast as one through a\n * comparator; the index moves each key by under `KEY_SLACK` of itself, which\n * the sweep's stop allows for.\n */\nfunction sortedMinX(ends: Float64Array, n: number): Float64Array {\n const keys = new Float64Array(n);\n const index = new Uint32Array(keys.buffer);\n for (let e = 0; e < n; e++) {\n keys[e] = Math.min(ends[e * 4], ends[e * 4 + 2]);\n index[e * 2 + LOW_WORD] = e;\n }\n return keys.sort();\n}\n\n/** Where segment E crosses segment F inside both, as fractions along each. */\nfunction crossingParams(\n ex0: number, ey0: number, ex1: number, ey1: number,\n fx0: number, fy0: number, fx1: number, fy1: number,\n): [number, number] | null {\n const rx = ex1 - ex0, ry = ey1 - ey0;\n const qx = fx1 - fx0, qy = fy1 - fy0;\n const den = rx * qy - ry * qx;\n if (den === 0) return null;\n const dx = fx0 - ex0, dy = fy0 - ey0;\n const s = (dx * qy - dy * qx) / den;\n const u = (dx * ry - dy * rx) / den;\n const lo = 1e-9, hi = 1 - 1e-9;\n if (s <= lo || s >= hi || u <= lo || u >= hi) return null;\n return [s, u];\n}\n","/** Rebuilding outlines as the non-crossing boundary of their nonzero fill. */\n\nimport { forEachCrossing } from './sweep';\n\n/** Flattened contours with each vertex's anchor parameterization. */\nexport interface FlattenedContours {\n coords: number[];\n contourStarts: number[];\n anchorA: number[];\n anchorB: number[];\n anchorT: number[];\n}\n\ninterface Node {\n x: number;\n y: number;\n a: number;\n b: number;\n t: number;\n}\n\ninterface Edge {\n from: Node;\n to: Node;\n /** Where crossings cut this edge, by parameter along it. */\n cuts: { s: number; node: Node }[];\n}\n\ninterface Piece {\n from: Node;\n to: Node;\n}\n\nconst keyOf = (n: Node): string => `${n.x},${n.y}`;\n\n/**\n * The boundary of `flat`'s nonzero fill as loops that do not cross, each with\n * the fill on its left, or `null` when no two edges cross and `always` is\n * not set.\n */\nexport function resolveCrossings(flat: FlattenedContours, always = false): FlattenedContours | null {\n if (!always && !anyCrossing(flat)) return null;\n const edges = edgesOf(flat);\n cutAtCrossings(edges);\n const pieces = boundaryPieces(edges);\n return loopsToContours(chainLoops(pieces));\n}\n\n/** Whether any two edges of `flat` cross. Every nonzero fill asks this, and\n * most cross nowhere, so it reads the coordinates without building edges. */\nexport function anyCrossing(flat: FlattenedContours): boolean {\n const { coords, contourStarts } = flat;\n const total = coords.length / 2;\n const ends = new Float64Array(total * 4);\n let n = 0;\n contourStarts.forEach((start, c) => {\n const end = c + 1 < contourStarts.length ? contourStarts[c + 1] : total;\n for (let i = start; i < end; i++) {\n const j = i + 1 < end ? i + 1 : start;\n const x0 = coords[i * 2], y0 = coords[i * 2 + 1], x1 = coords[j * 2], y1 = coords[j * 2 + 1];\n if (x0 === x1 && y0 === y1) continue;\n ends[n * 4] = x0; ends[n * 4 + 1] = y0; ends[n * 4 + 2] = x1; ends[n * 4 + 3] = y1;\n n++;\n }\n });\n let found = false;\n forEachCrossing(ends, n, () => (found = true));\n return found;\n}\n\nfunction edgesOf(flat: FlattenedContours): Edge[] {\n const { coords, contourStarts, anchorA, anchorB, anchorT } = flat;\n const total = coords.length / 2;\n const node = (i: number): Node => ({ x: coords[i * 2], y: coords[i * 2 + 1], a: anchorA[i], b: anchorB[i], t: anchorT[i] });\n const edges: Edge[] = [];\n contourStarts.forEach((start, c) => {\n const end = c + 1 < contourStarts.length ? contourStarts[c + 1] : total;\n for (let i = start; i < end; i++) {\n const from = node(i), to = node(i + 1 < end ? i + 1 : start);\n if (from.x !== to.x || from.y !== to.y) edges.push({ from, to, cuts: [] });\n }\n });\n return edges;\n}\n\n/** Record every interior crossing on both edges it cuts. */\nfunction cutAtCrossings(edges: Edge[]): void {\n const ends = new Float64Array(edges.length * 4);\n edges.forEach(({ from, to }, i) => ends.set([from.x, from.y, to.x, to.y], i * 4));\n forEachCrossing(ends, edges.length, (ei, fi, s, u) => {\n const e = edges[ei];\n const node = {\n x: e.from.x + (e.to.x - e.from.x) * s,\n y: e.from.y + (e.to.y - e.from.y) * s,\n ...anchorsAlong(e, s),\n };\n e.cuts.push({ s, node });\n edges[fi].cuts.push({ s: u, node });\n });\n}\n\n/** Anchors for a point `s` of the way along `e`: interpolated within one\n * curve's run, else the nearer end's. */\nfunction anchorsAlong(e: Edge, s: number): { a: number; b: number; t: number } {\n const { from, to } = e;\n if (from.a === to.a && from.b === to.b) return { a: from.a, b: from.b, t: from.t + (to.t - from.t) * s };\n const near = s < 0.5 ? from : to;\n return { a: near.a, b: near.b, t: near.t };\n}\n\n/** The pieces between cuts that have fill on exactly one side, turned so it is on the left. */\nfunction boundaryPieces(edges: Edge[]): Piece[] {\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (const { from: p } of edges) {\n minX = Math.min(minX, p.x); maxX = Math.max(maxX, p.x);\n minY = Math.min(minY, p.y); maxY = Math.max(maxY, p.y);\n }\n const eps = Math.max(Math.hypot(maxX - minX, maxY - minY) * 1e-7, 1e-9);\n const filled = (x: number, y: number) => windingAt(edges, x, y) !== 0;\n\n const out: Piece[] = [];\n for (const e of edges) {\n const stops = [e.from, ...e.cuts.sort((p, q) => p.s - q.s).map((c) => c.node), e.to];\n for (let k = 0; k + 1 < stops.length; k++) {\n const p = stops[k], q = stops[k + 1];\n const dx = q.x - p.x, dy = q.y - p.y;\n const len = Math.hypot(dx, dy);\n if (len === 0) continue;\n const mx = (p.x + q.x) / 2, my = (p.y + q.y) / 2;\n const nx = (-dy / len) * eps, ny = (dx / len) * eps;\n const left = filled(mx + nx, my + ny), right = filled(mx - nx, my - ny);\n if (left && !right) out.push({ from: p, to: q });\n else if (right && !left) out.push({ from: q, to: p });\n }\n }\n return out;\n}\n\nfunction windingAt(edges: Edge[], x: number, y: number): number {\n let w = 0;\n for (const { from: p, to: q } of edges) {\n const side = (q.x - p.x) * (y - p.y) - (x - p.x) * (q.y - p.y);\n if (p.y <= y && q.y > y && side > 0) w++;\n else if (q.y <= y && p.y > y && side < 0) w--;\n }\n return w;\n}\n\n/** Join pieces end to start into closed loops. Where a node has several ways\n * on, take the sharpest left turn, which keeps to the face being traced. */\nfunction chainLoops(pieces: Piece[]): Node[][] {\n const outgoing = new Map<string, Piece[]>();\n for (const p of pieces) {\n const k = keyOf(p.from);\n const list = outgoing.get(k);\n if (list) list.push(p);\n else outgoing.set(k, [p]);\n }\n const used = new Set<Piece>();\n const loops: Node[][] = [];\n for (const first of pieces) {\n if (used.has(first)) continue;\n used.add(first);\n const loop: Node[] = [first.from];\n const startKey = keyOf(first.from);\n let cur = first;\n while (keyOf(cur.to) !== startKey) {\n const next = sharpestLeft(cur, (outgoing.get(keyOf(cur.to)) ?? []).filter((p) => !used.has(p)));\n if (!next) break;\n used.add(next);\n loop.push(next.from);\n cur = next;\n }\n if (keyOf(cur.to) === startKey && loop.length >= 3) loops.push(loop);\n }\n return loops;\n}\n\nfunction sharpestLeft(into: Piece, options: Piece[]): Piece | undefined {\n const ix = into.to.x - into.from.x, iy = into.to.y - into.from.y;\n let best: Piece | undefined;\n let bestTurn = -Infinity;\n for (const p of options) {\n const ox = p.to.x - p.from.x, oy = p.to.y - p.from.y;\n const turn = Math.atan2(ix * oy - iy * ox, ix * ox + iy * oy);\n if (turn > bestTurn) {\n bestTurn = turn;\n best = p;\n }\n }\n return best;\n}\n\nfunction loopsToContours(loops: Node[][]): FlattenedContours {\n const out: FlattenedContours = { coords: [], contourStarts: [], anchorA: [], anchorB: [], anchorT: [] };\n for (const loop of loops) {\n out.contourStarts.push(out.coords.length / 2);\n for (const n of loop) {\n out.coords.push(n.x, n.y);\n out.anchorA.push(n.a);\n out.anchorB.push(n.b);\n out.anchorT.push(n.t);\n }\n }\n return out;\n}\n","/** How the rings of a fill that does not cross itself sit inside one another. */\n\nimport { pointInPolygon } from '../polyline';\nimport type { FlattenedContours } from './crossings';\n\nexport interface Ring {\n start: number;\n end: number;\n area: number;\n /** The smallest ring this one lies inside, or -1. */\n parent: number;\n /** Nonzero winding number just inside this ring. */\n winding: number;\n}\n\n/** Each contour's ring. A zero-area ring has no parent and winding 0. */\nexport function nestRings(flat: FlattenedContours): Ring[] {\n const { coords, contourStarts } = flat;\n const total = coords.length / 2;\n const rings: Ring[] = contourStarts.map((start, c) => {\n const end = c + 1 < contourStarts.length ? contourStarts[c + 1] : total;\n return { start, end, area: signedArea(coords, start, end), parent: -1, winding: 0 };\n });\n const boxes = rings.map((r) => boxOf(coords, r.start, r.end));\n const bySize = rings.map((_, i) => i).filter((i) => rings[i].area !== 0);\n bySize.sort((i, j) => Math.abs(rings[j].area) - Math.abs(rings[i].area));\n for (let k = 0; k < bySize.length; k++) {\n const r = rings[bySize[k]];\n for (let m = k - 1; m >= 0; m--) {\n const o = bySize[m];\n if (contains(coords, rings[o], boxes[o], r)) {\n r.parent = o;\n break;\n }\n }\n r.winding = Math.sign(r.area) + (r.parent >= 0 ? rings[r.parent].winding : 0);\n }\n return rings;\n}\n\n/** Whether `r` lies inside `o`, given that neither crosses the other. Judged\n * at the first vertex of `r` not on `o`'s outline, since one on it is\n * inside or out by rounding. */\nfunction contains(coords: number[], o: Ring, box: number[], r: Ring): boolean {\n const eps = Math.max(box[2] - box[0], box[3] - box[1]) * 1e-9;\n for (let i = r.start; i < r.end; i++) {\n const x = coords[i * 2], y = coords[i * 2 + 1];\n if (x < box[0] || x > box[2] || y < box[1] || y > box[3]) return false;\n if (!onOutline(coords, o, x, y, eps)) return pointInPolygon(coords, x, y, o.start, o.end);\n }\n return false;\n}\n\nfunction onOutline(coords: number[], o: Ring, x: number, y: number, eps: number): boolean {\n for (let i = o.start; i < o.end; i++) {\n const j = i + 1 === o.end ? o.start : i + 1;\n const ax = coords[i * 2], ay = coords[i * 2 + 1];\n const dx = coords[j * 2] - ax, dy = coords[j * 2 + 1] - ay;\n const len2 = dx * dx + dy * dy;\n const s = len2 > 0 ? Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / len2)) : 0;\n if (Math.hypot(ax + dx * s - x, ay + dy * s - y) <= eps) return true;\n }\n return false;\n}\n\nfunction boxOf(coords: number[], start: number, end: number): number[] {\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (let i = start; i < end; i++) {\n const x = coords[i * 2], y = coords[i * 2 + 1];\n minX = Math.min(minX, x); maxX = Math.max(maxX, x);\n minY = Math.min(minY, y); maxY = Math.max(maxY, y);\n }\n return [minX, minY, maxX, maxY];\n}\n\nfunction signedArea(coords: number[], start: number, end: number): number {\n let a = 0;\n for (let i = start; i < end; i++) {\n const j = i + 1 === end ? start : i + 1;\n a += coords[i * 2] * coords[j * 2 + 1] - coords[j * 2] * coords[i * 2 + 1];\n }\n return a * 0.5;\n}\n","import earcut from 'earcut';\nimport { forEachSegment, PATH_M, PATH_L, PATH_Z, PATH_C, PATH_Q } from '../commands';\nimport { resolveCorners } from '../paths/corners';\nimport { rectToContour } from '../box';\nimport type { Path, PolygonPath, RectPath } from '../path';\nimport { fillsOpenSubpaths } from '../openFill';\nimport {\n DEFAULT_FLATTEN_TOLERANCE,\n flattenCubicWithArcLen,\n flattenQuadraticWithArcLen,\n} from '../flatten';\nimport type { Mesh } from './mesh';\nimport { resolveCrossings, type FlattenedContours } from './crossings';\nimport { nestRings, type Ring } from './nesting';\n\n/** Options for `tessellate`. A smaller tolerance means more triangles and\n * smoother curves; it is in path-local units, so callers rendering at a\n * larger scale should tighten it. */\nexport interface TessellateOptions {\n /** Flatness tolerance for bezier subdivision in path-local units. */\n flattenTolerance?: number;\n}\n\n/** Turn a path into a triangle mesh the renderer can draw: curves flattened to\n * line segments, then the resulting polygon triangulated. */\nexport function tessellate(path: Path, opts: TessellateOptions = {}): Mesh {\n if (path.kind === 'rect') return tessellateRect(path);\n return tessellatePolygon(resolveCorners(path), opts);\n}\n\nfunction tessellateRect(p: RectPath): Mesh {\n const { x, y, width: w, height: h } = p;\n return {\n vertices: Float32Array.from(rectToContour(x, y, w, h)),\n indices: new Uint32Array([0, 1, 2, 0, 2, 3]),\n anchorA: new Uint32Array([0, 1, 2, 3]),\n anchorB: new Uint32Array([0, 1, 2, 3]),\n anchorT: new Float32Array([0, 0, 0, 0]),\n };\n}\n\n/** The contours a fill covers: all of them, or only those a `Z` closed. */\nexport function flattenPolygon(p: PolygonPath, tolerance: number): FlattenedContours {\n const closed = new Set<number>();\n const all = flattenContours(p, tolerance, closed);\n if (fillsOpenSubpaths(p)) return all;\n const kept: FlattenedContours = { coords: [], contourStarts: [], anchorA: [], anchorB: [], anchorT: [] };\n all.contourStarts.forEach((start, c) => {\n if (!closed.has(c)) return;\n const end = c + 1 < all.contourStarts.length ? all.contourStarts[c + 1] : all.coords.length / 2;\n kept.contourStarts.push(kept.coords.length / 2);\n kept.coords.push(...all.coords.slice(start * 2, end * 2));\n kept.anchorA.push(...all.anchorA.slice(start, end));\n kept.anchorB.push(...all.anchorB.slice(start, end));\n kept.anchorT.push(...all.anchorT.slice(start, end));\n });\n return kept;\n}\n\n/** Flatten every contour, noting in `closed` the index of each one a `Z` ends. */\nfunction flattenContours(p: PolygonPath, tolerance: number, closed: Set<number>): FlattenedContours {\n const { commands, coords } = p;\n const out: number[] = [];\n const anchorA: number[] = [];\n const anchorB: number[] = [];\n const anchorT: number[] = [];\n const contourStarts: number[] = [];\n let startAnchor = -1;\n let prevAnchor = -1;\n let anchorCounter = 0;\n\n // Anchor bookkeeping for the points a curve just appended: interior points\n // interpolate (prevAnchor → target); the last is pinned anchor-exact.\n const pushCurveAnchors = (anchorStart: number, arcAccum: number[], total: number, target: number): void => {\n for (let k = 0; k < arcAccum.length; k++) {\n anchorA.push(prevAnchor);\n anchorB.push(target);\n anchorT.push(total > 0 ? arcAccum[k] / total : 0);\n }\n const lastIdx = anchorStart + arcAccum.length - 1;\n anchorA[lastIdx] = target;\n anchorB[lastIdx] = target;\n anchorT[lastIdx] = 0;\n };\n\n forEachSegment(commands, coords, (cmd, coordIdx, prevX, prevY, _i, opensSubpath) => {\n if (opensSubpath) {\n const anchor = Math.max(startAnchor, 0);\n contourStarts.push(out.length / 2);\n out.push(prevX, prevY);\n anchorA.push(anchor);\n anchorB.push(anchor);\n anchorT.push(0);\n prevAnchor = anchor;\n }\n switch (cmd) {\n case PATH_M:\n case PATH_L: {\n if (cmd === PATH_M) {\n contourStarts.push(out.length / 2);\n startAnchor = anchorCounter;\n }\n out.push(coords[coordIdx], coords[coordIdx + 1]);\n anchorA.push(anchorCounter);\n anchorB.push(anchorCounter);\n anchorT.push(0);\n prevAnchor = anchorCounter;\n anchorCounter++;\n break;\n }\n case PATH_Q: {\n const target = anchorCounter;\n const arcAccum: number[] = [];\n const anchorStart = anchorA.length;\n const total = flattenQuadraticWithArcLen(\n prevX, prevY,\n coords[coordIdx], coords[coordIdx + 1],\n coords[coordIdx + 2], coords[coordIdx + 3],\n tolerance, out, arcAccum,\n );\n pushCurveAnchors(anchorStart, arcAccum, total, target);\n prevAnchor = target;\n anchorCounter++;\n break;\n }\n case PATH_C: {\n const target = anchorCounter;\n const arcAccum: number[] = [];\n const anchorStart = anchorA.length;\n const total = flattenCubicWithArcLen(\n prevX, prevY,\n coords[coordIdx], coords[coordIdx + 1],\n coords[coordIdx + 2], coords[coordIdx + 3],\n coords[coordIdx + 4], coords[coordIdx + 5],\n tolerance, out, arcAccum,\n );\n pushCurveAnchors(anchorStart, arcAccum, total, target);\n prevAnchor = target;\n anchorCounter++;\n break;\n }\n case PATH_Z:\n closed.add(contourStarts.length - 1);\n // The pen returns to the subpath start (forEachSegment does that); the\n // anchor it carries has to follow, or a curve after the Z interpolates\n // from the wrong end.\n prevAnchor = startAnchor;\n break;\n default:\n throw new Error(`tessellate: unknown command code ${cmd}`);\n }\n });\n\n return { coords: out, contourStarts, anchorA, anchorB, anchorT };\n}\n\nfunction tessellatePolygon(p: PolygonPath, opts: TessellateOptions): Mesh {\n const tolerance = opts.flattenTolerance ?? DEFAULT_FLATTEN_TOLERANCE;\n const flat = flattenPolygon(p, tolerance);\n\n if (p.fillRule === 'evenodd') {\n const { coords, contourStarts, anchorA, anchorB, anchorT } = flat;\n return tessellateEvenoddWithAnchors(coords, contourStarts, anchorA, anchorB, anchorT);\n }\n const crossed = resolveCrossings(flat);\n if (crossed) return tessellateNonzero(crossed, nestRings(crossed));\n const rings = nestRings(flat);\n if (rings.every((r) => Math.abs(r.winding) <= 1)) return tessellateNonzero(flat, rings);\n // Nested same-wound rings would cover the region they share twice.\n const rebuilt = resolveCrossings(flat, true)!;\n return tessellateNonzero(rebuilt, nestRings(rebuilt));\n}\n\n/** Triangulate rings that do not cross and wind at most once anywhere: each\n * ring with fill inside it, less the rings directly inside it, which are its\n * holes. */\nfunction tessellateNonzero(flat: FlattenedContours, rings: Ring[]): Mesh {\n const { coords, contourStarts, anchorA, anchorB, anchorT } = flat;\n const shapes: number[] = [];\n const holesByShape = new Map<number, number[]>();\n rings.forEach((r, i) => {\n if (r.area === 0) return;\n if (r.winding !== 0) shapes.push(i);\n else if (holesByShape.has(r.parent)) holesByShape.get(r.parent)!.push(i);\n else holesByShape.set(r.parent, [i]);\n });\n\n if (shapes.length <= 1 && (shapes[0] ?? 0) === 0) {\n const tri = earcut(coords, contourStarts.length > 1 ? contourStarts.slice(1) : undefined);\n return {\n vertices: new Float32Array(coords),\n indices: new Uint32Array(tri),\n anchorA: new Uint32Array(anchorA),\n anchorB: new Uint32Array(anchorB),\n anchorT: new Float32Array(anchorT),\n };\n }\n\n const finalCoords: number[] = [];\n const finalAnchorA: number[] = [];\n const finalAnchorB: number[] = [];\n const finalAnchorT: number[] = [];\n const finalIndices: number[] = [];\n for (const pos of shapes) {\n const holes = holesByShape.get(pos) ?? [];\n const offset = finalCoords.length / 2;\n const groupCoords: number[] = [];\n const groupStarts: number[] = [0];\n for (let i = rings[pos].start; i < rings[pos].end; i++) {\n groupCoords.push(coords[i * 2], coords[i * 2 + 1]);\n finalAnchorA.push(anchorA[i]);\n finalAnchorB.push(anchorB[i]);\n finalAnchorT.push(anchorT[i]);\n }\n for (const h of holes) {\n groupStarts.push(groupCoords.length / 2);\n for (let i = rings[h].start; i < rings[h].end; i++) {\n groupCoords.push(coords[i * 2], coords[i * 2 + 1]);\n finalAnchorA.push(anchorA[i]);\n finalAnchorB.push(anchorB[i]);\n finalAnchorT.push(anchorT[i]);\n }\n }\n const tri = earcut(groupCoords, groupStarts.length > 1 ? groupStarts.slice(1) : undefined);\n for (const v of groupCoords) finalCoords.push(v);\n for (const idx of tri) finalIndices.push(idx + offset);\n }\n\n return {\n vertices: new Float32Array(finalCoords),\n indices: new Uint32Array(finalIndices),\n anchorA: new Uint32Array(finalAnchorA),\n anchorB: new Uint32Array(finalAnchorB),\n anchorT: new Float32Array(finalAnchorT),\n };\n}\n\nfunction tessellateEvenoddWithAnchors(\n coords: number[],\n contourStarts: number[],\n anchorA: number[],\n anchorB: number[],\n anchorT: number[],\n): Mesh {\n const indices: number[] = [];\n const totalVerts = coords.length / 2;\n for (let c = 0; c < contourStarts.length; c++) {\n const start = contourStarts[c];\n const end = c + 1 < contourStarts.length ? contourStarts[c + 1] : totalVerts;\n for (let i = start + 1; i < end - 1; i++) {\n indices.push(start, i, i + 1);\n }\n }\n return {\n vertices: new Float32Array(coords),\n indices: new Uint32Array(indices),\n requiresStencil: true,\n anchorA: new Uint32Array(anchorA),\n anchorB: new Uint32Array(anchorB),\n anchorT: new Float32Array(anchorT),\n };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -676,6 +676,18 @@ declare function reversePath(path: PolygonPath): PolygonPath;
|
|
|
676
676
|
*/
|
|
677
677
|
declare function pathFromD(d: string, onWarn?: (message: string) => void): ReturnType<PathBuilder['build']>;
|
|
678
678
|
|
|
679
|
+
/**
|
|
680
|
+
* `pathToD` — a weasel `Path` as an SVG `d=` string, the inverse of
|
|
681
|
+
* `pathFromD`. `RectPath` lowers to `M h v h Z`; `PolygonPath` walks the
|
|
682
|
+
* (commands, coords) arrays, one SVG command per kit command, with corner
|
|
683
|
+
* shapes expanded into the geometry they draw.
|
|
684
|
+
*
|
|
685
|
+
* Absolute commands only; numbers are rounded to 6 decimals.
|
|
686
|
+
*/
|
|
687
|
+
|
|
688
|
+
/** `path` as SVG path data. */
|
|
689
|
+
declare function pathToD(given: Path): string;
|
|
690
|
+
|
|
679
691
|
/**
|
|
680
692
|
* A path measured once by arc length, so many stations along it cost a binary
|
|
681
693
|
* search each rather than a fresh flatten: what `pointAlongPath` answers one
|
|
@@ -694,6 +706,13 @@ interface MeasurePathOptions {
|
|
|
694
706
|
/** Curve flattening tolerance, in world units. Default 0.5. */
|
|
695
707
|
flattenTolerance?: number;
|
|
696
708
|
}
|
|
709
|
+
/** The station on a path nearest a point. */
|
|
710
|
+
interface PathNearestStation extends PathStation {
|
|
711
|
+
/** Arc length at `point`, on the scale {@link PathMeasure.at} reads. */
|
|
712
|
+
s: number;
|
|
713
|
+
/** Distance from the queried point to `point`. */
|
|
714
|
+
dist: number;
|
|
715
|
+
}
|
|
697
716
|
/** A measured path: its length, and the station at any distance along it. */
|
|
698
717
|
interface PathMeasure {
|
|
699
718
|
/** Total arc length, every subpath counted in order. */
|
|
@@ -709,6 +728,11 @@ interface PathMeasure {
|
|
|
709
728
|
* one vertex to the next, so geometry bent along it turns without facets.
|
|
710
729
|
*/
|
|
711
730
|
at(s: number, smooth?: boolean): PathStation;
|
|
731
|
+
/**
|
|
732
|
+
* The inverse of `at`: the station nearest `p`. On a tie the earliest
|
|
733
|
+
* segment wins. The tangent is the heading of the segment holding it.
|
|
734
|
+
*/
|
|
735
|
+
nearest(p: Point): PathNearestStation;
|
|
712
736
|
}
|
|
713
737
|
/**
|
|
714
738
|
* Measure `path` by arc length. Subpaths are measured in order and treated as
|
|
@@ -1294,7 +1318,8 @@ interface GrowRegionOptions {
|
|
|
1294
1318
|
* overlap rather than merge, and a hole grown shut winds back on itself and
|
|
1295
1319
|
* fills. At an inside corner the two offset edges are cut back to where they
|
|
1296
1320
|
* cross; where they do not, the gap is passed through the corner's original
|
|
1297
|
-
* point, which closes it with a loop inside the fill.
|
|
1321
|
+
* point, which closes it with a loop inside the fill. `mergeRegion`
|
|
1322
|
+
* redraws the result as its outline alone, for a stroke.
|
|
1298
1323
|
*
|
|
1299
1324
|
* What it costs: one segment per curve, more where `tolerance` needs the curve
|
|
1300
1325
|
* split; a miter corner between two straight edges costs nothing, one beside
|
|
@@ -1303,6 +1328,22 @@ interface GrowRegionOptions {
|
|
|
1303
1328
|
*/
|
|
1304
1329
|
declare function growRegion(path: Path, distance: number, opts?: GrowRegionOptions): PolygonPath;
|
|
1305
1330
|
|
|
1331
|
+
/** Options for {@link mergeRegion}. */
|
|
1332
|
+
interface MergeRegionOptions {
|
|
1333
|
+
/** How far from an edge a point is taken to tell which side is filled, in
|
|
1334
|
+
* the path's units; a sliver of region thinner than this may be lost.
|
|
1335
|
+
* Default 0.01. */
|
|
1336
|
+
tolerance?: number;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* The region `path` fills under `'nonzero'`, as contours that neither cross
|
|
1340
|
+
* nor overlap, wound so the fill lies on the same side of each as it does on
|
|
1341
|
+
* most of `path`. Stroking it traces only the region's edge. Every subpath
|
|
1342
|
+
* counts as closed. Answers `path`'s own contours, unchanged, where nothing
|
|
1343
|
+
* needs cutting or dropping.
|
|
1344
|
+
*/
|
|
1345
|
+
declare function mergeRegion(path: Path, opts?: MergeRegionOptions): PolygonPath;
|
|
1346
|
+
|
|
1306
1347
|
/**
|
|
1307
1348
|
* Simplify only where `flatIndexes` say: each unbroken run of those anchors
|
|
1308
1349
|
* along a subpath is refitted as one span by the fitter {@link simplifyPath}
|
|
@@ -2542,6 +2583,8 @@ interface PathsEditItem extends ConstrainPathEditOptions {
|
|
|
2542
2583
|
/** `before` as the edit left it; `before` itself for a path the edit did not touch. */
|
|
2543
2584
|
after: PolygonPath;
|
|
2544
2585
|
constraints: readonly PathConstraint[];
|
|
2586
|
+
/** For a path the edit left alone: its anchors give way as freely as any the edit did not move, rather than only when the edited paths cannot. */
|
|
2587
|
+
yields?: boolean;
|
|
2545
2588
|
}
|
|
2546
2589
|
/**
|
|
2547
2590
|
* A constraint across paths. Its anchors are numbered over the anchors of
|
|
@@ -2573,7 +2616,8 @@ interface ConstrainedPathsEdit {
|
|
|
2573
2616
|
* An edit of constrained paths, finished so their constraints and the links
|
|
2574
2617
|
* between them hold, as one solve over every anchor: the anchors and handles
|
|
2575
2618
|
* the edit moved are held, and so are the anchors of a path it left alone
|
|
2576
|
-
* (`after === before`), except one held on a segment
|
|
2619
|
+
* (`after === before`), except one held on a segment or on a path that
|
|
2620
|
+
* `yields`; `fixed` anchors go
|
|
2577
2621
|
* back to where they were, and the rest move the least they must. A constraint
|
|
2578
2622
|
* that did not hold before the edit is left out of the solve, and reported.
|
|
2579
2623
|
* Each item's own `horizontal` and `vertical` read its own `axisAngle`.
|
|
@@ -2855,4 +2899,4 @@ declare function reviveTypedArrays(value: unknown): unknown;
|
|
|
2855
2899
|
/** `tagTypedArrays` as a `JSON.stringify` replacer. */
|
|
2856
2900
|
declare function typedArrayReplacer(_key: string, value: unknown): unknown;
|
|
2857
2901
|
|
|
2858
|
-
export { ANCHOR_FIELDS, type Affine, type AnchorField, type AnchorFieldValues, type AnchorPair, type AnchorPathMeasure, AnchorSet, type AnchorSubpathMeasure, type AnchorSymmetry, type AverageAxis, type BendAlongPathOptions, type BendGrip, type BezierEasing, type BlendPathsOptions, type Box, CONSTRAINT_TOLERANCE, CORNER_RESTORE_TOLERANCE, type ConflictingConstraintsOptions, type ConstrainPathEditOptions, type ConstrainedPathEdit, type ConstrainedPathsEdit, type ConstraintPoint, type CornerCut, type CornerFrame, CornerPiece, CornerSpec, type CornerTrace, type CubicContour, type CubicCoords, type CubicSegment, type CurveNearest, DEFAULT_FLATTEN_TOLERANCE, type DirectionMark, EASINGS, EPS, type EasingFn, type EasingName, type EasingSpec, type ExtendToMeetOptions, type FramedBox, type GlMat3, type GrowRegionOptions, type HandleBalance, type HandleRef, type JoinOptions, type LengthenMode, type LineCoords, type MeasureAnchorPathOptions, type MeasurePathOptions, type NumberEntry, type NumberTypedArray, type OpenPathEnd, PATH_C, PATH_CMD_LENGTHS, PATH_COMMANDS, PATH_L, PATH_M, PATH_Q, PATH_SNAP_KINDS, PATH_Z, Path, type PathAnchorHit, type PathAwayFromAnchors, type PathBlend, PathBuilder, type PathCommandCode, type PathCommandName, type PathConstraint, type PathConstraintKind, type PathCrossing, type PathEndFrame, PathFillRule, type PathInWorldPose, type PathLink, type PathMeasure, type PathNearest, PathOpenFill, type PathSegment, type PathSnapHit, type PathSnapIndex, type PathSnapKind, type PathSnapQuery, type PathSnapTarget, type PathStation, type PathStop, type PathsEditItem, PenAnchor, type PlaceRectOptions, type PlacedRect, type Placement, type PlacementAlign, type PlacementSide, Point, type PointAlongPathOptions, type PointInPathOptions, type PointOrigin, type PolygonIntersectsPathOptions, PolygonPath, type PoseLinear, type PoseRotation, type QuadraticCoords, type Rect, RectPath, type RepeatAlongPathOptions, type RepeatStation, type ResamplePathOptions, type ResolvedCorners, SPRING_PRESETS, Scale2, type SegmentCrossing, type SegmentMeasure, type SegmentRef, type SegmentType, type SimplifyPathOptions, type SmudgePathOptions, type SoftFalloff, type SolveConstraintsOptions, type SolveConstraintsResult, type SolvePathConstraintsResult, type SpiroContour, SpiroKind, type SpiroPath, SpiroPoint, type SpiroToPathOptions, type SpringPreset, type SpringPresetName, type StaticPathSnapKind, type StrokeHitTestOptions, type SubpathEnd, TYPED_ARRAY_CONSTRUCTORS, type TaggedTypedArray, type TrimPathOptions, type TrimResult, type TypedArrayTag, type UnsatisfiedConstraintsOptions, type View, ZOOM_FLOOR, addExtremaAnchors, anchorOriginsOf, anchorSymmetries, anchorSymmetry, anchorsBefore, anchorsUnderBrush, anchorsWhere, applyToPoint, approxEq, asPolygonPath, averageAnchorsAt, balanceFactorToward, bendAlongPath, bendSegment, blendPaths, boundsOfCoords, boundsOfPath, boxContainsBox, boxContainsPoint, boxToBox, circlePath, clamp, clampRectWithin, closestOpenEnds, composePath, conflictingConstraints, constrainPathEdit, constrainPathsEdit, constraintAnchors, constraintApplies, constraintFits, convertSegments, cornerAnchors, cornerCuts, cornerFrameAt, cornerFrames, cornerTraces, createPathSnapIndex, cross, cubicAxisExtremaTs, cubicBezierEasing, cubicBounds, cubicContoursToPath, cubicEvalAt, decomposePath, defaultOpenFill, directionMarks, dot, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editAnchorSetTracked, elevateQuadraticToCubic, ellipsePath, equalizeSegmentHandles, everyNthAnchor, extendToMeet, fillsOpenSubpaths, findPathSnap, findPathSnaps, fitAffine, fitCubicThroughDeletion, fitCubicWithTangents, flatIndexesAfterReverse, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, forEachSegment, growAnchorSelection, growRegion, handleAlongItsAngle, handleAtItsLength, handleBalances, harmonizeAnchors, hasOpenSubpath, identity$1 as identity, intersectSegments, invert$1 as invert, invertAnchorSelection, isSegmentStraight, joinAnchorsAt, joinSubpathEnds, keepCorners, len2, lengthToward, lengthenOpenEnd, lengthenPathEnd, linePath, linear, makeHandlesSymmetric, mapConstraintAnchors, mat3, meanScale, measureAnchorPath, measurePath, moveHandleSymmetric, multiply$1 as multiply, nearestOnCubic, nearestOnLine, nearestOnPath, nearestOnQuadratic, nearestPathAnchor, normalizeZoom, offsetCornerTraces, openEndAt, openEndRay, openPathEnds, pathAnchorPoints, pathAwayFromAnchors, pathCommandCoordCount, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathCrossings, pathDistanceToPoint, pathEndAnchorIndex, pathEndFrame, pathFromD, pathInPoseFrame, pathInWorld, pathIntersectsPolygon, pathIntersectsRect, pathSegments, pathSignedArea, pathThroughPoseFrame, pathToCubicContours, placeRect, pointAlongPath, pointInPath, pointInPolygon, pointSegmentDist2, polygonContainsPath, polygonFromPoints, polygonIntersectsPath, polylineFromPoints, portControls, portCurvePoints, poseFrameInverseOf, poseFrameOf, poseLinearOf, poseRotationOf, prepareBlend, quadraticEvalAt, readAnchorFields, rectMarkerPath, rectPath, rectToContour, regularPolygonPath, remapAnchorValues, remapConstraints, remapPerAnchor, remapPointValues, repeatAlongPath, resamplePath, resolveCorners, resolveCornersWithSources, resolveEasing, restoreCorners, retractHandles, reverseAnchors, reversePath, reverseSubpaths, reviveTypedArrays, rotate, rotateAboutPoint, rotatePathAround, roundRectPath, scale, scalePathToBounds, scaleSegmentHandles, schneiderFit, segmentBetween, segmentExtremaTs, segmentsBetweenAnchors, segmentsCross, setDefaultOpenFill, setSubpathStart, shrinkAnchorSelection, sign, simplifyAnchorsAt, simplifyPath, simplifySpan, simplifySubpath, smoothAnchors, smudgePath, softFalloff, softSelectionBand, softSelectionWeights, solveConstraints, solvePathConstraints, spiroContoursFromControl, spiroContoursOf, spiroControlPath, spiroToPath, splitByClosure, splitCubicAt, splitLineAt, splitQuadraticAt, splitSubpaths, squarePath, starPath, stationsAlongPath, strokeHitTest, sub, subpathEndAt, subpathsOfAnchors, tagTypedArray, tagTypedArrays, transformCoords, transformPath, translate, translateAnchorsSymmetric, translatePath, trimPathAt, typedArrayReplacer, unionBoundsPath, unionBox, unsatisfiedConstraints, untagTypedArray, viewToMat3, withAnchorPoints, worldEditToStorage, writeAnchorField };
|
|
2902
|
+
export { ANCHOR_FIELDS, type Affine, type AnchorField, type AnchorFieldValues, type AnchorPair, type AnchorPathMeasure, AnchorSet, type AnchorSubpathMeasure, type AnchorSymmetry, type AverageAxis, type BendAlongPathOptions, type BendGrip, type BezierEasing, type BlendPathsOptions, type Box, CONSTRAINT_TOLERANCE, CORNER_RESTORE_TOLERANCE, type ConflictingConstraintsOptions, type ConstrainPathEditOptions, type ConstrainedPathEdit, type ConstrainedPathsEdit, type ConstraintPoint, type CornerCut, type CornerFrame, CornerPiece, CornerSpec, type CornerTrace, type CubicContour, type CubicCoords, type CubicSegment, type CurveNearest, DEFAULT_FLATTEN_TOLERANCE, type DirectionMark, EASINGS, EPS, type EasingFn, type EasingName, type EasingSpec, type ExtendToMeetOptions, type FramedBox, type GlMat3, type GrowRegionOptions, type HandleBalance, type HandleRef, type JoinOptions, type LengthenMode, type LineCoords, type MeasureAnchorPathOptions, type MeasurePathOptions, type MergeRegionOptions, type NumberEntry, type NumberTypedArray, type OpenPathEnd, PATH_C, PATH_CMD_LENGTHS, PATH_COMMANDS, PATH_L, PATH_M, PATH_Q, PATH_SNAP_KINDS, PATH_Z, Path, type PathAnchorHit, type PathAwayFromAnchors, type PathBlend, PathBuilder, type PathCommandCode, type PathCommandName, type PathConstraint, type PathConstraintKind, type PathCrossing, type PathEndFrame, PathFillRule, type PathInWorldPose, type PathLink, type PathMeasure, type PathNearest, type PathNearestStation, PathOpenFill, type PathSegment, type PathSnapHit, type PathSnapIndex, type PathSnapKind, type PathSnapQuery, type PathSnapTarget, type PathStation, type PathStop, type PathsEditItem, PenAnchor, type PlaceRectOptions, type PlacedRect, type Placement, type PlacementAlign, type PlacementSide, Point, type PointAlongPathOptions, type PointInPathOptions, type PointOrigin, type PolygonIntersectsPathOptions, PolygonPath, type PoseLinear, type PoseRotation, type QuadraticCoords, type Rect, RectPath, type RepeatAlongPathOptions, type RepeatStation, type ResamplePathOptions, type ResolvedCorners, SPRING_PRESETS, Scale2, type SegmentCrossing, type SegmentMeasure, type SegmentRef, type SegmentType, type SimplifyPathOptions, type SmudgePathOptions, type SoftFalloff, type SolveConstraintsOptions, type SolveConstraintsResult, type SolvePathConstraintsResult, type SpiroContour, SpiroKind, type SpiroPath, SpiroPoint, type SpiroToPathOptions, type SpringPreset, type SpringPresetName, type StaticPathSnapKind, type StrokeHitTestOptions, type SubpathEnd, TYPED_ARRAY_CONSTRUCTORS, type TaggedTypedArray, type TrimPathOptions, type TrimResult, type TypedArrayTag, type UnsatisfiedConstraintsOptions, type View, ZOOM_FLOOR, addExtremaAnchors, anchorOriginsOf, anchorSymmetries, anchorSymmetry, anchorsBefore, anchorsUnderBrush, anchorsWhere, applyToPoint, approxEq, asPolygonPath, averageAnchorsAt, balanceFactorToward, bendAlongPath, bendSegment, blendPaths, boundsOfCoords, boundsOfPath, boxContainsBox, boxContainsPoint, boxToBox, circlePath, clamp, clampRectWithin, closestOpenEnds, composePath, conflictingConstraints, constrainPathEdit, constrainPathsEdit, constraintAnchors, constraintApplies, constraintFits, convertSegments, cornerAnchors, cornerCuts, cornerFrameAt, cornerFrames, cornerTraces, createPathSnapIndex, cross, cubicAxisExtremaTs, cubicBezierEasing, cubicBounds, cubicContoursToPath, cubicEvalAt, decomposePath, defaultOpenFill, directionMarks, dot, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editAnchorSetTracked, elevateQuadraticToCubic, ellipsePath, equalizeSegmentHandles, everyNthAnchor, extendToMeet, fillsOpenSubpaths, findPathSnap, findPathSnaps, fitAffine, fitCubicThroughDeletion, fitCubicWithTangents, flatIndexesAfterReverse, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, forEachSegment, growAnchorSelection, growRegion, handleAlongItsAngle, handleAtItsLength, handleBalances, harmonizeAnchors, hasOpenSubpath, identity$1 as identity, intersectSegments, invert$1 as invert, invertAnchorSelection, isSegmentStraight, joinAnchorsAt, joinSubpathEnds, keepCorners, len2, lengthToward, lengthenOpenEnd, lengthenPathEnd, linePath, linear, makeHandlesSymmetric, mapConstraintAnchors, mat3, meanScale, measureAnchorPath, measurePath, mergeRegion, moveHandleSymmetric, multiply$1 as multiply, nearestOnCubic, nearestOnLine, nearestOnPath, nearestOnQuadratic, nearestPathAnchor, normalizeZoom, offsetCornerTraces, openEndAt, openEndRay, openPathEnds, pathAnchorPoints, pathAwayFromAnchors, pathCommandCoordCount, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathCrossings, pathDistanceToPoint, pathEndAnchorIndex, pathEndFrame, pathFromD, pathInPoseFrame, pathInWorld, pathIntersectsPolygon, pathIntersectsRect, pathSegments, pathSignedArea, pathThroughPoseFrame, pathToCubicContours, pathToD, placeRect, pointAlongPath, pointInPath, pointInPolygon, pointSegmentDist2, polygonContainsPath, polygonFromPoints, polygonIntersectsPath, polylineFromPoints, portControls, portCurvePoints, poseFrameInverseOf, poseFrameOf, poseLinearOf, poseRotationOf, prepareBlend, quadraticEvalAt, readAnchorFields, rectMarkerPath, rectPath, rectToContour, regularPolygonPath, remapAnchorValues, remapConstraints, remapPerAnchor, remapPointValues, repeatAlongPath, resamplePath, resolveCorners, resolveCornersWithSources, resolveEasing, restoreCorners, retractHandles, reverseAnchors, reversePath, reverseSubpaths, reviveTypedArrays, rotate, rotateAboutPoint, rotatePathAround, roundRectPath, scale, scalePathToBounds, scaleSegmentHandles, schneiderFit, segmentBetween, segmentExtremaTs, segmentsBetweenAnchors, segmentsCross, setDefaultOpenFill, setSubpathStart, shrinkAnchorSelection, sign, simplifyAnchorsAt, simplifyPath, simplifySpan, simplifySubpath, smoothAnchors, smudgePath, softFalloff, softSelectionBand, softSelectionWeights, solveConstraints, solvePathConstraints, spiroContoursFromControl, spiroContoursOf, spiroControlPath, spiroToPath, splitByClosure, splitCubicAt, splitLineAt, splitQuadraticAt, splitSubpaths, squarePath, starPath, stationsAlongPath, strokeHitTest, sub, subpathEndAt, subpathsOfAnchors, tagTypedArray, tagTypedArrays, transformCoords, transformPath, translate, translateAnchorsSymmetric, translatePath, trimPathAt, typedArrayReplacer, unionBoundsPath, unionBox, unsatisfiedConstraints, untagTypedArray, viewToMat3, withAnchorPoints, worldEditToStorage, writeAnchorField };
|