@pixerate/editor 0.49.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/index.cjs +151 -25
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +109 -3
- package/dist/canvas/index.d.ts +109 -3
- package/dist/canvas/index.js +127 -1
- package/dist/canvas/index.js.map +1 -1
- package/dist/chart/index.cjs +197 -52
- package/dist/chart/index.cjs.map +1 -1
- package/dist/chart/index.d.cts +88 -3
- package/dist/chart/index.d.ts +88 -3
- package/dist/chart/index.js +151 -6
- package/dist/chart/index.js.map +1 -1
- package/dist/{chunk-3LHWTGHW.js → chunk-TO22LX34.js} +11 -1
- package/dist/chunk-TO22LX34.js.map +1 -0
- package/dist/{chunk-VNYRI265.cjs → chunk-YNSK4MGT.cjs} +12 -2
- package/dist/chunk-YNSK4MGT.cjs.map +1 -0
- package/dist/{controller-DtbEo3om.d.ts → controller-BdKzaxs2.d.ts} +1 -1
- package/dist/{controller-ChjCCMLl.d.cts → controller-DS3drIvy.d.cts} +1 -1
- package/dist/extensions/index.d.cts +2 -2
- package/dist/extensions/index.d.ts +2 -2
- package/dist/image-editor/index.cjs +141 -1
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +42 -1
- package/dist/image-editor/index.d.ts +42 -1
- package/dist/image-editor/index.js +140 -0
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-DoHqT1mq.d.cts → index-DOy9HzfC.d.cts} +1 -1
- package/dist/{index-YLZ0fKqE.d.ts → index-Dt9lzydb.d.ts} +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/{pathfinder-D98S2lV5.d.ts → pathfinder-B9xh_pCZ.d.ts} +2 -1
- package/dist/{pathfinder-DKRcXiLS.d.cts → pathfinder-QdG70sr9.d.cts} +2 -1
- package/dist/vector/index.cjs +153 -153
- package/dist/vector/index.d.cts +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3LHWTGHW.js.map +0 -1
- package/dist/chunk-VNYRI265.cjs.map +0 -1
package/dist/vector/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ var _chunkQKLRAA4Tcjs = require('../chunk-QKLRAA4T.cjs');
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
var
|
|
43
|
+
var _chunkYNSK4MGTcjs = require('../chunk-YNSK4MGT.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
@@ -350,7 +350,7 @@ function spanVectorGradientStops(g, from, to, expanded = expandVectorGradientSto
|
|
|
350
350
|
var hasExplicitGradientGeometry = (g) => finitePoint(g.start) && finitePoint(g.end);
|
|
351
351
|
function shorthandPoints(g) {
|
|
352
352
|
if (g.type === "linear" || g.type === "reflected") {
|
|
353
|
-
const c =
|
|
353
|
+
const c = _chunkYNSK4MGTcjs.angleToSvgLinearCoords.call(void 0, Number.isFinite(g.angle) ? g.angle : 180);
|
|
354
354
|
const start2 = g.type === "linear" ? { x: c.x1, y: c.y1 } : { x: 0.5, y: 0.5 };
|
|
355
355
|
const end = { x: c.x2, y: c.y2 };
|
|
356
356
|
return { start: start2, end, width: add(start2, perp(sub(end, start2))) };
|
|
@@ -918,7 +918,7 @@ var Side = class {
|
|
|
918
918
|
constructor(a, h1, h2, b) {
|
|
919
919
|
this.straight = onAnchor(a, h1) && onAnchor(b, h2);
|
|
920
920
|
this.curve = this.straight ? [pt(a), pt(b)] : [pt(a), pt(_nullishCoalesce(h1, () => ( a))), pt(_nullishCoalesce(h2, () => ( b))), pt(b)];
|
|
921
|
-
this.length = this.straight ? Math.hypot(b.x - a.x, b.y - a.y) :
|
|
921
|
+
this.length = this.straight ? Math.hypot(b.x - a.x, b.y - a.y) : _chunkYNSK4MGTcjs.segmentLength.call(void 0, this.curve);
|
|
922
922
|
}
|
|
923
923
|
/** Unit direction the side leaves the corner in (towards its first control point off the corner). */
|
|
924
924
|
direction() {
|
|
@@ -936,10 +936,10 @@ var Side = class {
|
|
|
936
936
|
const t2 = this.length > EPS ? Math.min(1, Math.max(0, s / this.length)) : 0;
|
|
937
937
|
return { t: t2, p: add2(vec(this.curve[0]), mul2(u, s)), dir: u };
|
|
938
938
|
}
|
|
939
|
-
const t =
|
|
940
|
-
const d = vec(
|
|
939
|
+
const t = _chunkYNSK4MGTcjs.segmentParamAtLength.call(void 0, this.curve, s, this.length);
|
|
940
|
+
const d = vec(_chunkYNSK4MGTcjs.segmentDerivative.call(void 0, this.curve, t));
|
|
941
941
|
const l = len(d);
|
|
942
|
-
return { t, p: vec(
|
|
942
|
+
return { t, p: vec(_chunkYNSK4MGTcjs.segmentPoint.call(void 0, this.curve, t)), dir: l > EPS ? mul2(d, 1 / l) : u };
|
|
943
943
|
}
|
|
944
944
|
};
|
|
945
945
|
function cornerOf(sp, s, i) {
|
|
@@ -1040,7 +1040,7 @@ function expandVectorCornersOf(sp, subpath = 0) {
|
|
|
1040
1040
|
const s0 = from ? from.tv : 0;
|
|
1041
1041
|
const s1 = to ? 1 - to.tu : 1;
|
|
1042
1042
|
const seg = [pt(a), pt(_nullishCoalesce(a.out, () => ( a))), pt(_nullishCoalesce(b.in, () => ( b))), pt(b)];
|
|
1043
|
-
const part =
|
|
1043
|
+
const part = _chunkYNSK4MGTcjs.subSegment.call(void 0, seg, s0, Math.max(s0, s1));
|
|
1044
1044
|
return { out: vec(part[1]), in: vec(part[2]) };
|
|
1045
1045
|
});
|
|
1046
1046
|
const anchors = [];
|
|
@@ -1343,7 +1343,7 @@ function flatten(segments, closed, tol) {
|
|
|
1343
1343
|
corner.push(isCorner);
|
|
1344
1344
|
};
|
|
1345
1345
|
for (const seg of segments) {
|
|
1346
|
-
const flat =
|
|
1346
|
+
const flat = _chunkYNSK4MGTcjs.flattenChain.call(void 0, [seg], tol);
|
|
1347
1347
|
if (dist(seg[0], seg[seg.length - 1]) <= 1e-12 && flat.length > 1) flat.push(seg[seg.length - 1]);
|
|
1348
1348
|
flat.forEach((p, i) => push(p, i === 0 || i === flat.length - 1));
|
|
1349
1349
|
}
|
|
@@ -1433,7 +1433,7 @@ function variableStrokeRings(path, options) {
|
|
|
1433
1433
|
const last = out[out.length - 1];
|
|
1434
1434
|
if (!last || dist(last, p) > 1e-12) out.push(p);
|
|
1435
1435
|
};
|
|
1436
|
-
for (const contour of
|
|
1436
|
+
for (const contour of _chunkYNSK4MGTcjs.pathToContours.call(void 0, path)) {
|
|
1437
1437
|
if (!contour.segments.length) continue;
|
|
1438
1438
|
const poly = flatten(contour.segments, contour.closed, Math.min(tol, half) / 4);
|
|
1439
1439
|
if (!poly) continue;
|
|
@@ -1559,7 +1559,7 @@ function variableStrokeOutline(path, options) {
|
|
|
1559
1559
|
const tol = options.tolerance && options.tolerance > 0 ? options.tolerance : 0.05;
|
|
1560
1560
|
let polygons;
|
|
1561
1561
|
try {
|
|
1562
|
-
polygons =
|
|
1562
|
+
polygons = _chunkYNSK4MGTcjs.polygonBoolean.call(void 0, "union", [{ rings: pieces, fillRule: "nonzero" }]);
|
|
1563
1563
|
} catch (e3) {
|
|
1564
1564
|
return [];
|
|
1565
1565
|
}
|
|
@@ -1567,11 +1567,11 @@ function variableStrokeOutline(path, options) {
|
|
|
1567
1567
|
for (const polygon2 of polygons) {
|
|
1568
1568
|
for (const ring of polygon2) {
|
|
1569
1569
|
if (ring.length < 3) continue;
|
|
1570
|
-
const cubics =
|
|
1570
|
+
const cubics = _chunkYNSK4MGTcjs.fitCubics.call(void 0, ring, tol, { closed: true, cornerAngleDeg: 25 });
|
|
1571
1571
|
if (!cubics.length) continue;
|
|
1572
1572
|
out.push({ type: "M", x: cubics[0].p0[0], y: cubics[0].p0[1] });
|
|
1573
1573
|
cubics.forEach((c, i) => {
|
|
1574
|
-
if (
|
|
1574
|
+
if (_chunkYNSK4MGTcjs.isStraightCubic.call(void 0, c, tol * 0.02)) {
|
|
1575
1575
|
if (i < cubics.length - 1) out.push({ type: "L", x: c.p3[0], y: c.p3[1] });
|
|
1576
1576
|
} else out.push({ type: "C", x1: c.p1[0], y1: c.p1[1], x2: c.p2[0], y2: c.p2[1], x: c.p3[0], y: c.p3[1] });
|
|
1577
1577
|
});
|
|
@@ -1582,17 +1582,17 @@ function variableStrokeOutline(path, options) {
|
|
|
1582
1582
|
}
|
|
1583
1583
|
function nearestStrokePosition(path, p, only) {
|
|
1584
1584
|
let best = null;
|
|
1585
|
-
|
|
1585
|
+
_chunkYNSK4MGTcjs.pathToContours.call(void 0, path).forEach((c, ci) => {
|
|
1586
1586
|
if (!c.segments.length || only !== void 0 && ci !== only) return;
|
|
1587
|
-
const lengths = c.segments.map((s) =>
|
|
1587
|
+
const lengths = c.segments.map((s) => _chunkYNSK4MGTcjs.segmentLength.call(void 0, s));
|
|
1588
1588
|
const total = lengths.reduce((a, b) => a + b, 0);
|
|
1589
1589
|
if (!(total > 0)) return;
|
|
1590
1590
|
let acc = 0;
|
|
1591
1591
|
c.segments.forEach((seg, si) => {
|
|
1592
|
-
const near2 =
|
|
1592
|
+
const near2 = _chunkYNSK4MGTcjs.segmentNearest.call(void 0, seg, p);
|
|
1593
1593
|
if (!best || near2.distance < best.distance) {
|
|
1594
|
-
const s = acc +
|
|
1595
|
-
const tan =
|
|
1594
|
+
const s = acc + _chunkYNSK4MGTcjs.segmentLength.call(void 0, seg, 0, near2.t);
|
|
1595
|
+
const tan = _chunkYNSK4MGTcjs.segmentTangent.call(void 0, seg, near2.t);
|
|
1596
1596
|
const pt2 = seg.length === 2 ? lerp(seg[0], seg[1], near2.t) : evalSeg(seg, near2.t);
|
|
1597
1597
|
const n = leftNormal([tan[0], tan[1]]);
|
|
1598
1598
|
const side = (p[0] - pt2[0]) * n[0] + (p[1] - pt2[1]) * n[1] >= 0 ? "left" : "right";
|
|
@@ -1609,9 +1609,9 @@ function evalSeg(seg, t) {
|
|
|
1609
1609
|
return pts[0];
|
|
1610
1610
|
}
|
|
1611
1611
|
function strokePositionPoint(path, index, t) {
|
|
1612
|
-
const c =
|
|
1612
|
+
const c = _chunkYNSK4MGTcjs.pathToContours.call(void 0, path)[index];
|
|
1613
1613
|
if (!_optionalChain([c, 'optionalAccess', _32 => _32.segments, 'access', _33 => _33.length])) return null;
|
|
1614
|
-
const lengths = c.segments.map((s) =>
|
|
1614
|
+
const lengths = c.segments.map((s) => _chunkYNSK4MGTcjs.segmentLength.call(void 0, s));
|
|
1615
1615
|
const total = lengths.reduce((a, b) => a + b, 0);
|
|
1616
1616
|
let want = Math.min(Math.max(t, 0), 1) * total;
|
|
1617
1617
|
for (let i = 0; i < c.segments.length; i++) {
|
|
@@ -1622,11 +1622,11 @@ function strokePositionPoint(path, index, t) {
|
|
|
1622
1622
|
const target = Math.min(want, lengths[i]);
|
|
1623
1623
|
for (let k = 0; k < 40; k++) {
|
|
1624
1624
|
const mid = (lo + hi) / 2;
|
|
1625
|
-
if (
|
|
1625
|
+
if (_chunkYNSK4MGTcjs.segmentLength.call(void 0, seg, 0, mid) < target) lo = mid;
|
|
1626
1626
|
else hi = mid;
|
|
1627
1627
|
}
|
|
1628
1628
|
const u = (lo + hi) / 2;
|
|
1629
|
-
const tan =
|
|
1629
|
+
const tan = _chunkYNSK4MGTcjs.segmentTangent.call(void 0, seg, u);
|
|
1630
1630
|
return { point: evalSeg(seg, u), tangent: [tan[0], tan[1]] };
|
|
1631
1631
|
}
|
|
1632
1632
|
want -= lengths[i];
|
|
@@ -1638,7 +1638,7 @@ function strokePositionPoint(path, index, t) {
|
|
|
1638
1638
|
var KAPPA = 0.5522847498307936;
|
|
1639
1639
|
var NOTCH = 0.7;
|
|
1640
1640
|
function isClosedBezierShape(path) {
|
|
1641
|
-
const contours =
|
|
1641
|
+
const contours = _chunkYNSK4MGTcjs.pathToContours.call(void 0, path).filter((c) => c.segments.length > 0);
|
|
1642
1642
|
return contours.length > 0 && contours.every((c) => c.closed);
|
|
1643
1643
|
}
|
|
1644
1644
|
function effectiveStrokeAlign(style, closedShape) {
|
|
@@ -1659,7 +1659,7 @@ function vectorStrokeLineArea(parts, style, tolerance) {
|
|
|
1659
1659
|
const join = _nullishCoalesce(style.strokeLinejoin, () => ( "miter"));
|
|
1660
1660
|
const cap = _nullishCoalesce(style.strokeLinecap, () => ( "butt"));
|
|
1661
1661
|
if (profile) return variableStrokeOutline(parts.line, { width: parts.drawWidth, profile, join, cap, ...dash, ...tolerance ? { tolerance } : {} });
|
|
1662
|
-
return
|
|
1662
|
+
return _chunkYNSK4MGTcjs.outlineStroke.call(void 0, parts.line, { width: parts.drawWidth, join, cap, ...dash, ...tolerance ? { tolerance } : {} });
|
|
1663
1663
|
}
|
|
1664
1664
|
var capExtent = (style, width) => style.strokeLinecap === "round" || style.strokeLinecap === "square" ? width / 2 : 0;
|
|
1665
1665
|
function arrowheadWeight(style, end) {
|
|
@@ -1740,16 +1740,16 @@ function arrowheadPath(kind, tip, dir, hw) {
|
|
|
1740
1740
|
}
|
|
1741
1741
|
}
|
|
1742
1742
|
var toVec = (p) => ({ x: p[0], y: p[1] });
|
|
1743
|
-
var segLen = (s) =>
|
|
1743
|
+
var segLen = (s) => _chunkYNSK4MGTcjs.segmentLength.call(void 0, s);
|
|
1744
1744
|
function endOf(segs, atStart) {
|
|
1745
1745
|
const long = (s2) => segLen(s2) > 1e-9;
|
|
1746
1746
|
if (atStart) {
|
|
1747
1747
|
const s2 = _nullishCoalesce(segs.find(long), () => ( segs[0]));
|
|
1748
|
-
const t2 =
|
|
1748
|
+
const t2 = _chunkYNSK4MGTcjs.segmentTangent.call(void 0, s2, 0);
|
|
1749
1749
|
return { p: toVec(segs[0][0]), out: v(-t2[0], -t2[1]) };
|
|
1750
1750
|
}
|
|
1751
1751
|
const s = _nullishCoalesce([...segs].reverse().find(long), () => ( segs[segs.length - 1]));
|
|
1752
|
-
const t =
|
|
1752
|
+
const t = _chunkYNSK4MGTcjs.segmentTangent.call(void 0, s, 1);
|
|
1753
1753
|
const last = segs[segs.length - 1];
|
|
1754
1754
|
return { p: toVec(last[last.length - 1]), out: v(t[0], t[1]) };
|
|
1755
1755
|
}
|
|
@@ -1760,7 +1760,7 @@ function pointAlong(segs, fromStart, dist5) {
|
|
|
1760
1760
|
const l = segLen(s);
|
|
1761
1761
|
if (acc + l >= dist5) {
|
|
1762
1762
|
const want = fromStart ? dist5 - acc : l - (dist5 - acc);
|
|
1763
|
-
const pts =
|
|
1763
|
+
const pts = _chunkYNSK4MGTcjs.trimSegments.call(void 0, [s], 0, want);
|
|
1764
1764
|
const p = pts.length ? pts[0][pts[0].length - 1] : s[0];
|
|
1765
1765
|
return toVec(p);
|
|
1766
1766
|
}
|
|
@@ -1770,7 +1770,7 @@ function pointAlong(segs, fromStart, dist5) {
|
|
|
1770
1770
|
}
|
|
1771
1771
|
function vectorStrokeParts(path, style) {
|
|
1772
1772
|
const width = _nullishCoalesce(style.strokeWidth, () => ( 1));
|
|
1773
|
-
const contours =
|
|
1773
|
+
const contours = _chunkYNSK4MGTcjs.pathToContours.call(void 0, path).filter((c) => c.segments.length > 0);
|
|
1774
1774
|
const closedShape = contours.length > 0 && contours.every((c) => c.closed);
|
|
1775
1775
|
const align = effectiveStrokeAlign(style, closedShape);
|
|
1776
1776
|
const drawWidth = align === "center" ? width : width * 2;
|
|
@@ -1810,26 +1810,26 @@ function vectorStrokeParts(path, style) {
|
|
|
1810
1810
|
if (!s0 && !s1) return c;
|
|
1811
1811
|
const lengths = c.segments.map(segLen);
|
|
1812
1812
|
const total = lengths.reduce((a, b) => a + b, 0);
|
|
1813
|
-
return { closed: false, segments: total - s1 > s0 ?
|
|
1813
|
+
return { closed: false, segments: total - s1 > s0 ? _chunkYNSK4MGTcjs.trimSegments.call(void 0, c.segments, s0, total - s1, lengths) : [] };
|
|
1814
1814
|
});
|
|
1815
|
-
return { align, line:
|
|
1815
|
+
return { align, line: _chunkYNSK4MGTcjs.contoursToPath.call(void 0, trimmed), drawWidth, heads };
|
|
1816
1816
|
}
|
|
1817
1817
|
function vectorStrokeOutlinePath(path, style) {
|
|
1818
1818
|
const parts = vectorStrokeParts(path, style);
|
|
1819
1819
|
const stroke = vectorStrokeLineArea(parts, style);
|
|
1820
1820
|
const fill = { path, fillRule: _nullishCoalesce(style.fillRule, () => ( "nonzero")) };
|
|
1821
1821
|
let area = stroke;
|
|
1822
|
-
if (parts.align === "inside") area =
|
|
1823
|
-
else if (parts.align === "outside") area =
|
|
1822
|
+
if (parts.align === "inside") area = _chunkYNSK4MGTcjs.pathBoolean.call(void 0, "intersection", [stroke, fill]).path;
|
|
1823
|
+
else if (parts.align === "outside") area = _chunkYNSK4MGTcjs.pathBoolean.call(void 0, "difference", [stroke, fill]).path;
|
|
1824
1824
|
if (!parts.heads.length) return area;
|
|
1825
|
-
return
|
|
1825
|
+
return _chunkYNSK4MGTcjs.pathBoolean.call(void 0, "union", [area, ...parts.heads.map((h) => h.path)]).path;
|
|
1826
1826
|
}
|
|
1827
1827
|
function hitTestVectorStroke(path, p, style, tolerance = 0) {
|
|
1828
1828
|
const parts = vectorStrokeParts(path, style);
|
|
1829
1829
|
const point = [p.x, p.y];
|
|
1830
1830
|
const width = _nullishCoalesce(style.strokeWidth, () => ( 1));
|
|
1831
1831
|
for (const h of parts.heads) {
|
|
1832
|
-
if (
|
|
1832
|
+
if (_chunkYNSK4MGTcjs.pointInBezierPath.call(void 0, h.path, point) || tolerance > 0 && _chunkYNSK4MGTcjs.distanceToBezierPath.call(void 0, h.path, point) <= tolerance) return true;
|
|
1833
1833
|
}
|
|
1834
1834
|
if (!parts.line.length) return false;
|
|
1835
1835
|
const profile = strokeWidthProfileOf(style);
|
|
@@ -1847,13 +1847,13 @@ function hitTestVectorStroke(path, p, style, tolerance = 0) {
|
|
|
1847
1847
|
reach = Math.max(reach, width / 2 * (w.left + w.right) / 2);
|
|
1848
1848
|
}
|
|
1849
1849
|
} else {
|
|
1850
|
-
d =
|
|
1850
|
+
d = _chunkYNSK4MGTcjs.distanceToBezierPath.call(void 0, parts.line, point);
|
|
1851
1851
|
if (parts.align !== "center") reach = width;
|
|
1852
1852
|
}
|
|
1853
1853
|
if (parts.align === "center") return d <= reach + tolerance;
|
|
1854
1854
|
if (d > reach + tolerance) return false;
|
|
1855
1855
|
if (d <= tolerance) return true;
|
|
1856
|
-
const inside =
|
|
1856
|
+
const inside = _chunkYNSK4MGTcjs.pointInBezierPath.call(void 0, path, point, _nullishCoalesce(style.fillRule, () => ( "nonzero")));
|
|
1857
1857
|
return parts.align === "inside" ? inside : !inside;
|
|
1858
1858
|
}
|
|
1859
1859
|
function vectorStrokeReach(style) {
|
|
@@ -1876,9 +1876,9 @@ function raise(seg) {
|
|
|
1876
1876
|
return [p0, [p0[0] + 2 / 3 * (p1[0] - p0[0]), p0[1] + 2 / 3 * (p1[1] - p0[1])], [p2[0] + 2 / 3 * (p1[0] - p2[0]), p2[1] + 2 / 3 * (p1[1] - p2[1])], p2];
|
|
1877
1877
|
}
|
|
1878
1878
|
function subsOf(path) {
|
|
1879
|
-
return
|
|
1879
|
+
return _chunkYNSK4MGTcjs.pathToContours.call(void 0, path).map((c) => ({ segs: _chunkYNSK4MGTcjs.closeContour.call(void 0, c).filter((s) => !degenerate(s)).map(raise), closed: c.closed })).filter((s) => s.segs.length > 0);
|
|
1880
1880
|
}
|
|
1881
|
-
var subsToPath = (subs) =>
|
|
1881
|
+
var subsToPath = (subs) => _chunkYNSK4MGTcjs.contoursToPath.call(void 0, subs.map((s) => ({ segments: s.segs, closed: s.closed })));
|
|
1882
1882
|
var unit2 = (x, y) => {
|
|
1883
1883
|
const l = Math.hypot(x, y);
|
|
1884
1884
|
return l > 1e-12 && Number.isFinite(l) ? [x / l, y / l] : null;
|
|
@@ -1901,13 +1901,13 @@ function endTangent(s) {
|
|
|
1901
1901
|
function tangentAt(s, t) {
|
|
1902
1902
|
if (t <= 1e-9) return startTangent(s);
|
|
1903
1903
|
if (t >= 1 - 1e-9) return endTangent(s);
|
|
1904
|
-
const d =
|
|
1904
|
+
const d = _chunkYNSK4MGTcjs.segmentDerivative.call(void 0, s, t);
|
|
1905
1905
|
return _nullishCoalesce(unit2(d[0], d[1]), () => ( startTangent(s)));
|
|
1906
1906
|
}
|
|
1907
1907
|
var perp2 = (v2) => [-v2[1], v2[0]];
|
|
1908
1908
|
function effectPathLength(path) {
|
|
1909
1909
|
let total = 0;
|
|
1910
|
-
for (const s of subsOf(path)) for (const seg of s.segs) total +=
|
|
1910
|
+
for (const s of subsOf(path)) for (const seg of s.segs) total += _chunkYNSK4MGTcjs.segmentLength.call(void 0, seg);
|
|
1911
1911
|
return total;
|
|
1912
1912
|
}
|
|
1913
1913
|
function effectPathVertexCount(path) {
|
|
@@ -1919,7 +1919,7 @@ var Measured = class {
|
|
|
1919
1919
|
|
|
1920
1920
|
constructor(path) {
|
|
1921
1921
|
this.segs = subsOf(path).flatMap((s) => s.segs);
|
|
1922
|
-
this.lens = this.segs.map((s) =>
|
|
1922
|
+
this.lens = this.segs.map((s) => _chunkYNSK4MGTcjs.segmentLength.call(void 0, s));
|
|
1923
1923
|
this.total = this.lens.reduce((a, b) => a + b, 0);
|
|
1924
1924
|
}
|
|
1925
1925
|
/**
|
|
@@ -1927,7 +1927,7 @@ var Measured = class {
|
|
|
1927
1927
|
* starts where it ends (across the start of a closed path).
|
|
1928
1928
|
*/
|
|
1929
1929
|
append(sa, sb, out) {
|
|
1930
|
-
for (const piece of
|
|
1930
|
+
for (const piece of _chunkYNSK4MGTcjs.trimSegments.call(void 0, this.segs, sa, sb, this.lens)) {
|
|
1931
1931
|
if (degenerate(piece)) continue;
|
|
1932
1932
|
const last = _optionalChain([out, 'access', _38 => _38[out.length - 1], 'optionalAccess', _39 => _39.segs]);
|
|
1933
1933
|
const end = _optionalChain([last, 'optionalAccess', _40 => _40[last.length - 1], 'optionalAccess', _41 => _41.at, 'call', _42 => _42(-1)]);
|
|
@@ -2042,7 +2042,7 @@ function offsetPaths(paths, amount, join = "miter", miterLimit = 4, copies = 1,
|
|
|
2042
2042
|
const n = Math.min(1e3, Math.max(1, Math.round(Number.isFinite(copies) ? copies : 1)));
|
|
2043
2043
|
return paths.map((p) => {
|
|
2044
2044
|
const out = [];
|
|
2045
|
-
for (let i = 0; i < n; i++) out.push(...
|
|
2045
|
+
for (let i = 0; i < n; i++) out.push(..._chunkYNSK4MGTcjs.offsetPath.call(void 0, p, amount * (i + 1 + copyOffset), { join, miterLimit }));
|
|
2046
2046
|
return out;
|
|
2047
2047
|
});
|
|
2048
2048
|
}
|
|
@@ -2078,10 +2078,10 @@ function twistPaths(paths, angle, center) {
|
|
|
2078
2078
|
const segs = [];
|
|
2079
2079
|
for (const seg of sub5.segs) {
|
|
2080
2080
|
const cubic = seg.length === 2 ? [seg[0], seg[0], seg[1], seg[1]] : seg;
|
|
2081
|
-
const len2 =
|
|
2081
|
+
const len2 = _chunkYNSK4MGTcjs.segmentLength.call(void 0, seg);
|
|
2082
2082
|
const m = Math.min(64, Math.max(1, Math.ceil(Math.abs(a) * len2 / rmax / 0.15 + len2 / 50)));
|
|
2083
2083
|
for (let i = 0; i < m; i++) {
|
|
2084
|
-
const q =
|
|
2084
|
+
const q = _chunkYNSK4MGTcjs.subSegment.call(void 0, cubic, i / m, (i + 1) / m);
|
|
2085
2085
|
const p0 = map(q[0]);
|
|
2086
2086
|
const p3 = map(q[3]);
|
|
2087
2087
|
const h1 = jac(q[0], [q[1][0] - q[0][0], q[1][1] - q[0][1]]);
|
|
@@ -2097,7 +2097,7 @@ function twistPaths(paths, angle, center) {
|
|
|
2097
2097
|
function resample(sub5, m) {
|
|
2098
2098
|
const segs = sub5.segs;
|
|
2099
2099
|
const n = segs.length;
|
|
2100
|
-
const lens = segs.map((s) =>
|
|
2100
|
+
const lens = segs.map((s) => _chunkYNSK4MGTcjs.segmentLength.call(void 0, s));
|
|
2101
2101
|
const out = [];
|
|
2102
2102
|
for (let j = 0; j < n; j++) {
|
|
2103
2103
|
const piece = lens[j] / m;
|
|
@@ -2112,8 +2112,8 @@ function resample(sub5, m) {
|
|
|
2112
2112
|
}
|
|
2113
2113
|
out.push({ p: segs[j][0], tan, lenPrev: prev === null ? 0 : lens[prev] / m, lenNext: piece });
|
|
2114
2114
|
} else {
|
|
2115
|
-
const t =
|
|
2116
|
-
out.push({ p:
|
|
2115
|
+
const t = _chunkYNSK4MGTcjs.segmentParamAtLength.call(void 0, segs[j], piece * k, lens[j]);
|
|
2116
|
+
out.push({ p: _chunkYNSK4MGTcjs.segmentPoint.call(void 0, segs[j], t), tan: tangentAt(segs[j], t), lenPrev: piece, lenNext: piece });
|
|
2117
2117
|
}
|
|
2118
2118
|
}
|
|
2119
2119
|
}
|
|
@@ -2211,7 +2211,7 @@ function mergePaths(paths, mode = "merge") {
|
|
|
2211
2211
|
if (mode === "merge" || !(mode in MERGE_OPS)) return paths.flat();
|
|
2212
2212
|
const inputs = paths.filter((p) => p.length > 0).map((path) => ({ path, fillRule: "nonzero" }));
|
|
2213
2213
|
if (!inputs.length) return [];
|
|
2214
|
-
return
|
|
2214
|
+
return _chunkYNSK4MGTcjs.pathBoolean.call(void 0, MERGE_OPS[mode], inputs).path;
|
|
2215
2215
|
}
|
|
2216
2216
|
function vectorRepeaterCopies(r, pivot) {
|
|
2217
2217
|
const copies = Math.max(0, Number.isFinite(r.copies) ? Math.min(r.copies, 1e3) : 0);
|
|
@@ -2234,10 +2234,10 @@ function vectorRepeaterCopies(r, pivot) {
|
|
|
2234
2234
|
return out;
|
|
2235
2235
|
}
|
|
2236
2236
|
function repeatPaths(paths, r, pivot) {
|
|
2237
|
-
return vectorRepeaterCopies(r, pivot).map((copy) => ({ copy, paths: paths.map((p) =>
|
|
2237
|
+
return vectorRepeaterCopies(r, pivot).map((copy) => ({ copy, paths: paths.map((p) => _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, p, copy.matrix)) }));
|
|
2238
2238
|
}
|
|
2239
2239
|
function pathsCenter(paths) {
|
|
2240
|
-
const b =
|
|
2240
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, paths.flat());
|
|
2241
2241
|
return b ? { x: (b.minX + b.maxX) / 2, y: (b.minY + b.maxY) / 2 } : { x: 0, y: 0 };
|
|
2242
2242
|
}
|
|
2243
2243
|
|
|
@@ -2306,13 +2306,13 @@ function refit(seg, pieces, f, tol) {
|
|
|
2306
2306
|
const last = pieces[pieces.length - 1];
|
|
2307
2307
|
const t0 = !same(first[1], first[0]) ? first[1] : first[2];
|
|
2308
2308
|
const t1 = !same(last[2], last[3]) ? last[2] : last[1];
|
|
2309
|
-
const fitted =
|
|
2309
|
+
const fitted = _chunkYNSK4MGTcjs.fitCubicRun.call(void 0, samples, tol / 2, [t0.x - first[0].x, t0.y - first[0].y], [last[3].x - t1.x, last[3].y - t1.y]);
|
|
2310
2310
|
if (!fitted.length || fitted.length >= pieces.length) return pieces;
|
|
2311
2311
|
const chain = fitted.map((c) => [c.p0, c.p1, c.p2, c.p3]);
|
|
2312
2312
|
for (let i = 0; i < n; i++) {
|
|
2313
2313
|
const q = toPoint(f(evalCubic(seg, (i + 0.5) / n)));
|
|
2314
2314
|
let best = Infinity;
|
|
2315
|
-
for (const c of chain) best = Math.min(best,
|
|
2315
|
+
for (const c of chain) best = Math.min(best, _chunkYNSK4MGTcjs.segmentNearest.call(void 0, c, q).distance);
|
|
2316
2316
|
if (best > tol) return pieces;
|
|
2317
2317
|
}
|
|
2318
2318
|
return fitted.map((c) => [toVec2(c.p0), toVec2(c.p1), toVec2(c.p2), toVec2(c.p3)]);
|
|
@@ -3243,7 +3243,7 @@ function pathsBounds(paths) {
|
|
|
3243
3243
|
let maxX = -Infinity;
|
|
3244
3244
|
let maxY = -Infinity;
|
|
3245
3245
|
for (const p of paths) {
|
|
3246
|
-
const b =
|
|
3246
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, p);
|
|
3247
3247
|
if (!b) continue;
|
|
3248
3248
|
minX = Math.min(minX, b.minX);
|
|
3249
3249
|
minY = Math.min(minY, b.minY);
|
|
@@ -3409,7 +3409,7 @@ function foldVectorBooleanOperands(operands) {
|
|
|
3409
3409
|
for (let i = start + 1; i < operands.length; i++) {
|
|
3410
3410
|
const o = operands[i];
|
|
3411
3411
|
foldSteps++;
|
|
3412
|
-
const r =
|
|
3412
|
+
const r = _chunkYNSK4MGTcjs.pathBoolean.call(void 0, _nullishCoalesce(PATH_OPS[o.operation], () => ( "union")), [
|
|
3413
3413
|
{ path: acc, fillRule: accRule },
|
|
3414
3414
|
{ path: o.path, fillRule: o.fillRule }
|
|
3415
3415
|
]);
|
|
@@ -3496,7 +3496,7 @@ function childShapes(child, index) {
|
|
|
3496
3496
|
const k = _nullishCoalesce(child.opacity, () => ( 1));
|
|
3497
3497
|
return vectorAppearanceShapes(child).map((s) => ({
|
|
3498
3498
|
source: s.source,
|
|
3499
|
-
path: m && !isIdentityMatrix(m) ?
|
|
3499
|
+
path: m && !isIdentityMatrix(m) ? _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, s.path, m) : s.path,
|
|
3500
3500
|
opacity: s.opacity * k,
|
|
3501
3501
|
order: [index, ...s.order]
|
|
3502
3502
|
}));
|
|
@@ -3508,7 +3508,7 @@ function liveBooleanShapes(group) {
|
|
|
3508
3508
|
const shapes = childShapes(child, i);
|
|
3509
3509
|
if (!shapes.length) return;
|
|
3510
3510
|
source ??= shapes[0].source;
|
|
3511
|
-
const path = shapes.length === 1 ? shapes[0].path :
|
|
3511
|
+
const path = shapes.length === 1 ? shapes[0].path : _chunkYNSK4MGTcjs.pathBoolean.call(void 0, "union", shapes.map((s) => ({ path: s.path, fillRule: _nullishCoalesce(s.source.fillRule, () => ( "nonzero")) }))).path;
|
|
3512
3512
|
const fillRule = shapes.length === 1 ? _nullishCoalesce(shapes[0].source.fillRule, () => ( "nonzero")) : "nonzero";
|
|
3513
3513
|
operands.push({ path, fillRule, operation: vectorOperandOperation(group, child) });
|
|
3514
3514
|
});
|
|
@@ -3740,7 +3740,7 @@ function vectorNodeToBezier(node) {
|
|
|
3740
3740
|
}
|
|
3741
3741
|
function vectorPathData(input, precision = 3) {
|
|
3742
3742
|
const subpaths = Array.isArray(input) ? input : input.subpaths;
|
|
3743
|
-
return
|
|
3743
|
+
return _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, subpathsToBezier(subpaths), { precision });
|
|
3744
3744
|
}
|
|
3745
3745
|
function inferAnchorType(a) {
|
|
3746
3746
|
if (isOnAnchor(a, a.in) || isOnAnchor(a, a.out)) return "corner";
|
|
@@ -3756,7 +3756,7 @@ function inferAnchorType(a) {
|
|
|
3756
3756
|
return Math.abs(li - lo) <= 1e-3 * Math.max(li, lo) ? "symmetric" : "smooth";
|
|
3757
3757
|
}
|
|
3758
3758
|
function bezierToSubpaths(input) {
|
|
3759
|
-
const path =
|
|
3759
|
+
const path = _chunkYNSK4MGTcjs.toBezierPath.call(void 0, input);
|
|
3760
3760
|
const out = [];
|
|
3761
3761
|
let current = null;
|
|
3762
3762
|
const last = () => current.anchors[current.anchors.length - 1];
|
|
@@ -3853,7 +3853,7 @@ function nodeMatrix(node) {
|
|
|
3853
3853
|
function vectorPathWorldBezier(node, parent = IDENTITY_MATRIX, options = {}) {
|
|
3854
3854
|
const m = multiplyMatrices(nodeMatrix(node), parent);
|
|
3855
3855
|
const path = options.effects === false || !hasOwnVectorAppearance(node) ? subpathsToBezier(node.subpaths) : vectorAppearanceOutline(node);
|
|
3856
|
-
return isIdentityMatrix(m) ? path :
|
|
3856
|
+
return isIdentityMatrix(m) ? path : _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, path, m);
|
|
3857
3857
|
}
|
|
3858
3858
|
function vectorNodeBounds(node, parent = IDENTITY_MATRIX) {
|
|
3859
3859
|
node = expandVectorAppearance(node);
|
|
@@ -3861,7 +3861,7 @@ function vectorNodeBounds(node, parent = IDENTITY_MATRIX) {
|
|
|
3861
3861
|
const m = multiplyMatrices(nodeMatrix(node), parent);
|
|
3862
3862
|
return unionBounds(node.children.map((c) => vectorNodeBounds(c, m)));
|
|
3863
3863
|
}
|
|
3864
|
-
const b =
|
|
3864
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, vectorPathWorldBezier(node, parent));
|
|
3865
3865
|
if (!b) return null;
|
|
3866
3866
|
return { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY };
|
|
3867
3867
|
}
|
|
@@ -3896,9 +3896,9 @@ function hitTestVectorNode(node, p, tolerance = 0, parent = IDENTITY_MATRIX, opt
|
|
|
3896
3896
|
const path = vectorPathWorldBezier(node, parent);
|
|
3897
3897
|
if (path.length === 0) return false;
|
|
3898
3898
|
const point = [p.x, p.y];
|
|
3899
|
-
if (hasPaint(node.fill) &&
|
|
3899
|
+
if (hasPaint(node.fill) && _chunkYNSK4MGTcjs.pointInBezierPath.call(void 0, path, point, _nullishCoalesce(node.fillRule, () => ( "nonzero")))) return true;
|
|
3900
3900
|
if (hasPaint(node.stroke)) return hitTestVectorStroke(path, p, node, tolerance);
|
|
3901
|
-
return
|
|
3901
|
+
return _chunkYNSK4MGTcjs.distanceToBezierPath.call(void 0, path, point) <= tolerance;
|
|
3902
3902
|
}
|
|
3903
3903
|
function vectorStrokeOutline(node, parent = IDENTITY_MATRIX) {
|
|
3904
3904
|
if (!hasPaint(node.stroke) || !((_nullishCoalesce(node.strokeWidth, () => ( 1))) > 0)) return [];
|
|
@@ -3918,9 +3918,9 @@ function nearestSegment(node, p) {
|
|
|
3918
3918
|
const count = subpathSegmentCount(sp);
|
|
3919
3919
|
for (let i = 0; i < count; i++) {
|
|
3920
3920
|
const seg = subpathSegment(sp, i);
|
|
3921
|
-
const hit =
|
|
3921
|
+
const hit = _chunkYNSK4MGTcjs.segmentNearest.call(void 0, seg, [p.x, p.y]);
|
|
3922
3922
|
if (!best || hit.distance < best.distance) {
|
|
3923
|
-
const pt2 =
|
|
3923
|
+
const pt2 = _chunkYNSK4MGTcjs.segmentPoint.call(void 0, seg, hit.t);
|
|
3924
3924
|
best = { subpath: s, segment: i, t: hit.t, point: { x: pt2[0], y: pt2[1] }, distance: hit.distance };
|
|
3925
3925
|
}
|
|
3926
3926
|
}
|
|
@@ -4106,7 +4106,7 @@ function insertAnchor(sp, segment, t) {
|
|
|
4106
4106
|
const ia = segment;
|
|
4107
4107
|
const ib = (segment + 1) % n;
|
|
4108
4108
|
const seg = subpathSegment(sp, segment);
|
|
4109
|
-
const [left2, right] =
|
|
4109
|
+
const [left2, right] = _chunkYNSK4MGTcjs.splitSegment.call(void 0, seg, t);
|
|
4110
4110
|
const mid = left2[left2.length - 1];
|
|
4111
4111
|
const anchor = { x: mid[0], y: mid[1] };
|
|
4112
4112
|
if (seg.length === 4) {
|
|
@@ -4217,10 +4217,10 @@ var unit3 = (v2) => {
|
|
|
4217
4217
|
};
|
|
4218
4218
|
function flattenedSubpaths(node) {
|
|
4219
4219
|
const out = [];
|
|
4220
|
-
for (const contour of
|
|
4221
|
-
const segs =
|
|
4220
|
+
for (const contour of _chunkYNSK4MGTcjs.pathToContours.call(void 0, subpathsToBezier(node.subpaths))) {
|
|
4221
|
+
const segs = _chunkYNSK4MGTcjs.closeContour.call(void 0, contour);
|
|
4222
4222
|
if (!segs.length) continue;
|
|
4223
|
-
const ring =
|
|
4223
|
+
const ring = _chunkYNSK4MGTcjs.flattenChain.call(void 0, segs, TOLERANCE);
|
|
4224
4224
|
const pts = ring.map(([x, y]) => ({ x, y })).filter((p, i, a) => i === 0 || Math.hypot(p.x - a[i - 1].x, p.y - a[i - 1].y) > 1e-9);
|
|
4225
4225
|
if (contour.closed && pts.length > 2 && Math.hypot(pts[0].x - pts[pts.length - 1].x, pts[0].y - pts[pts.length - 1].y) < 1e-9) pts.pop();
|
|
4226
4226
|
if (pts.length >= 2) out.push({ pts, closed: contour.closed && pts.length > 2 });
|
|
@@ -4362,7 +4362,7 @@ function vectorCornersAttribute(subpaths, precision = 3) {
|
|
|
4362
4362
|
subpaths.forEach(
|
|
4363
4363
|
(sp, s) => sp.anchors.forEach((a, i) => {
|
|
4364
4364
|
if (!a.corner || !(a.corner.radius > 0)) return;
|
|
4365
|
-
out.push(`${s}.${i}:${
|
|
4365
|
+
out.push(`${s}.${i}:${_chunkYNSK4MGTcjs.formatNumber.call(void 0, a.corner.radius, precision)}${a.corner.kind && a.corner.kind !== "round" ? `:${a.corner.kind}` : ""}`);
|
|
4366
4366
|
})
|
|
4367
4367
|
);
|
|
4368
4368
|
return out.join(" ");
|
|
@@ -4381,7 +4381,7 @@ function applyVectorCornersAttribute(subpaths, value) {
|
|
|
4381
4381
|
}
|
|
4382
4382
|
var escapeAttr = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
4383
4383
|
function vectorPathLocalBounds(node) {
|
|
4384
|
-
const b =
|
|
4384
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, subpathsToBezier(node.subpaths));
|
|
4385
4385
|
return b ? { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY } : null;
|
|
4386
4386
|
}
|
|
4387
4387
|
var paintCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -4421,22 +4421,22 @@ function computeStrokeSvgParts(node, clipId, precision) {
|
|
|
4421
4421
|
if (parts.align === "center" && !parts.heads.length && !profiled) return void 0;
|
|
4422
4422
|
let clip = null;
|
|
4423
4423
|
if (parts.align !== "center") {
|
|
4424
|
-
const b =
|
|
4424
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, path);
|
|
4425
4425
|
const pad = vectorStrokeReach(node) + 1;
|
|
4426
4426
|
const bounds = b ? { x: round2(b.minX - pad), y: round2(b.minY - pad), width: round2(b.maxX - b.minX + 2 * pad), height: round2(b.maxY - b.minY + 2 * pad) } : { x: 0, y: 0, width: 0, height: 0 };
|
|
4427
4427
|
clip = { kind: parts.align === "inside" ? "clip" : "mask", id: clipId, bounds };
|
|
4428
4428
|
}
|
|
4429
4429
|
return {
|
|
4430
4430
|
align: parts.align,
|
|
4431
|
-
d:
|
|
4431
|
+
d: _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, parts.line, { precision }),
|
|
4432
4432
|
width: parts.drawWidth,
|
|
4433
|
-
...profiled && (_nullishCoalesce(node.strokeWidth, () => ( 1))) > 0 ? { outline:
|
|
4433
|
+
...profiled && (_nullishCoalesce(node.strokeWidth, () => ( 1))) > 0 ? { outline: _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, vectorStrokeLineArea(parts, node), { precision }) } : {},
|
|
4434
4434
|
clip,
|
|
4435
|
-
heads: parts.heads.map((h) =>
|
|
4435
|
+
heads: parts.heads.map((h) => _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, h.path, { precision }))
|
|
4436
4436
|
};
|
|
4437
4437
|
}
|
|
4438
4438
|
function widthProfileToAttribute(points, precision = 4) {
|
|
4439
|
-
return points.map((p) => [p.t, p.left, p.right].map((n) =>
|
|
4439
|
+
return points.map((p) => [p.t, p.left, p.right].map((n) => _chunkYNSK4MGTcjs.formatNumber.call(void 0, n, precision)).join(",")).join(";");
|
|
4440
4440
|
}
|
|
4441
4441
|
function widthProfileFromAttribute(value) {
|
|
4442
4442
|
if (!value) return [];
|
|
@@ -4495,11 +4495,11 @@ function vectorDocumentToSvg(doc, options = {}) {
|
|
|
4495
4495
|
const pretty = options.pretty !== false;
|
|
4496
4496
|
const defs = [];
|
|
4497
4497
|
const lines = [];
|
|
4498
|
-
const num2 = (n) =>
|
|
4498
|
+
const num2 = (n) => _chunkYNSK4MGTcjs.formatNumber.call(void 0, n, precision);
|
|
4499
4499
|
const indent = (depth) => pretty ? " ".repeat(depth) : "";
|
|
4500
4500
|
const common = (node) => {
|
|
4501
4501
|
let out2 = ` id="${escapeAttr(node.id)}"`;
|
|
4502
|
-
if (node.transform) out2 += ` transform="matrix(${node.transform.map((n) =>
|
|
4502
|
+
if (node.transform) out2 += ` transform="matrix(${node.transform.map((n) => _chunkYNSK4MGTcjs.formatNumber.call(void 0, n, 6)).join(" ")})"`;
|
|
4503
4503
|
if (node.opacity !== void 0 && node.opacity < 1) out2 += ` opacity="${num2(node.opacity)}"`;
|
|
4504
4504
|
if (node.visible === false) out2 += ` display="none"`;
|
|
4505
4505
|
if (node.blendStep) out2 += ` data-vector-blend-step=""`;
|
|
@@ -4539,7 +4539,7 @@ function vectorDocumentToSvg(doc, options = {}) {
|
|
|
4539
4539
|
defs.push(...paintMarkup(node.fill, fill.defs), ...paintMarkup(node.stroke, stroke.defs));
|
|
4540
4540
|
const d = vectorPathData(node, precision);
|
|
4541
4541
|
const corners2 = vectorCornersAttribute(node.subpaths, precision);
|
|
4542
|
-
const live = corners2 ? ` data-vector-d="${
|
|
4542
|
+
const live = corners2 ? ` data-vector-d="${_chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, subpathsToBezier(node.subpaths, { corners: false }), { precision })}" data-vector-corners="${corners2}"` : "";
|
|
4543
4543
|
const fillAttrs = ` fill="${escapeAttr(fill.value)}"${node.fillRule === "evenodd" ? ` fill-rule="evenodd"` : ""}`;
|
|
4544
4544
|
const lineAttrs = (width) => {
|
|
4545
4545
|
let out2 = ` stroke="${escapeAttr(stroke.value)}" stroke-width="${num2(width)}"`;
|
|
@@ -4570,7 +4570,7 @@ function vectorDocumentToSvg(doc, options = {}) {
|
|
|
4570
4570
|
lines.push(`${indent(depth)}<g${common(node)}${data}>`);
|
|
4571
4571
|
lines.push(`${indent(depth + 1)}<path data-vector-part="fill" d="${d}"${fillAttrs}${live}/>`);
|
|
4572
4572
|
if (options.strokes === "outline") {
|
|
4573
|
-
const area =
|
|
4573
|
+
const area = _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, vectorStrokeOutlinePath(subpathsToBezier(node.subpaths), node), { precision });
|
|
4574
4574
|
lines.push(`${indent(depth + 1)}<path data-vector-part="stroke-outline" d="${area}" fill="${escapeAttr(stroke.value)}"/>`);
|
|
4575
4575
|
} else {
|
|
4576
4576
|
let clip = "";
|
|
@@ -4788,7 +4788,7 @@ function resolveGradient(id, raw) {
|
|
|
4788
4788
|
const y2 = at2("y2", 0);
|
|
4789
4789
|
if (!user && plain3) {
|
|
4790
4790
|
const angle = Math.round((Math.atan2(x2 - x1, -(y2 - y1)) * 180 / Math.PI + 360) % 360);
|
|
4791
|
-
const c =
|
|
4791
|
+
const c = _chunkYNSK4MGTcjs.angleToSvgLinearCoords.call(void 0, angle);
|
|
4792
4792
|
const len2 = Math.hypot(x2 - x1, y2 - y1);
|
|
4793
4793
|
const d = len2 > 0 ? { x: (x2 - x1) / len2, y: (y2 - y1) / len2 } : { x: 0, y: 1 };
|
|
4794
4794
|
const along2 = (x, y) => x * d.x + y * d.y;
|
|
@@ -5178,7 +5178,7 @@ function refineMorphContour(c, segments) {
|
|
|
5178
5178
|
const identity = Array.from({ length: c.closed ? have : have + 1 }, (_, i) => i);
|
|
5179
5179
|
if (have >= segments) return { contour: c, anchors: identity };
|
|
5180
5180
|
const segs = Array.from({ length: have }, (_, k) => segOf(c, k));
|
|
5181
|
-
const lens = segs.map((s) =>
|
|
5181
|
+
const lens = segs.map((s) => _chunkYNSK4MGTcjs.segmentLength.call(void 0, s));
|
|
5182
5182
|
const sum = lens.reduce((a, b) => a + b, 0);
|
|
5183
5183
|
const extra = segments - have;
|
|
5184
5184
|
const want = lens.map((l) => sum > 1e-12 ? l / sum * extra : extra / have);
|
|
@@ -5195,9 +5195,9 @@ function refineMorphContour(c, segments) {
|
|
|
5195
5195
|
let rest = seg.slice();
|
|
5196
5196
|
let t0 = 0;
|
|
5197
5197
|
for (let j = 1; j < pieces; j++) {
|
|
5198
|
-
const t =
|
|
5198
|
+
const t = _chunkYNSK4MGTcjs.segmentParamAtLength.call(void 0, seg, lens[k] * j / pieces, lens[k]);
|
|
5199
5199
|
const u = Math.min(1, Math.max(0, (t - t0) / (1 - t0 || 1)));
|
|
5200
|
-
const [l, r] =
|
|
5200
|
+
const [l, r] = _chunkYNSK4MGTcjs.splitSegment.call(void 0, rest, u);
|
|
5201
5201
|
pts.push(l[1], l[2], l[3]);
|
|
5202
5202
|
rest = r;
|
|
5203
5203
|
t0 = t;
|
|
@@ -5359,7 +5359,7 @@ function correspondMorphContours(a, b, options = {}) {
|
|
|
5359
5359
|
const bb = boundsOfPoints(b.flatMap((c) => c.pts));
|
|
5360
5360
|
const contourLength = (c) => {
|
|
5361
5361
|
let l = 0;
|
|
5362
|
-
for (let k = 0; k < curvesOf(c); k++) l +=
|
|
5362
|
+
for (let k = 0; k < curvesOf(c); k++) l += _chunkYNSK4MGTcjs.segmentLength.call(void 0, segOf(c, k));
|
|
5363
5363
|
return l;
|
|
5364
5364
|
};
|
|
5365
5365
|
const pairs = [];
|
|
@@ -5868,8 +5868,8 @@ function vectorBlendRail(sp) {
|
|
|
5868
5868
|
for (let i = 0; i < count; i++) {
|
|
5869
5869
|
const seg = subpathSegment(sp, i);
|
|
5870
5870
|
const samples = seg.length === 2 ? 1 : 32;
|
|
5871
|
-
if (i === 0) push(seg[0],
|
|
5872
|
-
for (let k = 1; k <= samples; k++) push(
|
|
5871
|
+
if (i === 0) push(seg[0], _chunkYNSK4MGTcjs.segmentTangent.call(void 0, seg, 0));
|
|
5872
|
+
for (let k = 1; k <= samples; k++) push(_chunkYNSK4MGTcjs.segmentPoint.call(void 0, seg, k / samples), _chunkYNSK4MGTcjs.segmentTangent.call(void 0, seg, k / samples));
|
|
5873
5873
|
}
|
|
5874
5874
|
if (pts.length < 2) return null;
|
|
5875
5875
|
const cum = [0];
|
|
@@ -6555,13 +6555,13 @@ var VectorSnapTargets = (_class3 = class _VectorSnapTargets {
|
|
|
6555
6555
|
const pt2 = toPoint2(p);
|
|
6556
6556
|
for (const s of this.segments) {
|
|
6557
6557
|
if (p.x < s.minX - tol || p.x > s.maxX + tol || p.y < s.minY - tol || p.y > s.maxY + tol) continue;
|
|
6558
|
-
const hit =
|
|
6558
|
+
const hit = _chunkYNSK4MGTcjs.segmentNearest.call(void 0, s.seg, pt2);
|
|
6559
6559
|
if (hit.distance <= tol) out.push({ seg: s.seg, t: hit.t, distance: hit.distance });
|
|
6560
6560
|
}
|
|
6561
6561
|
return out.sort((a, b) => a.distance - b.distance);
|
|
6562
6562
|
}
|
|
6563
6563
|
onSegment(near2) {
|
|
6564
|
-
return near2.length ? toVec3(
|
|
6564
|
+
return near2.length ? toVec3(_chunkYNSK4MGTcjs.segmentPoint.call(void 0, near2[0].seg, near2[0].t)) : null;
|
|
6565
6565
|
}
|
|
6566
6566
|
/** Where two of the target segments near `p` cross, the crossing nearest `p` within `tol`. */
|
|
6567
6567
|
crossing(near2, p, tol) {
|
|
@@ -6570,7 +6570,7 @@ var VectorSnapTargets = (_class3 = class _VectorSnapTargets {
|
|
|
6570
6570
|
let bestD = Infinity;
|
|
6571
6571
|
for (let i = 0; i < list.length; i++) {
|
|
6572
6572
|
for (let j = i + 1; j < list.length; j++) {
|
|
6573
|
-
for (const hit of
|
|
6573
|
+
for (const hit of _chunkYNSK4MGTcjs.segmentIntersections.call(void 0, list[i].seg, list[j].seg)) {
|
|
6574
6574
|
const q = toVec3(hit.point);
|
|
6575
6575
|
const d = distance(q, p);
|
|
6576
6576
|
if (d <= tol && d < bestD) {
|
|
@@ -6892,15 +6892,15 @@ var crossCondition = (r, d) => r[0] * d[1] - r[1] * d[0];
|
|
|
6892
6892
|
function solveOnSegment(seg, base, cond) {
|
|
6893
6893
|
const b = [base.x, base.y];
|
|
6894
6894
|
const g = (t) => {
|
|
6895
|
-
const p =
|
|
6896
|
-
return cond([p[0] - b[0], p[1] - b[1]],
|
|
6895
|
+
const p = _chunkYNSK4MGTcjs.segmentPoint.call(void 0, seg, t);
|
|
6896
|
+
return cond([p[0] - b[0], p[1] - b[1]], _chunkYNSK4MGTcjs.segmentDerivative.call(void 0, seg, t));
|
|
6897
6897
|
};
|
|
6898
6898
|
const vals = [];
|
|
6899
6899
|
let scale3 = 0;
|
|
6900
6900
|
for (let i = 0; i <= CURVE_SAMPLES; i++) {
|
|
6901
6901
|
const t = i / CURVE_SAMPLES;
|
|
6902
|
-
const p =
|
|
6903
|
-
const d =
|
|
6902
|
+
const p = _chunkYNSK4MGTcjs.segmentPoint.call(void 0, seg, t);
|
|
6903
|
+
const d = _chunkYNSK4MGTcjs.segmentDerivative.call(void 0, seg, t);
|
|
6904
6904
|
const r = [p[0] - b[0], p[1] - b[1]];
|
|
6905
6905
|
vals.push(cond(r, d));
|
|
6906
6906
|
scale3 = Math.max(scale3, Math.hypot(r[0], r[1]) * Math.hypot(d[0], d[1]));
|
|
@@ -6927,8 +6927,8 @@ function solveOnSegment(seg, base, cond) {
|
|
|
6927
6927
|
} else hi = m;
|
|
6928
6928
|
}
|
|
6929
6929
|
const t = (lo + hi) / 2;
|
|
6930
|
-
const p =
|
|
6931
|
-
const dv =
|
|
6930
|
+
const p = _chunkYNSK4MGTcjs.segmentPoint.call(void 0, seg, t);
|
|
6931
|
+
const dv = _chunkYNSK4MGTcjs.segmentDerivative.call(void 0, seg, t);
|
|
6932
6932
|
const r = Math.hypot(p[0] - b[0], p[1] - b[1]);
|
|
6933
6933
|
const dl = Math.hypot(dv[0], dv[1]);
|
|
6934
6934
|
if (!(r > 1e-9 && dl > 0) || Math.abs(cond([p[0] - b[0], p[1] - b[1]], dv)) > 1e-6 * r * dl) continue;
|
|
@@ -6965,7 +6965,7 @@ function endTangent2(c) {
|
|
|
6965
6965
|
return [1, 0];
|
|
6966
6966
|
}
|
|
6967
6967
|
function sample(c, n, out, withStart) {
|
|
6968
|
-
for (let i = withStart ? 0 : 1; i <= n; i++) out.push(
|
|
6968
|
+
for (let i = withStart ? 0 : 1; i <= n; i++) out.push(_chunkYNSK4MGTcjs.segmentPoint.call(void 0, c, i / n));
|
|
6969
6969
|
}
|
|
6970
6970
|
var onAnchor2 = (a, h) => !h || Math.abs(h.x - a.x) < EPS4 && Math.abs(h.y - a.y) < EPS4;
|
|
6971
6971
|
function tidy(a, keepType = true) {
|
|
@@ -7011,7 +7011,7 @@ function fitAcross(pts, N, t0, t1) {
|
|
|
7011
7011
|
const u = [];
|
|
7012
7012
|
for (let i = 0; i <= N; i++) u.push(k * i / N);
|
|
7013
7013
|
for (let i = 1; i <= N; i++) u.push(k + (1 - k) * i / N);
|
|
7014
|
-
return
|
|
7014
|
+
return _chunkYNSK4MGTcjs.fitCubicWithTangents.call(void 0, pts, u, t0, t1);
|
|
7015
7015
|
};
|
|
7016
7016
|
return goldenMin(fit, 0, 1);
|
|
7017
7017
|
}
|
|
@@ -7071,7 +7071,7 @@ function bendSegment(sp, segment, t, p) {
|
|
|
7071
7071
|
return { anchors, closed: sp.closed };
|
|
7072
7072
|
}
|
|
7073
7073
|
function subpathPointAt(sp, segment, t) {
|
|
7074
|
-
const [x, y] =
|
|
7074
|
+
const [x, y] = _chunkYNSK4MGTcjs.segmentPoint.call(void 0, subpathSegment(sp, segment), t);
|
|
7075
7075
|
return { x, y };
|
|
7076
7076
|
}
|
|
7077
7077
|
function curvatureMoveAnchor(sp, index, q) {
|
|
@@ -7332,12 +7332,12 @@ function removeRedundantPoints(sp, tolerance) {
|
|
|
7332
7332
|
}
|
|
7333
7333
|
|
|
7334
7334
|
// src/vector/pathCut.ts
|
|
7335
|
-
var loopArea = (l) =>
|
|
7335
|
+
var loopArea = (l) => _chunkYNSK4MGTcjs.contourSignedArea.call(void 0, l.segs);
|
|
7336
7336
|
function loopSample(l) {
|
|
7337
7337
|
const k = l.chord.findIndex((c) => !c);
|
|
7338
|
-
return
|
|
7338
|
+
return _chunkYNSK4MGTcjs.segmentPoint.call(void 0, l.segs[k >= 0 ? k : 0], 0.5);
|
|
7339
7339
|
}
|
|
7340
|
-
var contains2 = (l, p) =>
|
|
7340
|
+
var contains2 = (l, p) => _chunkYNSK4MGTcjs.windingNumber.call(void 0, [l.segs], p) !== 0;
|
|
7341
7341
|
function groupFaces(loops) {
|
|
7342
7342
|
const usable2 = loops.filter((l) => l.segs.length && Math.abs(loopArea(l)) > 1e-12);
|
|
7343
7343
|
if (!usable2.length) return [];
|
|
@@ -7353,12 +7353,12 @@ function groupFaces(loops) {
|
|
|
7353
7353
|
return outers.reverse().map((o) => faces.get(o));
|
|
7354
7354
|
}
|
|
7355
7355
|
function faceToPath(face) {
|
|
7356
|
-
return
|
|
7356
|
+
return _chunkYNSK4MGTcjs.contoursToPath.call(void 0, face.loops.map((l) => ({ segments: l.segs, closed: true })));
|
|
7357
7357
|
}
|
|
7358
7358
|
function facesOf(path, fillRule) {
|
|
7359
|
-
const normalized =
|
|
7360
|
-
const loops =
|
|
7361
|
-
const segs =
|
|
7359
|
+
const normalized = _chunkYNSK4MGTcjs.normalizeBezierPath.call(void 0, path, fillRule);
|
|
7360
|
+
const loops = _chunkYNSK4MGTcjs.pathToContours.call(void 0, normalized).map((c) => {
|
|
7361
|
+
const segs = _chunkYNSK4MGTcjs.closeContour.call(void 0, c, true).map((s) => s.slice());
|
|
7362
7362
|
return { segs, chord: segs.map(() => false) };
|
|
7363
7363
|
});
|
|
7364
7364
|
return groupFaces(loops);
|
|
@@ -7428,7 +7428,7 @@ function lineHits(p, q, seg) {
|
|
|
7428
7428
|
const scale3 = Math.sqrt(len2) * Math.max(1, ...seg.map((pt2) => Math.abs(pt2[0]) + Math.abs(pt2[1])));
|
|
7429
7429
|
const out = [];
|
|
7430
7430
|
for (const t of rootsInUnit(...coeffs, scale3)) {
|
|
7431
|
-
const point =
|
|
7431
|
+
const point = _chunkYNSK4MGTcjs.segmentPoint.call(void 0, seg, t);
|
|
7432
7432
|
const s = ((point[0] - p[0]) * dx + (point[1] - p[1]) * dy) / len2;
|
|
7433
7433
|
if (s >= -1e-9 && s <= 1 + 1e-9) out.push({ s: Math.min(1, Math.max(0, s)), t, point });
|
|
7434
7434
|
}
|
|
@@ -7441,7 +7441,7 @@ function arc(l, a, b, eps) {
|
|
|
7441
7441
|
const segs = [];
|
|
7442
7442
|
const chord = [];
|
|
7443
7443
|
const push = (k, t0, t1) => {
|
|
7444
|
-
const piece = t0 <= 0 && t1 >= 1 ? l.segs[k].slice() :
|
|
7444
|
+
const piece = t0 <= 0 && t1 >= 1 ? l.segs[k].slice() : _chunkYNSK4MGTcjs.subSegment.call(void 0, l.segs[k], t0, t1);
|
|
7445
7445
|
if (!degenerate2(piece, eps)) {
|
|
7446
7446
|
segs.push(piece);
|
|
7447
7447
|
chord.push(l.chord[k]);
|
|
@@ -7466,7 +7466,7 @@ function knifePath(path, fillRule, knife) {
|
|
|
7466
7466
|
if (pts.length < 2) return null;
|
|
7467
7467
|
let faces = facesOf(path, fillRule);
|
|
7468
7468
|
if (!faces.length) return null;
|
|
7469
|
-
const b =
|
|
7469
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, path);
|
|
7470
7470
|
const size = b ? Math.max(b.maxX - b.minX, b.maxY - b.minY, 1) : 1;
|
|
7471
7471
|
const eps = size * 1e-9;
|
|
7472
7472
|
let cursor = -Infinity;
|
|
@@ -7480,7 +7480,7 @@ function knifePath(path, fillRule, knife) {
|
|
|
7480
7480
|
const kb = { minX: Math.min(pts[m][0], pts[m + 1][0]), maxX: Math.max(pts[m][0], pts[m + 1][0]), minY: Math.min(pts[m][1], pts[m + 1][1]), maxY: Math.max(pts[m][1], pts[m + 1][1]) };
|
|
7481
7481
|
face2.loops.forEach(
|
|
7482
7482
|
(l, li) => l.segs.forEach((seg, si) => {
|
|
7483
|
-
const sb =
|
|
7483
|
+
const sb = _chunkYNSK4MGTcjs.segmentBounds.call(void 0, seg);
|
|
7484
7484
|
if (sb.maxX < kb.minX - eps || sb.minX > kb.maxX + eps || sb.maxY < kb.minY - eps || sb.minY > kb.maxY + eps) return;
|
|
7485
7485
|
for (const h of lineHits(pts[m], pts[m + 1], seg)) {
|
|
7486
7486
|
const s = m + h.s;
|
|
@@ -7495,7 +7495,7 @@ function knifePath(path, fillRule, knife) {
|
|
|
7495
7495
|
const m = Math.min(pts.length - 2, Math.floor(s));
|
|
7496
7496
|
const u = s - m;
|
|
7497
7497
|
const q = [pts[m][0] + (pts[m + 1][0] - pts[m][0]) * u, pts[m][1] + (pts[m + 1][1] - pts[m][1]) * u];
|
|
7498
|
-
return
|
|
7498
|
+
return _chunkYNSK4MGTcjs.windingNumber.call(void 0, face2.loops.map((l) => l.segs), q) !== 0;
|
|
7499
7499
|
};
|
|
7500
7500
|
for (let i = 0; i < unique.length - 1; i++) {
|
|
7501
7501
|
const from2 = unique[i];
|
|
@@ -7555,33 +7555,33 @@ function eraserRegion(points, width) {
|
|
|
7555
7555
|
];
|
|
7556
7556
|
}
|
|
7557
7557
|
const line2 = [{ type: "M", x: pts[0][0], y: pts[0][1] }, ...pts.slice(1).map((p) => ({ type: "L", x: p[0], y: p[1] }))];
|
|
7558
|
-
return
|
|
7558
|
+
return _chunkYNSK4MGTcjs.outlineStroke.call(void 0, line2, { width, cap: "round", join: "round" });
|
|
7559
7559
|
}
|
|
7560
7560
|
function eraseFromFill(path, fillRule, region) {
|
|
7561
|
-
const overlap =
|
|
7562
|
-
if (!
|
|
7563
|
-
const rest =
|
|
7561
|
+
const overlap = _chunkYNSK4MGTcjs.pathBoolean.call(void 0, "intersection", [{ path, fillRule }, { path: region }]).path;
|
|
7562
|
+
if (!_chunkYNSK4MGTcjs.pathToContours.call(void 0, overlap).some((c) => Math.abs(_chunkYNSK4MGTcjs.contourSignedArea.call(void 0, _chunkYNSK4MGTcjs.closeContour.call(void 0, c, true))) > 1e-9)) return null;
|
|
7563
|
+
const rest = _chunkYNSK4MGTcjs.pathBoolean.call(void 0, "difference", [{ path, fillRule }, { path: region }]).path;
|
|
7564
7564
|
return splitIntoFaces(rest);
|
|
7565
7565
|
}
|
|
7566
7566
|
function eraseFromOutline(sp, region) {
|
|
7567
|
-
const regionSegs =
|
|
7567
|
+
const regionSegs = _chunkYNSK4MGTcjs.pathToContours.call(void 0, region).flatMap((c) => _chunkYNSK4MGTcjs.closeContour.call(void 0, c, true));
|
|
7568
7568
|
if (!regionSegs.length) return null;
|
|
7569
|
-
const rb =
|
|
7569
|
+
const rb = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, region);
|
|
7570
7570
|
const count = subpathSegmentCount(sp);
|
|
7571
7571
|
if (!rb || count === 0) return null;
|
|
7572
|
-
const removed = (p) =>
|
|
7572
|
+
const removed = (p) => _chunkYNSK4MGTcjs.pointInBezierPath.call(void 0, region, p, "nonzero");
|
|
7573
7573
|
const runs = [];
|
|
7574
7574
|
let cur = [];
|
|
7575
7575
|
let any = false;
|
|
7576
7576
|
for (let i = 0; i < count; i++) {
|
|
7577
7577
|
const seg = subpathSegment(sp, i);
|
|
7578
|
-
const sb =
|
|
7578
|
+
const sb = _chunkYNSK4MGTcjs.segmentBounds.call(void 0, seg);
|
|
7579
7579
|
const ts = [0, 1];
|
|
7580
7580
|
if (!(sb.maxX < rb.minX || sb.minX > rb.maxX || sb.maxY < rb.minY || sb.minY > rb.maxY)) {
|
|
7581
7581
|
for (const r of regionSegs) {
|
|
7582
|
-
const b =
|
|
7582
|
+
const b = _chunkYNSK4MGTcjs.segmentBounds.call(void 0, r);
|
|
7583
7583
|
if (b.maxX < sb.minX || b.minX > sb.maxX || b.maxY < sb.minY || b.minY > sb.maxY) continue;
|
|
7584
|
-
for (const hit of
|
|
7584
|
+
for (const hit of _chunkYNSK4MGTcjs.segmentIntersections.call(void 0, seg, r)) if (hit.ta > 1e-9 && hit.ta < 1 - 1e-9) ts.push(hit.ta);
|
|
7585
7585
|
}
|
|
7586
7586
|
}
|
|
7587
7587
|
ts.sort((a, b) => a - b);
|
|
@@ -7589,7 +7589,7 @@ function eraseFromOutline(sp, region) {
|
|
|
7589
7589
|
const t0 = ts[k];
|
|
7590
7590
|
const t1 = ts[k + 1];
|
|
7591
7591
|
if (t1 - t0 < 1e-9) continue;
|
|
7592
|
-
if (removed(
|
|
7592
|
+
if (removed(_chunkYNSK4MGTcjs.segmentPoint.call(void 0, seg, (t0 + t1) / 2))) {
|
|
7593
7593
|
any = true;
|
|
7594
7594
|
if (cur.length) runs.push(cur);
|
|
7595
7595
|
cur = [];
|
|
@@ -7608,7 +7608,7 @@ function eraseFromOutline(sp, region) {
|
|
|
7608
7608
|
for (const run of runs) {
|
|
7609
7609
|
const anchors = [];
|
|
7610
7610
|
for (const { seg, t0, t1 } of run) {
|
|
7611
|
-
const c =
|
|
7611
|
+
const c = _chunkYNSK4MGTcjs.subSegment.call(void 0, subpathSegment(sp, seg), t0, t1);
|
|
7612
7612
|
const line2 = c.length === 2;
|
|
7613
7613
|
const start = c[0];
|
|
7614
7614
|
const end = c[c.length - 1];
|
|
@@ -7917,14 +7917,14 @@ function worldOf(entry, subpaths) {
|
|
|
7917
7917
|
return vectorPathWorldBezier({ ...entry.node, subpaths }, entry.parent);
|
|
7918
7918
|
}
|
|
7919
7919
|
function subpathEnclosesArea(sp) {
|
|
7920
|
-
const contour =
|
|
7920
|
+
const contour = _chunkYNSK4MGTcjs.pathToContours.call(void 0, subpathsToBezier([{ ...sp, closed: true }]))[0];
|
|
7921
7921
|
if (!contour) return false;
|
|
7922
|
-
const segs =
|
|
7923
|
-
const b =
|
|
7922
|
+
const segs = _chunkYNSK4MGTcjs.closeContour.call(void 0, contour, true);
|
|
7923
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, _chunkYNSK4MGTcjs.contoursToPath.call(void 0, [{ segments: segs, closed: true }]));
|
|
7924
7924
|
if (!b) return false;
|
|
7925
7925
|
const w = b.maxX - b.minX;
|
|
7926
7926
|
const h = b.maxY - b.minY;
|
|
7927
|
-
return Math.abs(
|
|
7927
|
+
return Math.abs(_chunkYNSK4MGTcjs.contourSignedArea.call(void 0, segs)) > 1e-9 * (w * w + h * h);
|
|
7928
7928
|
}
|
|
7929
7929
|
var paintKey = (paint) => typeof paint === "string" ? paint.trim().toLowerCase() : JSON.stringify(_nullishCoalesce(paint, () => ( null)));
|
|
7930
7930
|
function vectorPathfinderShape(entry, op) {
|
|
@@ -7977,18 +7977,18 @@ function vectorShapeBuilderMap(entries) {
|
|
|
7977
7977
|
lines.push(!subpaths.some((s) => s.closed));
|
|
7978
7978
|
return { path: worldOf(entry, subpaths), fillRule: _nullishCoalesce(entry.node.fillRule, () => ( "nonzero")) };
|
|
7979
7979
|
});
|
|
7980
|
-
const map =
|
|
7980
|
+
const map = _chunkYNSK4MGTcjs.PlanarMap.build(inputs);
|
|
7981
7981
|
if (!map) return null;
|
|
7982
7982
|
let chains = null;
|
|
7983
7983
|
const runs = (line2) => (chains ??= map.chains()).filter((c) => lines[c.source] === line2 && !(line2 && c.closed)).map((c) => {
|
|
7984
|
-
const path =
|
|
7985
|
-
return { path, segments: c.segments, closed: c.closed, source: c.source, bounds:
|
|
7984
|
+
const path = _chunkYNSK4MGTcjs.contoursToPath.call(void 0, [{ segments: c.segments, closed: c.closed }]);
|
|
7985
|
+
return { path, segments: c.segments, closed: c.closed, source: c.source, bounds: _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, path) };
|
|
7986
7986
|
});
|
|
7987
7987
|
const pieces = lines.some(Boolean) ? runs(true) : [];
|
|
7988
7988
|
let edges = null;
|
|
7989
7989
|
let size = 0;
|
|
7990
7990
|
for (const input of inputs) {
|
|
7991
|
-
const b =
|
|
7991
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, input.path);
|
|
7992
7992
|
if (b) size = Math.max(size, b.maxX - b.minX, b.maxY - b.minY);
|
|
7993
7993
|
}
|
|
7994
7994
|
return {
|
|
@@ -8008,7 +8008,7 @@ function pieceNear(pieces, p, tol) {
|
|
|
8008
8008
|
pieces.forEach((piece, index) => {
|
|
8009
8009
|
const b = piece.bounds;
|
|
8010
8010
|
if (p.x < b.minX - tol || p.x > b.maxX + tol || p.y < b.minY - tol || p.y > b.maxY + tol) return;
|
|
8011
|
-
const d =
|
|
8011
|
+
const d = _chunkYNSK4MGTcjs.distanceToBezierPath.call(void 0, piece.path, point);
|
|
8012
8012
|
if (d <= tol && (!best || d < best.d)) best = { index, d };
|
|
8013
8013
|
});
|
|
8014
8014
|
return best;
|
|
@@ -8045,8 +8045,8 @@ function addBuilderHit(touched, hit) {
|
|
|
8045
8045
|
}
|
|
8046
8046
|
function sides(m, piece) {
|
|
8047
8047
|
const seg = piece.segments[Math.floor(piece.segments.length / 2)];
|
|
8048
|
-
const mid =
|
|
8049
|
-
const t =
|
|
8048
|
+
const mid = _chunkYNSK4MGTcjs.segmentPoint.call(void 0, seg, 0.5);
|
|
8049
|
+
const t = _chunkYNSK4MGTcjs.segmentTangent.call(void 0, seg, 0.5);
|
|
8050
8050
|
const chord = Math.hypot(seg[seg.length - 1][0] - seg[0][0], seg[seg.length - 1][1] - seg[0][1]);
|
|
8051
8051
|
const off = Math.max(1e-6, Math.min(0.05, 0.05 * chord));
|
|
8052
8052
|
return [m.map.faceAt([mid[0] - t[1] * off, mid[1] + t[0] * off]), m.map.faceAt([mid[0] + t[1] * off, mid[1] - t[0] * off])];
|
|
@@ -8080,7 +8080,7 @@ function planShapeBuilder(m, touched, erase) {
|
|
|
8080
8080
|
const fillCloses = hasPaint(entry.node.fill);
|
|
8081
8081
|
let cut = false;
|
|
8082
8082
|
for (const piece of cuts) {
|
|
8083
|
-
const r = rest.length ?
|
|
8083
|
+
const r = rest.length ? _chunkYNSK4MGTcjs.cutOutPiece.call(void 0, rest, piece, fillCloses, m.tolerance) : null;
|
|
8084
8084
|
if (r) {
|
|
8085
8085
|
rest = r;
|
|
8086
8086
|
cut = true;
|
|
@@ -8101,7 +8101,7 @@ function planShapeBuilder(m, touched, erase) {
|
|
|
8101
8101
|
}
|
|
8102
8102
|
function vectorFillMap(doc, gap = 0) {
|
|
8103
8103
|
const entries = vectorPathEntries(doc, null, { locked: true });
|
|
8104
|
-
return
|
|
8104
|
+
return _chunkYNSK4MGTcjs.PlanarMap.build(
|
|
8105
8105
|
entries.map((e) => ({ path: worldOf(e, e.node.subpaths.filter(usable)), fills: false })),
|
|
8106
8106
|
{ gap, maxSegments: 2e4 }
|
|
8107
8107
|
);
|
|
@@ -9624,7 +9624,7 @@ var VectorEditorController = (_class5 = class {
|
|
|
9624
9624
|
while (list.some((e) => e.id === `fx${k}`)) k++;
|
|
9625
9625
|
const params = { ..._nullishCoalesce(options.params, () => ( {})) };
|
|
9626
9626
|
if (type === "repeater" && params.position === void 0) {
|
|
9627
|
-
const b =
|
|
9627
|
+
const b = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, vectorAppearanceOutline(node));
|
|
9628
9628
|
if (b && b.maxX - b.minX > 0) params.position = { x: Math.round((b.maxX - b.minX) * 1.25 * 100) / 100, y: 0 };
|
|
9629
9629
|
}
|
|
9630
9630
|
const effect = createVectorEffect(type, `fx${k}`, params);
|
|
@@ -10369,7 +10369,7 @@ var VectorEditorController = (_class5 = class {
|
|
|
10369
10369
|
if (options.live) return this.liveBooleanOp(op, roots);
|
|
10370
10370
|
const entries = vectorPathEntries(this.doc, roots, { locked: true });
|
|
10371
10371
|
if (entries.length < 2) return null;
|
|
10372
|
-
const result =
|
|
10372
|
+
const result = _chunkYNSK4MGTcjs.pathBoolean.call(void 0,
|
|
10373
10373
|
BOOLEAN_OPS[op],
|
|
10374
10374
|
entries.map((e) => ({
|
|
10375
10375
|
path: vectorPathWorldBezier({ ...e.node, subpaths: e.node.subpaths.filter((s) => s.anchors.length > 1).map((s) => ({ ...s, closed: true })) }, e.parent),
|
|
@@ -10473,7 +10473,7 @@ var VectorEditorController = (_class5 = class {
|
|
|
10473
10473
|
/** A document-space path mapped into the parent space of node `id`. */
|
|
10474
10474
|
intoParentSpace(id, path) {
|
|
10475
10475
|
const parent = _nullishCoalesce(vectorParentMatrix(this.doc.nodes, id), () => ( IDENTITY_MATRIX));
|
|
10476
|
-
return isRoot(parent) ? path :
|
|
10476
|
+
return isRoot(parent) ? path : _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, path, invertMatrix(parent));
|
|
10477
10477
|
}
|
|
10478
10478
|
/** Splits selected compound paths into one path per subpath. */
|
|
10479
10479
|
breakApart(options = {}) {
|
|
@@ -10512,7 +10512,7 @@ var VectorEditorController = (_class5 = class {
|
|
|
10512
10512
|
const entries = vectorPathEntries(this.doc, roots);
|
|
10513
10513
|
if (entries.length < (op === "divide" || op === "outline" ? 1 : 2)) return [];
|
|
10514
10514
|
const shapes = entries.map((e) => vectorPathfinderShape(e, op));
|
|
10515
|
-
const result =
|
|
10515
|
+
const result = _chunkYNSK4MGTcjs.pathfinder.call(void 0, op, shapes);
|
|
10516
10516
|
if (result.error || !result.pieces.length) return [];
|
|
10517
10517
|
const last = entries[entries.length - 1].node.id;
|
|
10518
10518
|
const topRoot = _nullishCoalesce([...roots].reverse().find((r) => this.holds(r, last)), () => ( last));
|
|
@@ -10721,7 +10721,7 @@ var VectorEditorController = (_class5 = class {
|
|
|
10721
10721
|
const p = m.map.faceInterior(index);
|
|
10722
10722
|
return {
|
|
10723
10723
|
index,
|
|
10724
|
-
d:
|
|
10724
|
+
d: _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, f.path, { precision: 3 }),
|
|
10725
10725
|
area: f.area,
|
|
10726
10726
|
sources: m.map.faceSources(index).map((i) => m.entries[i].node.id),
|
|
10727
10727
|
point: p ? { x: p[0], y: p[1] } : null
|
|
@@ -10763,7 +10763,7 @@ var VectorEditorController = (_class5 = class {
|
|
|
10763
10763
|
let nodes = this.doc.nodes;
|
|
10764
10764
|
m.entries.forEach((entry, i) => {
|
|
10765
10765
|
const node = entry.node;
|
|
10766
|
-
const toLocal = (path) =>
|
|
10766
|
+
const toLocal = (path) => _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, path, invertMatrix(multiplyMatrices(nodeMatrix(node), entry.parent)));
|
|
10767
10767
|
const list = [];
|
|
10768
10768
|
const r = plan.replace.get(i);
|
|
10769
10769
|
if (r === void 0) list.push(node);
|
|
@@ -10845,7 +10845,7 @@ var VectorEditorController = (_class5 = class {
|
|
|
10845
10845
|
hoverBuilder(p, alt) {
|
|
10846
10846
|
if (this.tool === "paintBucket") {
|
|
10847
10847
|
const region = _nullishCoalesce(_optionalChain([this, 'access', _301 => _301.fillMap, 'call', _302 => _302(this.editing.fillGap), 'optionalAccess', _303 => _303.regionAt, 'call', _304 => _304([p.x, p.y])]), () => ( null));
|
|
10848
|
-
const key2 = region ?
|
|
10848
|
+
const key2 = region ? _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, region, { precision: 2 }) : null;
|
|
10849
10849
|
if (key2 === this.builderHoverKey) return false;
|
|
10850
10850
|
this.builderHoverKey = key2;
|
|
10851
10851
|
this.builderPreview = region ? { mode: "fill", faces: [region], lines: [], trail: null } : null;
|
|
@@ -11316,10 +11316,10 @@ var VectorEditorController = (_class5 = class {
|
|
|
11316
11316
|
const region = eraserRegion(pts, width);
|
|
11317
11317
|
if (!region.length) return [];
|
|
11318
11318
|
const plan = [];
|
|
11319
|
-
const rb =
|
|
11319
|
+
const rb = _chunkYNSK4MGTcjs.bezierPathBounds.call(void 0, region);
|
|
11320
11320
|
const reach = rb ? [{ x: rb.minX, y: rb.minY }, { x: rb.maxX, y: rb.maxY }] : points;
|
|
11321
11321
|
for (const node of this.strokeTargets(reach, options.ids, 0)) {
|
|
11322
|
-
const local =
|
|
11322
|
+
const local = _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, region, invertMatrix(this.worldOf(node.id)));
|
|
11323
11323
|
const live = node.subpaths.filter((sp) => sp.anchors.length > 1);
|
|
11324
11324
|
if (!live.length) continue;
|
|
11325
11325
|
if (hasPaint(node.fill) && live.every((sp) => sp.closed)) {
|
|
@@ -12531,7 +12531,7 @@ var VectorEditorController = (_class5 = class {
|
|
|
12531
12531
|
this.selection = [drag.nodeId];
|
|
12532
12532
|
return this.commit(`Draw ${inkShapeLabel(shape)}`, drag.before);
|
|
12533
12533
|
}
|
|
12534
|
-
const fitted =
|
|
12534
|
+
const fitted = _chunkYNSK4MGTcjs.fitCubics.call(void 0, drag.points, 1.5 / this.viewport.zoom, { cornerAngleDeg: 60 });
|
|
12535
12535
|
const anchors = [];
|
|
12536
12536
|
for (const c of fitted) {
|
|
12537
12537
|
if (!anchors.length) anchors.push({ x: c.p0[0], y: c.p0[1] });
|
|
@@ -12863,12 +12863,12 @@ function screenOutline(state, node, entered) {
|
|
|
12863
12863
|
const v2 = state.viewport;
|
|
12864
12864
|
const view = [v2.zoom, 0, 0, v2.zoom, v2.x, v2.y];
|
|
12865
12865
|
const parent = _nullishCoalesce(vectorParentMatrix(state.document.nodes, node.id), () => ( IDENTITY_MATRIX));
|
|
12866
|
-
return outlinePaths(node, parent, entered).map((path) =>
|
|
12866
|
+
return outlinePaths(node, parent, entered).map((path) => _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, path, view), { precision: 2 })).join(" ");
|
|
12867
12867
|
}
|
|
12868
12868
|
function outlinePaths(node, parent, entered) {
|
|
12869
12869
|
if (node.type === "path") return [vectorPathWorldBezier(node, parent, { effects: false })];
|
|
12870
12870
|
const m = multiplyMatrices(nodeMatrix(node), parent);
|
|
12871
|
-
if (hasOwnVectorAppearance(node) && !entered.has(node.id)) return [
|
|
12871
|
+
if (hasOwnVectorAppearance(node) && !entered.has(node.id)) return [_chunkYNSK4MGTcjs.transformBezierPath.call(void 0, vectorAppearanceOutline(node), m)];
|
|
12872
12872
|
return node.children.filter((c) => c.visible !== false).flatMap((c) => outlinePaths(c, m, entered));
|
|
12873
12873
|
}
|
|
12874
12874
|
function getVectorEnteredGroups(state) {
|
|
@@ -13000,15 +13000,15 @@ function getVectorOverlayRenderData(state) {
|
|
|
13000
13000
|
if (state.builder) {
|
|
13001
13001
|
const v2 = state.viewport;
|
|
13002
13002
|
const view = [v2.zoom, 0, 0, v2.zoom, v2.x, v2.y];
|
|
13003
|
-
const svg = (path) =>
|
|
13004
|
-
const screen = state.builder.faces.map((f) =>
|
|
13003
|
+
const svg = (path) => _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, path, { precision: 2 });
|
|
13004
|
+
const screen = state.builder.faces.map((f) => _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, f, view));
|
|
13005
13005
|
const hatch = state.builder.mode !== "fill";
|
|
13006
13006
|
const trail = state.builder.trail && state.builder.trail.length > 1 ? state.builder.trail.map((q, i) => `${i ? "L" : "M"}${sc(q).x} ${sc(q).y}`).join("") : null;
|
|
13007
13007
|
builder = {
|
|
13008
13008
|
mode: state.builder.mode,
|
|
13009
13009
|
faces: screen.map(svg),
|
|
13010
|
-
hatches: screen.map((f) => hatch ? svg(
|
|
13011
|
-
lines: state.builder.lines.map((l) => svg(
|
|
13010
|
+
hatches: screen.map((f) => hatch ? svg(_chunkYNSK4MGTcjs.hatchPath.call(void 0, f, { gap: VECTOR_BUILDER_HATCH_GAP })) : ""),
|
|
13011
|
+
lines: state.builder.lines.map((l) => svg(_chunkYNSK4MGTcjs.transformBezierPath.call(void 0, l, view))),
|
|
13012
13012
|
trail
|
|
13013
13013
|
};
|
|
13014
13014
|
if (state.builder.mode !== "fill" && _optionalChain([it, 'optionalAccess', _395 => _395.type]) === "builder") {
|
|
@@ -13131,7 +13131,7 @@ function blendOverlay(state) {
|
|
|
13131
13131
|
const s = vectorBlendSpine(g);
|
|
13132
13132
|
if (!s) return [];
|
|
13133
13133
|
const m = multiplyMatrices(_nullishCoalesce(vectorWorldMatrix(doc.nodes, g.id), () => ( IDENTITY_MATRIX)), view);
|
|
13134
|
-
const d =
|
|
13134
|
+
const d = _chunkYNSK4MGTcjs.bezierPathToSvg.call(void 0, _chunkYNSK4MGTcjs.transformBezierPath.call(void 0, subpathsToBezier([s.spine], { corners: false }), m), { precision: 2 });
|
|
13135
13135
|
const keys = s.stops.map((stop) => {
|
|
13136
13136
|
const p = vectorBlendRailAt(s.rail, stop).point;
|
|
13137
13137
|
return sc({ x: p[0], y: p[1] }, m);
|