@pixerate/editor 0.264.1 → 0.266.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/agent/index.cjs +4 -3
  2. package/dist/agent/index.js +3 -2
  3. package/dist/animation-editor/index.cjs +60 -61
  4. package/dist/animation-editor/index.js +4 -5
  5. package/dist/brushes/index.cjs +73 -60
  6. package/dist/brushes/index.d.cts +1 -0
  7. package/dist/brushes/index.d.ts +1 -0
  8. package/dist/brushes/index.js +17 -4
  9. package/dist/brushes/preview.d.cts +59 -0
  10. package/dist/brushes/preview.d.ts +59 -0
  11. package/dist/brushes/tools.d.cts +12 -5
  12. package/dist/brushes/tools.d.ts +12 -5
  13. package/dist/{brushstrokeRender-3MOI7PH4.js → brushstrokeRender-4UB6NRJW.js} +11 -4
  14. package/dist/{brushstrokeRender-SMMPIJF2.cjs → brushstrokeRender-JQ2XQRUD.cjs} +22 -15
  15. package/dist/canvas/brushstroke.d.cts +6 -1
  16. package/dist/canvas/brushstroke.d.ts +6 -1
  17. package/dist/canvas/index.cjs +18 -18
  18. package/dist/canvas/index.js +4 -4
  19. package/dist/{chunk-TMDDMJCR.js → chunk-472INMWH.js} +4 -2
  20. package/dist/chunk-55ALHYJY.js +289 -0
  21. package/dist/{chunk-F3KKR6DD.cjs → chunk-5OE4ZZ6V.cjs} +30 -30
  22. package/dist/{chunk-BY5EBP26.cjs → chunk-677777GH.cjs} +3 -3
  23. package/dist/{chunk-NHA26O5X.cjs → chunk-7KNW3WXZ.cjs} +14 -12
  24. package/dist/{chunk-G5ADO47G.cjs → chunk-7NQOGWLM.cjs} +3 -2
  25. package/dist/{chunk-WWI6FLH2.js → chunk-7PW6VCNW.js} +2 -2
  26. package/dist/{chunk-CECCP2V7.js → chunk-BLR4KWYQ.js} +1 -1
  27. package/dist/chunk-DEBIFWY6.cjs +77 -0
  28. package/dist/{chunk-KXNZNOEF.cjs → chunk-DGXTEPCU.cjs} +94 -94
  29. package/dist/{chunk-3CI7FRMK.js → chunk-DVPQFMH6.js} +13 -1
  30. package/dist/chunk-E2Z4UARJ.cjs +289 -0
  31. package/dist/chunk-HAEB3MZD.js +664 -0
  32. package/dist/{chunk-EE7SAYBF.js → chunk-J4SGJCPW.js} +3 -3
  33. package/dist/{chunk-A2IS7EHE.cjs → chunk-JBZRVLXV.cjs} +14 -2
  34. package/dist/chunk-KIJIONZF.cjs +664 -0
  35. package/dist/{chunk-V7MJ4HIN.cjs → chunk-NOP4Y5AB.cjs} +23 -23
  36. package/dist/{chunk-FQC5TDB6.cjs → chunk-O53MOGXG.cjs} +35 -35
  37. package/dist/{chunk-LPFQHVCO.js → chunk-PXXXRCME.js} +1 -284
  38. package/dist/{chunk-4OJC4MCD.js → chunk-Q6RVVJW6.js} +1 -1
  39. package/dist/{chunk-T7QSEKDY.cjs → chunk-QJVOJUTD.cjs} +4 -287
  40. package/dist/{chunk-HAUDEVMC.js → chunk-WY23AUCA.js} +2 -2
  41. package/dist/{chunk-JEML4FSA.js → chunk-XDNWQMHY.js} +3 -2
  42. package/dist/{chunk-ROBSFJ6F.js → chunk-Z2Z2OHRM.js} +1 -1
  43. package/dist/{chunk-USJX5SW4.cjs → chunk-ZHRVCW3M.cjs} +12 -12
  44. package/dist/chunk-ZS7LB2MV.js +77 -0
  45. package/dist/commands/index.cjs +26 -656
  46. package/dist/commands/index.js +18 -648
  47. package/dist/image-editor/index.cjs +788 -790
  48. package/dist/image-editor/index.js +6 -8
  49. package/dist/paint-editor/index.cjs +88 -84
  50. package/dist/paint-editor/index.js +12 -8
  51. package/dist/vector/contract.d.cts +52 -0
  52. package/dist/vector/contract.d.ts +52 -0
  53. package/dist/vector/index.cjs +1168 -971
  54. package/dist/vector/index.d.cts +1 -0
  55. package/dist/vector/index.d.ts +1 -0
  56. package/dist/vector/index.js +204 -7
  57. package/package.json +1 -1
  58. package/skills/pixerate-brushes/SKILL.md +7 -2
  59. package/dist/chunk-FJBQTZS4.js +0 -17
  60. package/dist/chunk-LRTR4ASZ.cjs +0 -17
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkUSJX5SW4cjs = require('./chunk-USJX5SW4.cjs');
8
+ var _chunkZHRVCW3Mcjs = require('./chunk-ZHRVCW3M.cjs');
9
9
 
10
10
 
11
11
  var _chunkGF2RBSDMcjs = require('./chunk-GF2RBSDM.cjs');
@@ -1361,12 +1361,12 @@ var unit = (x, y) => {
1361
1361
  return l > 1e-12 && Number.isFinite(l) ? [x / l, y / l] : null;
1362
1362
  };
1363
1363
  function cubicOf(sp, i) {
1364
- const s = _chunkUSJX5SW4cjs.subpathSegment.call(void 0, sp, i);
1364
+ const s = _chunkZHRVCW3Mcjs.subpathSegment.call(void 0, sp, i);
1365
1365
  if (s.length === 4) return s;
1366
1366
  const [a, b] = s;
1367
1367
  return [a, [a[0] + (b[0] - a[0]) / 3, a[1] + (b[1] - a[1]) / 3], [a[0] + 2 * (b[0] - a[0]) / 3, a[1] + 2 * (b[1] - a[1]) / 3], b];
1368
1368
  }
1369
- var isLine = (sp, i) => _chunkUSJX5SW4cjs.subpathSegment.call(void 0, sp, i).length === 2;
1369
+ var isLine = (sp, i) => _chunkZHRVCW3Mcjs.subpathSegment.call(void 0, sp, i).length === 2;
1370
1370
  function startTangent(c) {
1371
1371
  for (let k = 1; k < 4; k++) {
1372
1372
  const u = unit(c[k][0] - c[0][0], c[k][1] - c[0][1]);
@@ -1386,10 +1386,10 @@ function sample(c, n, out, withStart) {
1386
1386
  }
1387
1387
  var onAnchor = (a, h) => !h || Math.abs(h.x - a.x) < EPS && Math.abs(h.y - a.y) < EPS;
1388
1388
  function tidy(a, keepType = true) {
1389
- const next = _chunkUSJX5SW4cjs.cloneAnchor.call(void 0, a);
1389
+ const next = _chunkZHRVCW3Mcjs.cloneAnchor.call(void 0, a);
1390
1390
  if (onAnchor(next, next.in)) delete next.in;
1391
1391
  if (onAnchor(next, next.out)) delete next.out;
1392
- const shown = _chunkUSJX5SW4cjs.inferAnchorType.call(void 0, next);
1392
+ const shown = _chunkZHRVCW3Mcjs.inferAnchorType.call(void 0, next);
1393
1393
  const type = keepType && a.type ? a.type === "symmetric" && shown !== "symmetric" ? shown === "corner" ? "corner" : "smooth" : a.type === "smooth" && shown === "corner" ? "corner" : a.type : shown;
1394
1394
  if (type === "corner") delete next.type;
1395
1395
  else next.type = type;
@@ -1433,7 +1433,7 @@ function fitAcross(pts, N, t0, t1) {
1433
1433
  return goldenMin(fit, 0, 1);
1434
1434
  }
1435
1435
  function removeAnchorKeepingShape(sp, index) {
1436
- const anchors = sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor);
1436
+ const anchors = sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor);
1437
1437
  const n = anchors.length;
1438
1438
  if (index < 0 || index >= n) return { anchors, closed: sp.closed };
1439
1439
  if ((sp.closed || index > 0 && index < n - 1) && n >= 3) {
@@ -1467,12 +1467,12 @@ function removeAnchorKeepingShape(sp, index) {
1467
1467
  }
1468
1468
  function removeAnchorsKeepingShape(sp, indices) {
1469
1469
  const order = [...new Set(indices)].filter((i) => i >= 0 && i < sp.anchors.length).sort((a, b) => b - a);
1470
- return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed });
1470
+ return order.reduce((acc, i) => removeAnchorKeepingShape(acc, i), { anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed });
1471
1471
  }
1472
1472
  function bendSegment(sp, segment, t, p) {
1473
- const anchors = sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor);
1473
+ const anchors = sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor);
1474
1474
  const n = anchors.length;
1475
- if (segment < 0 || segment >= _chunkUSJX5SW4cjs.subpathSegmentCount.call(void 0, sp) || !Number.isFinite(t) || !Number.isFinite(p.x) || !Number.isFinite(p.y)) return { anchors, closed: sp.closed };
1475
+ if (segment < 0 || segment >= _chunkZHRVCW3Mcjs.subpathSegmentCount.call(void 0, sp) || !Number.isFinite(t) || !Number.isFinite(p.x) || !Number.isFinite(p.y)) return { anchors, closed: sp.closed };
1476
1476
  const tc = Math.min(0.95, Math.max(0.05, t));
1477
1477
  const ia = segment;
1478
1478
  const ib = (segment + 1) % n;
@@ -1483,16 +1483,16 @@ function bendSegment(sp, segment, t, p) {
1483
1483
  const oy = (p.y - (a.y + (b.y - a.y) * tc)) / k;
1484
1484
  const c1 = { x: a.x + (b.x - a.x) / 3 + ox, y: a.y + (b.y - a.y) / 3 + oy };
1485
1485
  const c2 = { x: b.x + (a.x - b.x) / 3 + ox, y: b.y + (a.y - b.y) / 3 + oy };
1486
- anchors[ia] = _chunkUSJX5SW4cjs.moveAnchorHandle.call(void 0, a, "out", c1);
1487
- anchors[ib] = _chunkUSJX5SW4cjs.moveAnchorHandle.call(void 0, b, "in", c2);
1486
+ anchors[ia] = _chunkZHRVCW3Mcjs.moveAnchorHandle.call(void 0, a, "out", c1);
1487
+ anchors[ib] = _chunkZHRVCW3Mcjs.moveAnchorHandle.call(void 0, b, "in", c2);
1488
1488
  return { anchors, closed: sp.closed };
1489
1489
  }
1490
1490
  function subpathPointAt(sp, segment, t) {
1491
- const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0, _chunkUSJX5SW4cjs.subpathSegment.call(void 0, sp, segment), t);
1491
+ const [x, y] = _chunkGF2RBSDMcjs.segmentPoint.call(void 0, _chunkZHRVCW3Mcjs.subpathSegment.call(void 0, sp, segment), t);
1492
1492
  return { x, y };
1493
1493
  }
1494
1494
  function curvatureMoveAnchor(sp, index, q) {
1495
- const anchors = sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor);
1495
+ const anchors = sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor);
1496
1496
  const a = sp.anchors[index];
1497
1497
  if (!a) return { anchors, closed: sp.closed };
1498
1498
  const own = [
@@ -1538,7 +1538,7 @@ function curvatureMoveAnchor(sp, index, q) {
1538
1538
  function cutSubpathAt(sp, at) {
1539
1539
  const n = sp.anchors.length;
1540
1540
  const cuts = [...new Set(at)].filter((i) => Number.isInteger(i) && i >= 0 && i < n && (sp.closed || i > 0 && i < n - 1)).sort((a, b) => a - b);
1541
- if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed }];
1541
+ if (!cuts.length || n < 2) return [{ anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed }];
1542
1542
  const first = cuts[0];
1543
1543
  const run = sp.closed ? Array.from({ length: n + 1 }, (_, i) => sp.anchors[(first + i) % n]) : sp.anchors;
1544
1544
  const cutSet = new Set(sp.closed ? [...cuts.map((c) => (c - first + n) % n), n] : cuts);
@@ -1546,7 +1546,7 @@ function cutSubpathAt(sp, at) {
1546
1546
  let cur = [];
1547
1547
  run.forEach((a, i) => {
1548
1548
  if (!cutSet.has(i)) {
1549
- cur.push(_chunkUSJX5SW4cjs.cloneAnchor.call(void 0, a));
1549
+ cur.push(_chunkZHRVCW3Mcjs.cloneAnchor.call(void 0, a));
1550
1550
  return;
1551
1551
  }
1552
1552
  if (cur.length) {
@@ -1561,10 +1561,10 @@ function cutSubpathAt(sp, at) {
1561
1561
  }
1562
1562
  function splitSubpathAt(sp, segment, t, endTolerance = 1e-6) {
1563
1563
  const n = sp.anchors.length;
1564
- if (segment < 0 || segment >= _chunkUSJX5SW4cjs.subpathSegmentCount.call(void 0, sp)) return [{ anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed }];
1564
+ if (segment < 0 || segment >= _chunkZHRVCW3Mcjs.subpathSegmentCount.call(void 0, sp)) return [{ anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed }];
1565
1565
  if (t <= endTolerance) return cutSubpathAt(sp, [segment]);
1566
1566
  if (t >= 1 - endTolerance) return cutSubpathAt(sp, [(segment + 1) % n]);
1567
- const { subpath, index } = _chunkUSJX5SW4cjs.insertAnchor.call(void 0, sp, segment, t);
1567
+ const { subpath, index } = _chunkZHRVCW3Mcjs.insertAnchor.call(void 0, sp, segment, t);
1568
1568
  return cutSubpathAt(subpath, [index]);
1569
1569
  }
1570
1570
  var endOf = (sp, last) => sp.anchors[last ? sp.anchors.length - 1 : 0];
@@ -1587,7 +1587,7 @@ function joinSubpaths(subpaths, tolerance) {
1587
1587
  const closed = [];
1588
1588
  let open = [];
1589
1589
  for (const sp of subpaths) {
1590
- const copy = { anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed };
1590
+ const copy = { anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed };
1591
1591
  if (sp.closed || sp.anchors.length < 2) {
1592
1592
  if (sp.anchors.length) closed.push(copy);
1593
1593
  } else open.push(copy);
@@ -1642,7 +1642,7 @@ function smoothSubpath(sp, amount = 1, only) {
1642
1642
  const t = Math.min(1, Math.max(0, amount));
1643
1643
  const orig = sp.anchors;
1644
1644
  const n = orig.length;
1645
- const anchors = orig.map(_chunkUSJX5SW4cjs.cloneAnchor);
1645
+ const anchors = orig.map(_chunkZHRVCW3Mcjs.cloneAnchor);
1646
1646
  if (n < 3 || t === 0) return { anchors, closed: sp.closed };
1647
1647
  for (let i = 0; i < n; i++) {
1648
1648
  if (!sp.closed && (i === 0 || i === n - 1)) continue;
@@ -1671,8 +1671,8 @@ function smoothSubpath(sp, amount = 1, only) {
1671
1671
  }
1672
1672
  function segsOf(sp) {
1673
1673
  const out = [];
1674
- for (let i = 0; i < _chunkUSJX5SW4cjs.subpathSegmentCount.call(void 0, sp); i++) {
1675
- const s = _chunkUSJX5SW4cjs.subpathSegment.call(void 0, sp, i);
1674
+ for (let i = 0; i < _chunkZHRVCW3Mcjs.subpathSegmentCount.call(void 0, sp); i++) {
1675
+ const s = _chunkZHRVCW3Mcjs.subpathSegment.call(void 0, sp, i);
1676
1676
  out.push(s.length === 2 ? { c: s, line: true } : { c: s, line: false });
1677
1677
  }
1678
1678
  return out;
@@ -1729,7 +1729,7 @@ function removeRedundantPoints(sp, tolerance) {
1729
1729
  const tol = Math.max(tolerance, 1e-9);
1730
1730
  const types = new Map(sp.anchors.filter((a) => a.type).map((a) => [`${a.x},${a.y}`, a.type]));
1731
1731
  const segs = segsOf(sp).filter((s) => !isZeroSeg(s));
1732
- if (!segs.length) return { anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed };
1732
+ if (!segs.length) return { anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed };
1733
1733
  const minSegs = sp.closed ? 2 : 1;
1734
1734
  let changed = true;
1735
1735
  while (changed && segs.length > minSegs) {
@@ -1747,7 +1747,7 @@ function removeRedundantPoints(sp, tolerance) {
1747
1747
  break;
1748
1748
  }
1749
1749
  }
1750
- return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(_chunkUSJX5SW4cjs.cloneAnchor), closed: sp.closed }));
1750
+ return _nullishCoalesce(segsToSubpath(segs, sp.closed, types), () => ( { anchors: sp.anchors.map(_chunkZHRVCW3Mcjs.cloneAnchor), closed: sp.closed }));
1751
1751
  }
1752
1752
 
1753
1753
 
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- var _chunkUSJX5SW4cjs = require('./chunk-USJX5SW4.cjs');
21
+ var _chunkZHRVCW3Mcjs = require('./chunk-ZHRVCW3M.cjs');
22
22
 
23
23
 
24
24
 
@@ -37,7 +37,7 @@ var lerpP = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
37
37
  var toP = (v) => [v.x, v.y];
38
38
  var mapP = (m, p) => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];
39
39
  var curvesOf = (c) => Math.max(0, (c.pts.length - 1) / 3) | 0;
40
- function subpathToMorphContour(sp, m = _chunkUSJX5SW4cjs.IDENTITY_MATRIX) {
40
+ function subpathToMorphContour(sp, m = _chunkZHRVCW3Mcjs.IDENTITY_MATRIX) {
41
41
  const n = sp.anchors.length;
42
42
  if (!n) return null;
43
43
  const first = mapP(m, toP(sp.anchors[0]));
@@ -67,8 +67,8 @@ function isStraight(p0, p1, p2, p3) {
67
67
  const u2 = along(p2);
68
68
  return off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;
69
69
  }
70
- function morphContourToSubpath(c, m = _chunkUSJX5SW4cjs.IDENTITY_MATRIX, closed = c.closed) {
71
- const pts = _chunkUSJX5SW4cjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
70
+ function morphContourToSubpath(c, m = _chunkZHRVCW3Mcjs.IDENTITY_MATRIX, closed = c.closed) {
71
+ const pts = _chunkZHRVCW3Mcjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
72
72
  const curves = curvesOf(c);
73
73
  const dropLast = closed && c.closed && curves > 0;
74
74
  const count = dropLast ? curves : curves + 1;
@@ -84,7 +84,7 @@ function morphContourToSubpath(c, m = _chunkUSJX5SW4cjs.IDENTITY_MATRIX, closed
84
84
  anchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };
85
85
  }
86
86
  for (const a of anchors) {
87
- const type = _chunkUSJX5SW4cjs.inferAnchorType.call(void 0, a);
87
+ const type = _chunkZHRVCW3Mcjs.inferAnchorType.call(void 0, a);
88
88
  if (type !== "corner") a.type = type;
89
89
  }
90
90
  const isClosed = closed && curves > 0;
@@ -267,7 +267,7 @@ function bestStart(fixed, free, useShapeContext) {
267
267
  return best;
268
268
  }
269
269
  function placeIn(c, from, to) {
270
- const b = _chunkUSJX5SW4cjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
270
+ const b = _chunkZHRVCW3Mcjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
271
271
  const p = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];
272
272
  if (!from || !to) return p;
273
273
  const fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;
@@ -456,7 +456,7 @@ function interpolateVectorColor(a, b, t) {
456
456
  }
457
457
  function resampleGradientStops(g, offsets) {
458
458
  return offsets.map((offset) => {
459
- const s = _chunkUSJX5SW4cjs.sampleVectorGradient.call(void 0, g, offset);
459
+ const s = _chunkZHRVCW3Mcjs.sampleVectorGradient.call(void 0, g, offset);
460
460
  return s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };
461
461
  });
462
462
  }
@@ -467,11 +467,11 @@ function lerpAngle(a, b, t) {
467
467
  var lerpPoint = (a, b, t) => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });
468
468
  var sameColourModel = (a, b) => (_nullishCoalesce(a.interpolation, () => ( "srgb"))) === (_nullishCoalesce(b.interpolation, () => ( "srgb"))) && (_nullishCoalesce(a.smoothness, () => ( 0))) === (_nullishCoalesce(b.smoothness, () => ( 0)));
469
469
  function lerpStops(a, b, t) {
470
- let stopsA = _chunkUSJX5SW4cjs.sortedVectorGradientStops.call(void 0, a);
471
- let stopsB = _chunkUSJX5SW4cjs.sortedVectorGradientStops.call(void 0, b);
470
+ let stopsA = _chunkZHRVCW3Mcjs.sortedVectorGradientStops.call(void 0, a);
471
+ let stopsB = _chunkZHRVCW3Mcjs.sortedVectorGradientStops.call(void 0, b);
472
472
  const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
473
473
  if (resampled) {
474
- const offs = [..._chunkUSJX5SW4cjs.expandVectorGradientStops.call(void 0, a), ..._chunkUSJX5SW4cjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
474
+ const offs = [..._chunkZHRVCW3Mcjs.expandVectorGradientStops.call(void 0, a), ..._chunkZHRVCW3Mcjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
475
475
  const common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);
476
476
  stopsA = resampleGradientStops(a, common);
477
477
  stopsB = resampleGradientStops(b, common);
@@ -498,8 +498,8 @@ function lerpGradient(a, b, t) {
498
498
  }
499
499
  if (near.spread && near.spread !== "pad") out.spread = near.spread;
500
500
  if (near.strokeMode && near.strokeMode !== "within") out.strokeMode = near.strokeMode;
501
- const ea = _chunkUSJX5SW4cjs.hasExplicitGradientGeometry.call(void 0, a);
502
- const eb = _chunkUSJX5SW4cjs.hasExplicitGradientGeometry.call(void 0, b);
501
+ const ea = _chunkZHRVCW3Mcjs.hasExplicitGradientGeometry.call(void 0, a);
502
+ const eb = _chunkZHRVCW3Mcjs.hasExplicitGradientGeometry.call(void 0, b);
503
503
  if (!ea && !eb) {
504
504
  if (a.angle !== void 0 || b.angle !== void 0 || a.type === "linear" || a.type === "reflected") {
505
505
  const fallback = a.type === "linear" || a.type === "reflected" ? 180 : 90;
@@ -512,10 +512,10 @@ function lerpGradient(a, b, t) {
512
512
  }
513
513
  return out;
514
514
  }
515
- const pa = _chunkUSJX5SW4cjs.vectorGradientPoints.call(void 0, a);
516
- const pb = _chunkUSJX5SW4cjs.vectorGradientPoints.call(void 0, b);
515
+ const pa = _chunkZHRVCW3Mcjs.vectorGradientPoints.call(void 0, a);
516
+ const pb = _chunkZHRVCW3Mcjs.vectorGradientPoints.call(void 0, b);
517
517
  if (pa.units !== pb.units) {
518
- const src = _chunkUSJX5SW4cjs.explicitVectorGradient.call(void 0, near);
518
+ const src = _chunkZHRVCW3Mcjs.explicitVectorGradient.call(void 0, near);
519
519
  return { ...src, stops: out.stops, ...out.interpolation ? { interpolation: out.interpolation } : {}, ...out.smoothness ? { smoothness: out.smoothness } : {} };
520
520
  }
521
521
  out.start = lerpPoint(pa.start, pb.start, t);
@@ -535,14 +535,14 @@ function solidLike(color, like) {
535
535
  function interpolateVectorPaint(a, b, t) {
536
536
  if (t <= 0) return a;
537
537
  if (t >= 1) return b;
538
- const pa = _chunkUSJX5SW4cjs.hasPaint.call(void 0, a);
539
- const pb = _chunkUSJX5SW4cjs.hasPaint.call(void 0, b);
538
+ const pa = _chunkZHRVCW3Mcjs.hasPaint.call(void 0, a);
539
+ const pb = _chunkZHRVCW3Mcjs.hasPaint.call(void 0, b);
540
540
  if (!pa && !pb) return t < 0.5 ? a : b;
541
541
  if (typeof a === "string" && pa && typeof b === "string" && pb) return interpolateVectorColor(a, b, t);
542
542
  if (!pa && typeof b === "string") return interpolateVectorColor("transparent", b, t);
543
543
  if (!pb && typeof a === "string") return interpolateVectorColor(a, "transparent", t);
544
- const ga = pa && _chunkUSJX5SW4cjs.isVectorGradient.call(void 0, a) ? a : null;
545
- const gb = pb && _chunkUSJX5SW4cjs.isVectorGradient.call(void 0, b) ? b : null;
544
+ const ga = pa && _chunkZHRVCW3Mcjs.isVectorGradient.call(void 0, a) ? a : null;
545
+ const gb = pb && _chunkZHRVCW3Mcjs.isVectorGradient.call(void 0, b) ? b : null;
546
546
  if (ga && gb) return _nullishCoalesce(lerpGradient(ga, gb, t), () => ( (t < 0.5 ? a : b)));
547
547
  if (gb) return _nullishCoalesce(lerpGradient(solidLike(pa ? a : null, gb), gb, t), () => ( b));
548
548
  if (ga) return _nullishCoalesce(lerpGradient(ga, solidLike(pb ? b : null, ga), t), () => ( a));
@@ -553,8 +553,8 @@ function interpolateWidthProfiles(a, b, t) {
553
553
  const at = [..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( [])), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);
554
554
  const ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);
555
555
  return ts.map((pos) => {
556
- const x = _chunkUSJX5SW4cjs.widthProfileAt.call(void 0, a, pos);
557
- const y = _chunkUSJX5SW4cjs.widthProfileAt.call(void 0, b, pos);
556
+ const x = _chunkZHRVCW3Mcjs.widthProfileAt.call(void 0, a, pos);
557
+ const y = _chunkZHRVCW3Mcjs.widthProfileAt.call(void 0, b, pos);
558
558
  return { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };
559
559
  });
560
560
  }
@@ -597,7 +597,7 @@ function reversedStyle(s) {
597
597
  out.endArrow = s.startArrow;
598
598
  out.startArrowScale = s.endArrowScale;
599
599
  out.endArrowScale = s.startArrowScale;
600
- if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkUSJX5SW4cjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
600
+ if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkZHRVCW3Mcjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
601
601
  for (const k of ["startArrow", "endArrow", "startArrowScale", "endArrowScale"]) if (out[k] === void 0) delete out[k];
602
602
  return out;
603
603
  }
@@ -623,19 +623,19 @@ function styleOf(n) {
623
623
  return out;
624
624
  }
625
625
  function contoursOf(node, m) {
626
- return _chunkUSJX5SW4cjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
626
+ return _chunkZHRVCW3Mcjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
627
627
  }
628
- function preparePathMorph(a, b, options, ma = _chunkUSJX5SW4cjs.nodeMatrix.call(void 0, a), mb = _chunkUSJX5SW4cjs.nodeMatrix.call(void 0, b)) {
628
+ function preparePathMorph(a, b, options, ma = _chunkZHRVCW3Mcjs.nodeMatrix.call(void 0, a), mb = _chunkZHRVCW3Mcjs.nodeMatrix.call(void 0, b)) {
629
629
  const corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);
630
630
  const sim = procrustes(corr.a, corr.b);
631
631
  const styleA = styleOf(a);
632
632
  const styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);
633
- const rigid = !_chunkUSJX5SW4cjs.isIdentityMatrix.call(void 0, ma) || !_chunkUSJX5SW4cjs.isIdentityMatrix.call(void 0, mb);
633
+ const rigid = !_chunkZHRVCW3Mcjs.isIdentityMatrix.call(void 0, ma) || !_chunkZHRVCW3Mcjs.isIdentityMatrix.call(void 0, mb);
634
634
  const id = _nullishCoalesce(options.id, () => ( a.id));
635
635
  return (t) => {
636
636
  const contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });
637
- const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkUSJX5SW4cjs.IDENTITY_MATRIX;
638
- const back = rigid ? _chunkUSJX5SW4cjs.invertMatrix.call(void 0, m) : _chunkUSJX5SW4cjs.IDENTITY_MATRIX;
637
+ const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkZHRVCW3Mcjs.IDENTITY_MATRIX;
638
+ const back = rigid ? _chunkZHRVCW3Mcjs.invertMatrix.call(void 0, m) : _chunkZHRVCW3Mcjs.IDENTITY_MATRIX;
639
639
  const subpaths = contours.map((c, k) => {
640
640
  const closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;
641
641
  return morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);
@@ -643,14 +643,14 @@ function preparePathMorph(a, b, options, ma = _chunkUSJX5SW4cjs.nodeMatrix.call(
643
643
  const node = { id, type: "path", subpaths, ...interpolateVectorStyle(styleA, styleB, t) };
644
644
  const opacity = lerpN(_nullishCoalesce(a.opacity, () => ( 1)), _nullishCoalesce(b.opacity, () => ( 1)), t);
645
645
  if (opacity < 1) node.opacity = opacity;
646
- if (rigid && !_chunkUSJX5SW4cjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
646
+ if (rigid && !_chunkZHRVCW3Mcjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
647
647
  return node;
648
648
  };
649
649
  }
650
- function flattenPaths(node, parent = _chunkUSJX5SW4cjs.IDENTITY_MATRIX) {
651
- const m = _chunkUSJX5SW4cjs.multiplyMatrices.call(void 0, _chunkUSJX5SW4cjs.nodeMatrix.call(void 0, node), parent);
650
+ function flattenPaths(node, parent = _chunkZHRVCW3Mcjs.IDENTITY_MATRIX) {
651
+ const m = _chunkZHRVCW3Mcjs.multiplyMatrices.call(void 0, _chunkZHRVCW3Mcjs.nodeMatrix.call(void 0, node), parent);
652
652
  if (node.type === "path") return [{ path: node, m, opacity: 1 }];
653
- if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkUSJX5SW4cjs.expandVectorAppearance.call(void 0, node), parent);
653
+ if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkZHRVCW3Mcjs.expandVectorAppearance.call(void 0, node), parent);
654
654
  const o = _nullishCoalesce(node.opacity, () => ( 1));
655
655
  return node.children.filter((c) => c.visible !== false).flatMap((c) => flattenPaths(c, m)).map((e) => ({ ...e, opacity: e.opacity * o }));
656
656
  }
@@ -672,8 +672,8 @@ function createVectorMorph(a, b, options = {}) {
672
672
  }
673
673
  const pa = flattenPaths(a);
674
674
  const pb = flattenPaths(b);
675
- const ba = _chunkUSJX5SW4cjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
676
- const bb = _chunkUSJX5SW4cjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
675
+ const ba = _chunkZHRVCW3Mcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
676
+ const bb = _chunkZHRVCW3Mcjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
677
677
  const id = _nullishCoalesce(options.id, () => ( a.id));
678
678
  const parts = [];
679
679
  const opacities = [];
@@ -685,10 +685,10 @@ function createVectorMorph(a, b, options = {}) {
685
685
  parts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));
686
686
  opacities.push([x.opacity, y.opacity]);
687
687
  } else if (x) {
688
- parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkUSJX5SW4cjs.IDENTITY_MATRIX));
688
+ parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkZHRVCW3Mcjs.IDENTITY_MATRIX));
689
689
  opacities.push([x.opacity, x.opacity]);
690
690
  } else if (y) {
691
- parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkUSJX5SW4cjs.IDENTITY_MATRIX, y.m));
691
+ parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkZHRVCW3Mcjs.IDENTITY_MATRIX, y.m));
692
692
  opacities.push([y.opacity, y.opacity]);
693
693
  }
694
694
  }
@@ -392,276 +392,6 @@ function eitherKey(chord) {
392
392
  return [(chord.mod || chord.ctrl || chord.meta) && "Mod", chord.alt && "Alt", chord.shift && "Shift", chord.key].filter(Boolean).join("+");
393
393
  }
394
394
 
395
- // src/canvas/arrangeShortcuts.ts
396
- var DEFAULT_ARRANGE_SHORTCUTS = [
397
- { action: "alignLeft", code: "KeyA", alt: true, label: "Alt+A" },
398
- { action: "alignCenter", code: "KeyH", alt: true, label: "Alt+H" },
399
- { action: "alignRight", code: "KeyD", alt: true, label: "Alt+D" },
400
- { action: "alignTop", code: "KeyW", alt: true, label: "Alt+W" },
401
- { action: "alignMiddle", code: "KeyV", alt: true, label: "Alt+V" },
402
- { action: "alignBottom", code: "KeyS", alt: true, label: "Alt+S" },
403
- { action: "distributeHorizontal", code: "KeyH", alt: true, shift: true, label: "Alt+Shift+H" },
404
- { action: "distributeVertical", code: "KeyV", alt: true, shift: true, label: "Alt+Shift+V" },
405
- { action: "lock", code: "KeyL", mod: true, label: "Mod+L" },
406
- { action: "unlock", code: "KeyL", mod: true, alt: true, label: "Mod+Alt+L" },
407
- { action: "bringForward", code: "BracketRight", mod: true, label: "Mod+]" },
408
- { action: "sendBackward", code: "BracketLeft", mod: true, label: "Mod+[" },
409
- { action: "bringToFront", code: "BracketRight", mod: true, alt: true, label: "Mod+Alt+]" },
410
- { action: "sendToBack", code: "BracketLeft", mod: true, alt: true, label: "Mod+Alt+[" },
411
- { action: "nextScene", code: "PageDown", label: "PageDown" },
412
- { action: "previousScene", code: "PageUp", label: "PageUp" }
413
- ];
414
- var maps = /* @__PURE__ */ new WeakMap();
415
- function arrangeShortcutMap(bindings) {
416
- let map = maps.get(bindings);
417
- if (!map) {
418
- map = new ShortcutMap(
419
- bindings.map((b) => ({
420
- command: b.action,
421
- chord: { key: b.code, mod: b.mod, alt: b.alt, shift: b.shift }
422
- })),
423
- { modifierMode: "either" }
424
- );
425
- maps.set(bindings, map);
426
- }
427
- return map;
428
- }
429
- function matchArrangeShortcut(event, bindings = DEFAULT_ARRANGE_SHORTCUTS) {
430
- return arrangeShortcutMap(bindings).resolve(event)?.command ?? null;
431
- }
432
-
433
- // src/canvas/gestures.ts
434
- function gestureRandom(seed) {
435
- let a = seed >>> 0;
436
- return () => {
437
- a = a + 1831565813 >>> 0;
438
- let t = a;
439
- t = Math.imul(t ^ t >>> 15, t | 1);
440
- t ^= t + Math.imul(t ^ t >>> 7, t | 61);
441
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
442
- };
443
- }
444
- function gestureSeed(value) {
445
- const text = JSON.stringify(value) ?? "";
446
- let h = 2166136261;
447
- for (let i = 0; i < text.length; i++) {
448
- h ^= text.charCodeAt(i);
449
- h = Math.imul(h, 16777619);
450
- }
451
- return h >>> 0;
452
- }
453
- function gestureUnion(rects) {
454
- if (!rects.length) throw new Error("Pass at least one rect.");
455
- const x = Math.min(...rects.map((r) => r.x));
456
- const y = Math.min(...rects.map((r) => r.y));
457
- const right = Math.max(...rects.map((r) => r.x + r.width));
458
- const bottom = Math.max(...rects.map((r) => r.y + r.height));
459
- return { x, y, width: right - x, height: bottom - y };
460
- }
461
- var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
462
- var centre = (r) => [r.x + r.width / 2, r.y + r.height / 2];
463
- function smoothNoise(rand, octaves = 3) {
464
- const waves = Array.from({ length: octaves }, (_, i) => ({ f: (i + 1) * (0.6 + rand() * 0.8), phase: rand() * Math.PI * 2, amp: 1 / (i + 1) }));
465
- const total = waves.reduce((sum, w) => sum + w.amp, 0);
466
- return (t) => waves.reduce((sum, w) => sum + w.amp * Math.sin(2 * Math.PI * w.f * t + w.phase), 0) / total;
467
- }
468
- function handPressure(rand) {
469
- const r = (lo, hi) => Math.round((lo + rand() * (hi - lo)) * 100) / 100;
470
- return [r(0.35, 0.55), r(0.8, 0.95), r(0.9, 1), r(0.75, 0.95), r(0.4, 0.65)];
471
- }
472
- var round = (p) => [Math.round(p[0] * 100) / 100, Math.round(p[1] * 100) / 100];
473
- function wobblyLine(a, b, rand, amp, bow = 0) {
474
- const dx = b[0] - a[0];
475
- const dy = b[1] - a[1];
476
- const len = Math.hypot(dx, dy);
477
- if (len === 0) return [a];
478
- const nx = -dy / len;
479
- const ny = dx / len;
480
- const noise = smoothNoise(rand);
481
- const n = clamp(Math.ceil(len / 4), 8, 200);
482
- return Array.from({ length: n + 1 }, (_, i) => {
483
- const t = i / n;
484
- const off = bow * 4 * t * (1 - t) + amp * noise(t) * Math.sqrt(Math.sin(Math.PI * t));
485
- return [a[0] + dx * t + nx * off, a[1] + dy * t + ny * off];
486
- });
487
- }
488
- function circleGesture(rect, seed, options = {}) {
489
- const rand = gestureRandom(seed);
490
- const pad = Math.max(0, options.padding ?? 8);
491
- const [cx, cy] = centre(rect);
492
- const tilt = (rand() - 0.5) * 0.08;
493
- const c = Math.abs(Math.cos(tilt));
494
- const s = Math.abs(Math.sin(tilt));
495
- const a = (rect.width / 2 * c + rect.height / 2 * s) * Math.SQRT2 + pad;
496
- const b = (rect.width / 2 * s + rect.height / 2 * c) * Math.SQRT2 + pad;
497
- const dir = rand() < 0.7 ? -1 : 1;
498
- const start = -Math.PI * 0.75 + (rand() - 0.5) * 0.6;
499
- const sweep = Math.PI * 2 + Math.PI * (0.1 + rand() * 0.12);
500
- const jitter = 0.03 + rand() * 0.03;
501
- const drift = 0.04 + rand() * 0.05;
502
- const noise = smoothNoise(rand, 4);
503
- const perimeter = Math.PI * (3 * (a + b) - Math.sqrt((3 * a + b) * (a + 3 * b)));
504
- const n = clamp(Math.ceil(perimeter * (sweep / (Math.PI * 2)) / 5), 48, 360);
505
- const points = Array.from({ length: n + 1 }, (_, i) => {
506
- const t = i / n;
507
- const angle = start + dir * sweep * t;
508
- const grow = 1 + jitter * (0.5 + 0.5 * noise(t)) + drift * t * t;
509
- const ex = a * grow * Math.cos(angle);
510
- const ey = b * grow * Math.sin(angle);
511
- return round([cx + ex * Math.cos(tilt) - ey * Math.sin(tilt), cy + ex * Math.sin(tilt) + ey * Math.cos(tilt)]);
512
- });
513
- return { points, pressure: handPressure(rand) };
514
- }
515
- function underlineGesture(rect, seed, options = {}) {
516
- const rand = gestureRandom(seed);
517
- const offset = Math.max(0, options.offset ?? 4);
518
- const amp = options.wave ? clamp(rect.width * 0.02, 2, 4) : 0;
519
- const shake = Math.min(1.5, offset * 0.4);
520
- const base = rect.y + rect.height + offset + amp + shake;
521
- const slope = Math.min(6, rect.width * 0.03);
522
- const x0 = rect.x - rect.width * (0.01 + rand() * 0.04);
523
- const x1 = rect.x + rect.width * (0.96 + rand() * 0.08);
524
- const line = wobblyLine([x0, base + rand() * slope], [x1, base + rand() * slope], rand, shake, (rand() - 0.5) * 2 * shake);
525
- const wavelength = clamp(rect.width / 8, 12, 28);
526
- const phase = rand() * Math.PI * 2;
527
- const points = amp ? line.map(([x, y]) => [x, y + amp * Math.sin(2 * Math.PI * (x - x0) / wavelength + phase)]) : line;
528
- return { points: points.map(round), pressure: handPressure(rand) };
529
- }
530
- function gestureEdgePoint(rect, toward, gap = 0) {
531
- const [cx, cy] = centre(rect);
532
- const dx = toward[0] - cx;
533
- const dy = toward[1] - cy;
534
- const len = Math.hypot(dx, dy);
535
- if (len === 0) return [cx, cy];
536
- const t = Math.min(dx ? rect.width / 2 / Math.abs(dx) : Infinity, dy ? rect.height / 2 / Math.abs(dy) : Infinity);
537
- return [cx + dx * t + dx / len * gap, cy + dy * t + dy / len * gap];
538
- }
539
- var isRect = (end) => !Array.isArray(end);
540
- function arrowGesture(from, to, seed, options = {}) {
541
- const rand = gestureRandom(seed);
542
- const gap = Math.max(0, options.gap ?? 6);
543
- const fromCentre = isRect(from) ? centre(from) : from;
544
- const toCentre = isRect(to) ? centre(to) : to;
545
- const start = isRect(from) ? gestureEdgePoint(from, toCentre, gap) : from;
546
- const tip = isRect(to) ? gestureEdgePoint(to, fromCentre, gap) : to;
547
- const dx = tip[0] - start[0];
548
- const dy = tip[1] - start[1];
549
- const len = Math.hypot(dx, dy);
550
- if (len < 4) throw new Error("The arrow's ends are too close together (or overlap): pass ends at least a few canvas units apart.");
551
- const curve = clamp(options.curve ?? (0.08 + rand() * 0.08) * (rand() < 0.5 ? -1 : 1), -1, 1);
552
- const nx = -dy / len;
553
- const ny = dx / len;
554
- const control = [(start[0] + tip[0]) / 2 + nx * curve * len, (start[1] + tip[1]) / 2 + ny * curve * len];
555
- const noise = smoothNoise(rand);
556
- const amp = Math.min(2, len * 0.01);
557
- const n = clamp(Math.ceil(len / 4), 12, 200);
558
- const shaft = Array.from({ length: n + 1 }, (_, i) => {
559
- const t = i / n;
560
- const u = 1 - t;
561
- const x = u * u * start[0] + 2 * u * t * control[0] + t * t * tip[0];
562
- const y = u * u * start[1] + 2 * u * t * control[1] + t * t * tip[1];
563
- const off = amp * noise(t) * Math.sqrt(Math.sin(Math.PI * t));
564
- return [x + nx * off, y + ny * off];
565
- });
566
- const tx = tip[0] - control[0];
567
- const ty = tip[1] - control[1];
568
- const tl = Math.hypot(tx, ty) || 1;
569
- const head = clamp(len * 0.15, 8, 22);
570
- const barb = (angle2, length) => {
571
- const c = Math.cos(angle2);
572
- const s = Math.sin(angle2);
573
- const bx = -(tx / tl) * c + ty / tl * s;
574
- const by = -(ty / tl) * c - tx / tl * s;
575
- return [1 / 3, 2 / 3, 1].map((f) => [tip[0] + bx * length * f, tip[1] + by * length * f]);
576
- };
577
- const clear = (pts) => !isRect(to) || pts.every(([x, y]) => x <= to.x || x >= to.x + to.width || y <= to.y || y >= to.y + to.height);
578
- const fit = (angle2) => {
579
- const length = head * (0.85 + rand() * 0.3);
580
- for (let k = 1; k > 0.05; k -= 0.15) {
581
- const pts = barb(angle2 * k, length);
582
- if (clear(pts)) return pts;
583
- }
584
- return barb(0, length);
585
- };
586
- const angle = () => (25 + rand() * 8) * Math.PI / 180;
587
- const first = fit(angle());
588
- const second = fit(-angle());
589
- const points = [...shaft, ...first, ...first.slice(0, -1).reverse(), tip, ...second];
590
- return { points: points.map(round), pressure: handPressure(rand) };
591
- }
592
- function bracketGesture(rect, side, seed, options = {}) {
593
- const rand = gestureRandom(seed);
594
- const pad = Math.max(0, options.padding ?? 8);
595
- const vertical = side === "left" || side === "right";
596
- const span = vertical ? rect.height : rect.width;
597
- const depth = Math.max(1, options.depth ?? clamp(span * 0.08, 6, 20));
598
- const from = vertical ? rect.y : rect.x;
599
- const edge = side === "left" ? rect.x - pad : side === "right" ? rect.x + rect.width + pad : side === "top" ? rect.y - pad : rect.y + rect.height + pad;
600
- const out = side === "left" || side === "top" ? -1 : 1;
601
- const at = (s, d) => vertical ? [edge + out * d, from + s * span] : [from + s * span, edge + out * d];
602
- const noise = smoothNoise(rand);
603
- const shake = Math.min(1, depth * 0.06);
604
- const n = clamp(Math.ceil(span / 4), 24, 240);
605
- let points;
606
- if (options.shape === "square") {
607
- const arm = depth * (0.8 + rand() * 0.2);
608
- const spine = Array.from({ length: n + 1 }, (_, i) => at(i / n, depth + shake * (1 + noise(i / n))));
609
- points = [at(0, depth - arm), at(0, depth * 0.5), ...spine, at(1, depth * 0.5), at(1, depth - arm * (0.85 + rand() * 0.15))];
610
- } else {
611
- const e = clamp(depth / Math.max(span, 1), 0.04, 0.2);
612
- const brace = (s) => {
613
- const u = s <= 0.5 ? s : 1 - s;
614
- if (u < e) return depth / 2 * Math.sin(Math.PI / 2 * u / e);
615
- if (u < 0.5 - e) return depth / 2;
616
- return depth / 2 + depth / 2 * (1 - Math.cos(Math.PI / 2 * (u - (0.5 - e)) / e));
617
- };
618
- points = Array.from({ length: n + 1 }, (_, i) => {
619
- const s = i / n;
620
- return at(s, brace(s) + shake * (1 + noise(s)) * Math.sin(Math.PI * s));
621
- });
622
- }
623
- return { points: points.map(round), pressure: handPressure(rand) };
624
- }
625
- function strikeGesture(rect, seed) {
626
- const rand = gestureRandom(seed);
627
- const [, cy] = centre(rect);
628
- const slope = rect.height * 0.08;
629
- const x0 = rect.x - rect.width * (0.01 + rand() * 0.03);
630
- const x1 = rect.x + rect.width * (1.01 + rand() * 0.03);
631
- const y0 = cy + (rand() - 0.5) * rect.height * 0.1 + slope * (rand() - 0.5);
632
- const y1 = cy + (rand() - 0.5) * rect.height * 0.1 + slope * (rand() - 0.5);
633
- const points = wobblyLine([x0, y0], [x1, y1], rand, Math.min(1.5, rect.height * 0.05));
634
- return { points: points.map(round), pressure: handPressure(rand) };
635
- }
636
- function crossGesture(rect, seed) {
637
- const rand = gestureRandom(seed);
638
- const over = () => 0.02 + rand() * 0.04;
639
- const left = () => rect.x - rect.width * over();
640
- const right = () => rect.x + rect.width * (1 + over());
641
- const top = () => rect.y - rect.height * over();
642
- const bottom = () => rect.y + rect.height * (1 + over());
643
- const amp = Math.min(1.5, Math.min(rect.width, rect.height) * 0.03);
644
- const first = wobblyLine([left(), top()], [right(), bottom()], rand, amp);
645
- const second = wobblyLine([right(), top()], [left(), bottom()], rand, amp);
646
- const mid1 = Math.floor(first.length / 2);
647
- const mid2 = Math.floor(second.length / 2);
648
- const points = [...first, ...first.slice(mid1, -1).reverse(), ...second.slice(1, mid2 + 1).reverse(), ...second];
649
- return { points: points.map(round), pressure: handPressure(rand) };
650
- }
651
- function checkGesture(at, seed, options = {}) {
652
- const rand = gestureRandom(seed);
653
- const [cx, cy] = isRect(at) ? centre(at) : at;
654
- const s = Math.max(4, options.size ?? (isRect(at) ? clamp(Math.min(at.width, at.height) * 0.6, 12, 48) : 20));
655
- const turn = (rand() - 0.5) * 12 * Math.PI / 180;
656
- const place = ([x, y]) => [cx + s * (x * Math.cos(turn) - y * Math.sin(turn)), cy + s * (x * Math.sin(turn) + y * Math.cos(turn))];
657
- const p0 = [-0.42 + rand() * 0.08, -0.05 + rand() * 0.08];
658
- const p1 = [-0.12 + rand() * 0.06, 0.38 + rand() * 0.06];
659
- const p2 = [0.48 + rand() * 0.06, -0.5 + rand() * 0.06];
660
- const short = wobblyLine(place(p0), place(p1), rand, 0, -s * 0.03);
661
- const long = wobblyLine(place(p1), place(p2), rand, Math.min(1, s * 0.02), s * 0.06);
662
- return { points: [...short, ...long.slice(1)].map(round), pressure: [0.5, 0.95, 0.9, 0.7, 0.35] };
663
- }
664
-
665
395
  export {
666
396
  PLATFORMS,
667
397
  detectPlatform,
@@ -678,18 +408,5 @@ export {
678
408
  codeFromKey,
679
409
  isEditableEventTarget,
680
410
  toShortcutBindings,
681
- ShortcutMap,
682
- DEFAULT_ARRANGE_SHORTCUTS,
683
- matchArrangeShortcut,
684
- gestureRandom,
685
- gestureSeed,
686
- gestureUnion,
687
- circleGesture,
688
- underlineGesture,
689
- gestureEdgePoint,
690
- arrowGesture,
691
- bracketGesture,
692
- strikeGesture,
693
- crossGesture,
694
- checkGesture
411
+ ShortcutMap
695
412
  };