@pixerate/editor 0.265.0 → 0.266.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.cjs +4 -3
- package/dist/agent/index.js +3 -2
- package/dist/animation-editor/index.cjs +59 -59
- package/dist/animation-editor/index.js +3 -3
- package/dist/brushes/index.cjs +56 -56
- package/dist/brushes/index.js +3 -3
- package/dist/brushes/presets.d.cts +3 -3
- package/dist/brushes/presets.d.ts +3 -3
- package/dist/brushes/resolve.d.cts +1 -1
- package/dist/brushes/resolve.d.ts +1 -1
- package/dist/{brushstrokeRender-JQ2XQRUD.cjs → brushstrokeRender-FSUWXUZY.cjs} +15 -15
- package/dist/{brushstrokeRender-4UB6NRJW.js → brushstrokeRender-KD453OBX.js} +3 -3
- package/dist/canvas/index.cjs +15 -14
- package/dist/canvas/index.js +3 -2
- package/dist/{chunk-Q6RVVJW6.js → chunk-3C33YTNN.js} +1 -1
- package/dist/{chunk-NOP4Y5AB.cjs → chunk-3SBLVGOM.cjs} +23 -23
- package/dist/{chunk-TMDDMJCR.js → chunk-472INMWH.js} +4 -2
- package/dist/{chunk-ZS7LB2MV.js → chunk-4ODRXQRW.js} +1 -1
- package/dist/chunk-55ALHYJY.js +289 -0
- package/dist/{chunk-NHA26O5X.cjs → chunk-7KNW3WXZ.cjs} +14 -12
- package/dist/{chunk-O53MOGXG.cjs → chunk-AQZQWXEU.cjs} +35 -35
- package/dist/{chunk-J4SGJCPW.js → chunk-CIJBSUM5.js} +1133 -1806
- package/dist/{chunk-XDNWQMHY.js → chunk-DXYHQ2VN.js} +1 -1
- package/dist/chunk-E2Z4UARJ.cjs +289 -0
- package/dist/{chunk-BLR4KWYQ.js → chunk-EZOJBP4D.js} +1 -1
- package/dist/chunk-HAEB3MZD.js +664 -0
- package/dist/chunk-KIJIONZF.cjs +664 -0
- package/dist/{chunk-Z2Z2OHRM.js → chunk-LK4SXL3V.js} +1 -1
- package/dist/{chunk-DGXTEPCU.cjs → chunk-MVUQSK5J.cjs} +86 -86
- package/dist/{chunk-LPFQHVCO.js → chunk-PXXXRCME.js} +1 -284
- package/dist/{chunk-T7QSEKDY.cjs → chunk-QJVOJUTD.cjs} +4 -287
- package/dist/{chunk-WY23AUCA.js → chunk-R44Y3EFS.js} +1 -1
- package/dist/{chunk-677777GH.cjs → chunk-RFJZGTHA.cjs} +1137 -1810
- package/dist/{chunk-7PW6VCNW.js → chunk-T2LDTEXK.js} +1 -1
- package/dist/{chunk-7NQOGWLM.cjs → chunk-TOID45I2.cjs} +1 -1
- package/dist/{chunk-DEBIFWY6.cjs → chunk-VRK322ZC.cjs} +2 -2
- package/dist/{chunk-5OE4ZZ6V.cjs → chunk-WLUVZKVD.cjs} +30 -30
- package/dist/{chunk-ZHRVCW3M.cjs → chunk-XRXFVRGY.cjs} +10 -10
- package/dist/commands/index.cjs +26 -656
- package/dist/commands/index.js +18 -648
- package/dist/image-editor/index.cjs +786 -786
- package/dist/image-editor/index.js +4 -4
- package/dist/paint-editor/brush-model.d.cts +273 -0
- package/dist/paint-editor/brush-model.d.ts +273 -0
- package/dist/paint-editor/brushes.d.cts +6 -270
- package/dist/paint-editor/brushes.d.ts +6 -270
- package/dist/paint-editor/index.cjs +79 -79
- package/dist/paint-editor/index.js +5 -5
- package/dist/paint-editor/ui.d.cts +1 -1
- package/dist/paint-editor/ui.d.ts +1 -1
- package/dist/vector/contract.d.cts +52 -0
- package/dist/vector/contract.d.ts +52 -0
- package/dist/vector/index.cjs +1167 -969
- package/dist/vector/index.d.cts +1 -0
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.js +203 -5
- package/package.json +1 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ShortcutMap
|
|
3
|
+
} from "./chunk-PXXXRCME.js";
|
|
4
|
+
|
|
5
|
+
// src/canvas/arrangeShortcuts.ts
|
|
6
|
+
var DEFAULT_ARRANGE_SHORTCUTS = [
|
|
7
|
+
{ action: "alignLeft", code: "KeyA", alt: true, label: "Alt+A" },
|
|
8
|
+
{ action: "alignCenter", code: "KeyH", alt: true, label: "Alt+H" },
|
|
9
|
+
{ action: "alignRight", code: "KeyD", alt: true, label: "Alt+D" },
|
|
10
|
+
{ action: "alignTop", code: "KeyW", alt: true, label: "Alt+W" },
|
|
11
|
+
{ action: "alignMiddle", code: "KeyV", alt: true, label: "Alt+V" },
|
|
12
|
+
{ action: "alignBottom", code: "KeyS", alt: true, label: "Alt+S" },
|
|
13
|
+
{ action: "distributeHorizontal", code: "KeyH", alt: true, shift: true, label: "Alt+Shift+H" },
|
|
14
|
+
{ action: "distributeVertical", code: "KeyV", alt: true, shift: true, label: "Alt+Shift+V" },
|
|
15
|
+
{ action: "lock", code: "KeyL", mod: true, label: "Mod+L" },
|
|
16
|
+
{ action: "unlock", code: "KeyL", mod: true, alt: true, label: "Mod+Alt+L" },
|
|
17
|
+
{ action: "bringForward", code: "BracketRight", mod: true, label: "Mod+]" },
|
|
18
|
+
{ action: "sendBackward", code: "BracketLeft", mod: true, label: "Mod+[" },
|
|
19
|
+
{ action: "bringToFront", code: "BracketRight", mod: true, alt: true, label: "Mod+Alt+]" },
|
|
20
|
+
{ action: "sendToBack", code: "BracketLeft", mod: true, alt: true, label: "Mod+Alt+[" },
|
|
21
|
+
{ action: "nextScene", code: "PageDown", label: "PageDown" },
|
|
22
|
+
{ action: "previousScene", code: "PageUp", label: "PageUp" }
|
|
23
|
+
];
|
|
24
|
+
var maps = /* @__PURE__ */ new WeakMap();
|
|
25
|
+
function arrangeShortcutMap(bindings) {
|
|
26
|
+
let map = maps.get(bindings);
|
|
27
|
+
if (!map) {
|
|
28
|
+
map = new ShortcutMap(
|
|
29
|
+
bindings.map((b) => ({
|
|
30
|
+
command: b.action,
|
|
31
|
+
chord: { key: b.code, mod: b.mod, alt: b.alt, shift: b.shift }
|
|
32
|
+
})),
|
|
33
|
+
{ modifierMode: "either" }
|
|
34
|
+
);
|
|
35
|
+
maps.set(bindings, map);
|
|
36
|
+
}
|
|
37
|
+
return map;
|
|
38
|
+
}
|
|
39
|
+
function matchArrangeShortcut(event, bindings = DEFAULT_ARRANGE_SHORTCUTS) {
|
|
40
|
+
return arrangeShortcutMap(bindings).resolve(event)?.command ?? null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/canvas/gestures.ts
|
|
44
|
+
function gestureRandom(seed) {
|
|
45
|
+
let a = seed >>> 0;
|
|
46
|
+
return () => {
|
|
47
|
+
a = a + 1831565813 >>> 0;
|
|
48
|
+
let t = a;
|
|
49
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
50
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
51
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function gestureSeed(value) {
|
|
55
|
+
const text = JSON.stringify(value) ?? "";
|
|
56
|
+
let h = 2166136261;
|
|
57
|
+
for (let i = 0; i < text.length; i++) {
|
|
58
|
+
h ^= text.charCodeAt(i);
|
|
59
|
+
h = Math.imul(h, 16777619);
|
|
60
|
+
}
|
|
61
|
+
return h >>> 0;
|
|
62
|
+
}
|
|
63
|
+
function gestureUnion(rects) {
|
|
64
|
+
if (!rects.length) throw new Error("Pass at least one rect.");
|
|
65
|
+
const x = Math.min(...rects.map((r) => r.x));
|
|
66
|
+
const y = Math.min(...rects.map((r) => r.y));
|
|
67
|
+
const right = Math.max(...rects.map((r) => r.x + r.width));
|
|
68
|
+
const bottom = Math.max(...rects.map((r) => r.y + r.height));
|
|
69
|
+
return { x, y, width: right - x, height: bottom - y };
|
|
70
|
+
}
|
|
71
|
+
var clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
72
|
+
var centre = (r) => [r.x + r.width / 2, r.y + r.height / 2];
|
|
73
|
+
function smoothNoise(rand, octaves = 3) {
|
|
74
|
+
const waves = Array.from({ length: octaves }, (_, i) => ({ f: (i + 1) * (0.6 + rand() * 0.8), phase: rand() * Math.PI * 2, amp: 1 / (i + 1) }));
|
|
75
|
+
const total = waves.reduce((sum, w) => sum + w.amp, 0);
|
|
76
|
+
return (t) => waves.reduce((sum, w) => sum + w.amp * Math.sin(2 * Math.PI * w.f * t + w.phase), 0) / total;
|
|
77
|
+
}
|
|
78
|
+
function handPressure(rand) {
|
|
79
|
+
const r = (lo, hi) => Math.round((lo + rand() * (hi - lo)) * 100) / 100;
|
|
80
|
+
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)];
|
|
81
|
+
}
|
|
82
|
+
var round = (p) => [Math.round(p[0] * 100) / 100, Math.round(p[1] * 100) / 100];
|
|
83
|
+
function wobblyLine(a, b, rand, amp, bow = 0) {
|
|
84
|
+
const dx = b[0] - a[0];
|
|
85
|
+
const dy = b[1] - a[1];
|
|
86
|
+
const len = Math.hypot(dx, dy);
|
|
87
|
+
if (len === 0) return [a];
|
|
88
|
+
const nx = -dy / len;
|
|
89
|
+
const ny = dx / len;
|
|
90
|
+
const noise = smoothNoise(rand);
|
|
91
|
+
const n = clamp(Math.ceil(len / 4), 8, 200);
|
|
92
|
+
return Array.from({ length: n + 1 }, (_, i) => {
|
|
93
|
+
const t = i / n;
|
|
94
|
+
const off = bow * 4 * t * (1 - t) + amp * noise(t) * Math.sqrt(Math.sin(Math.PI * t));
|
|
95
|
+
return [a[0] + dx * t + nx * off, a[1] + dy * t + ny * off];
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function circleGesture(rect, seed, options = {}) {
|
|
99
|
+
const rand = gestureRandom(seed);
|
|
100
|
+
const pad = Math.max(0, options.padding ?? 8);
|
|
101
|
+
const [cx, cy] = centre(rect);
|
|
102
|
+
const tilt = (rand() - 0.5) * 0.08;
|
|
103
|
+
const c = Math.abs(Math.cos(tilt));
|
|
104
|
+
const s = Math.abs(Math.sin(tilt));
|
|
105
|
+
const a = (rect.width / 2 * c + rect.height / 2 * s) * Math.SQRT2 + pad;
|
|
106
|
+
const b = (rect.width / 2 * s + rect.height / 2 * c) * Math.SQRT2 + pad;
|
|
107
|
+
const dir = rand() < 0.7 ? -1 : 1;
|
|
108
|
+
const start = -Math.PI * 0.75 + (rand() - 0.5) * 0.6;
|
|
109
|
+
const sweep = Math.PI * 2 + Math.PI * (0.1 + rand() * 0.12);
|
|
110
|
+
const jitter = 0.03 + rand() * 0.03;
|
|
111
|
+
const drift = 0.04 + rand() * 0.05;
|
|
112
|
+
const noise = smoothNoise(rand, 4);
|
|
113
|
+
const perimeter = Math.PI * (3 * (a + b) - Math.sqrt((3 * a + b) * (a + 3 * b)));
|
|
114
|
+
const n = clamp(Math.ceil(perimeter * (sweep / (Math.PI * 2)) / 5), 48, 360);
|
|
115
|
+
const points = Array.from({ length: n + 1 }, (_, i) => {
|
|
116
|
+
const t = i / n;
|
|
117
|
+
const angle = start + dir * sweep * t;
|
|
118
|
+
const grow = 1 + jitter * (0.5 + 0.5 * noise(t)) + drift * t * t;
|
|
119
|
+
const ex = a * grow * Math.cos(angle);
|
|
120
|
+
const ey = b * grow * Math.sin(angle);
|
|
121
|
+
return round([cx + ex * Math.cos(tilt) - ey * Math.sin(tilt), cy + ex * Math.sin(tilt) + ey * Math.cos(tilt)]);
|
|
122
|
+
});
|
|
123
|
+
return { points, pressure: handPressure(rand) };
|
|
124
|
+
}
|
|
125
|
+
function underlineGesture(rect, seed, options = {}) {
|
|
126
|
+
const rand = gestureRandom(seed);
|
|
127
|
+
const offset = Math.max(0, options.offset ?? 4);
|
|
128
|
+
const amp = options.wave ? clamp(rect.width * 0.02, 2, 4) : 0;
|
|
129
|
+
const shake = Math.min(1.5, offset * 0.4);
|
|
130
|
+
const base = rect.y + rect.height + offset + amp + shake;
|
|
131
|
+
const slope = Math.min(6, rect.width * 0.03);
|
|
132
|
+
const x0 = rect.x - rect.width * (0.01 + rand() * 0.04);
|
|
133
|
+
const x1 = rect.x + rect.width * (0.96 + rand() * 0.08);
|
|
134
|
+
const line = wobblyLine([x0, base + rand() * slope], [x1, base + rand() * slope], rand, shake, (rand() - 0.5) * 2 * shake);
|
|
135
|
+
const wavelength = clamp(rect.width / 8, 12, 28);
|
|
136
|
+
const phase = rand() * Math.PI * 2;
|
|
137
|
+
const points = amp ? line.map(([x, y]) => [x, y + amp * Math.sin(2 * Math.PI * (x - x0) / wavelength + phase)]) : line;
|
|
138
|
+
return { points: points.map(round), pressure: handPressure(rand) };
|
|
139
|
+
}
|
|
140
|
+
function gestureEdgePoint(rect, toward, gap = 0) {
|
|
141
|
+
const [cx, cy] = centre(rect);
|
|
142
|
+
const dx = toward[0] - cx;
|
|
143
|
+
const dy = toward[1] - cy;
|
|
144
|
+
const len = Math.hypot(dx, dy);
|
|
145
|
+
if (len === 0) return [cx, cy];
|
|
146
|
+
const t = Math.min(dx ? rect.width / 2 / Math.abs(dx) : Infinity, dy ? rect.height / 2 / Math.abs(dy) : Infinity);
|
|
147
|
+
return [cx + dx * t + dx / len * gap, cy + dy * t + dy / len * gap];
|
|
148
|
+
}
|
|
149
|
+
var isRect = (end) => !Array.isArray(end);
|
|
150
|
+
function arrowGesture(from, to, seed, options = {}) {
|
|
151
|
+
const rand = gestureRandom(seed);
|
|
152
|
+
const gap = Math.max(0, options.gap ?? 6);
|
|
153
|
+
const fromCentre = isRect(from) ? centre(from) : from;
|
|
154
|
+
const toCentre = isRect(to) ? centre(to) : to;
|
|
155
|
+
const start = isRect(from) ? gestureEdgePoint(from, toCentre, gap) : from;
|
|
156
|
+
const tip = isRect(to) ? gestureEdgePoint(to, fromCentre, gap) : to;
|
|
157
|
+
const dx = tip[0] - start[0];
|
|
158
|
+
const dy = tip[1] - start[1];
|
|
159
|
+
const len = Math.hypot(dx, dy);
|
|
160
|
+
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.");
|
|
161
|
+
const curve = clamp(options.curve ?? (0.08 + rand() * 0.08) * (rand() < 0.5 ? -1 : 1), -1, 1);
|
|
162
|
+
const nx = -dy / len;
|
|
163
|
+
const ny = dx / len;
|
|
164
|
+
const control = [(start[0] + tip[0]) / 2 + nx * curve * len, (start[1] + tip[1]) / 2 + ny * curve * len];
|
|
165
|
+
const noise = smoothNoise(rand);
|
|
166
|
+
const amp = Math.min(2, len * 0.01);
|
|
167
|
+
const n = clamp(Math.ceil(len / 4), 12, 200);
|
|
168
|
+
const shaft = Array.from({ length: n + 1 }, (_, i) => {
|
|
169
|
+
const t = i / n;
|
|
170
|
+
const u = 1 - t;
|
|
171
|
+
const x = u * u * start[0] + 2 * u * t * control[0] + t * t * tip[0];
|
|
172
|
+
const y = u * u * start[1] + 2 * u * t * control[1] + t * t * tip[1];
|
|
173
|
+
const off = amp * noise(t) * Math.sqrt(Math.sin(Math.PI * t));
|
|
174
|
+
return [x + nx * off, y + ny * off];
|
|
175
|
+
});
|
|
176
|
+
const tx = tip[0] - control[0];
|
|
177
|
+
const ty = tip[1] - control[1];
|
|
178
|
+
const tl = Math.hypot(tx, ty) || 1;
|
|
179
|
+
const head = clamp(len * 0.15, 8, 22);
|
|
180
|
+
const barb = (angle2, length) => {
|
|
181
|
+
const c = Math.cos(angle2);
|
|
182
|
+
const s = Math.sin(angle2);
|
|
183
|
+
const bx = -(tx / tl) * c + ty / tl * s;
|
|
184
|
+
const by = -(ty / tl) * c - tx / tl * s;
|
|
185
|
+
return [1 / 3, 2 / 3, 1].map((f) => [tip[0] + bx * length * f, tip[1] + by * length * f]);
|
|
186
|
+
};
|
|
187
|
+
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);
|
|
188
|
+
const fit = (angle2) => {
|
|
189
|
+
const length = head * (0.85 + rand() * 0.3);
|
|
190
|
+
for (let k = 1; k > 0.05; k -= 0.15) {
|
|
191
|
+
const pts = barb(angle2 * k, length);
|
|
192
|
+
if (clear(pts)) return pts;
|
|
193
|
+
}
|
|
194
|
+
return barb(0, length);
|
|
195
|
+
};
|
|
196
|
+
const angle = () => (25 + rand() * 8) * Math.PI / 180;
|
|
197
|
+
const first = fit(angle());
|
|
198
|
+
const second = fit(-angle());
|
|
199
|
+
const points = [...shaft, ...first, ...first.slice(0, -1).reverse(), tip, ...second];
|
|
200
|
+
return { points: points.map(round), pressure: handPressure(rand) };
|
|
201
|
+
}
|
|
202
|
+
function bracketGesture(rect, side, seed, options = {}) {
|
|
203
|
+
const rand = gestureRandom(seed);
|
|
204
|
+
const pad = Math.max(0, options.padding ?? 8);
|
|
205
|
+
const vertical = side === "left" || side === "right";
|
|
206
|
+
const span = vertical ? rect.height : rect.width;
|
|
207
|
+
const depth = Math.max(1, options.depth ?? clamp(span * 0.08, 6, 20));
|
|
208
|
+
const from = vertical ? rect.y : rect.x;
|
|
209
|
+
const edge = side === "left" ? rect.x - pad : side === "right" ? rect.x + rect.width + pad : side === "top" ? rect.y - pad : rect.y + rect.height + pad;
|
|
210
|
+
const out = side === "left" || side === "top" ? -1 : 1;
|
|
211
|
+
const at = (s, d) => vertical ? [edge + out * d, from + s * span] : [from + s * span, edge + out * d];
|
|
212
|
+
const noise = smoothNoise(rand);
|
|
213
|
+
const shake = Math.min(1, depth * 0.06);
|
|
214
|
+
const n = clamp(Math.ceil(span / 4), 24, 240);
|
|
215
|
+
let points;
|
|
216
|
+
if (options.shape === "square") {
|
|
217
|
+
const arm = depth * (0.8 + rand() * 0.2);
|
|
218
|
+
const spine = Array.from({ length: n + 1 }, (_, i) => at(i / n, depth + shake * (1 + noise(i / n))));
|
|
219
|
+
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))];
|
|
220
|
+
} else {
|
|
221
|
+
const e = clamp(depth / Math.max(span, 1), 0.04, 0.2);
|
|
222
|
+
const brace = (s) => {
|
|
223
|
+
const u = s <= 0.5 ? s : 1 - s;
|
|
224
|
+
if (u < e) return depth / 2 * Math.sin(Math.PI / 2 * u / e);
|
|
225
|
+
if (u < 0.5 - e) return depth / 2;
|
|
226
|
+
return depth / 2 + depth / 2 * (1 - Math.cos(Math.PI / 2 * (u - (0.5 - e)) / e));
|
|
227
|
+
};
|
|
228
|
+
points = Array.from({ length: n + 1 }, (_, i) => {
|
|
229
|
+
const s = i / n;
|
|
230
|
+
return at(s, brace(s) + shake * (1 + noise(s)) * Math.sin(Math.PI * s));
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return { points: points.map(round), pressure: handPressure(rand) };
|
|
234
|
+
}
|
|
235
|
+
function strikeGesture(rect, seed) {
|
|
236
|
+
const rand = gestureRandom(seed);
|
|
237
|
+
const [, cy] = centre(rect);
|
|
238
|
+
const slope = rect.height * 0.08;
|
|
239
|
+
const x0 = rect.x - rect.width * (0.01 + rand() * 0.03);
|
|
240
|
+
const x1 = rect.x + rect.width * (1.01 + rand() * 0.03);
|
|
241
|
+
const y0 = cy + (rand() - 0.5) * rect.height * 0.1 + slope * (rand() - 0.5);
|
|
242
|
+
const y1 = cy + (rand() - 0.5) * rect.height * 0.1 + slope * (rand() - 0.5);
|
|
243
|
+
const points = wobblyLine([x0, y0], [x1, y1], rand, Math.min(1.5, rect.height * 0.05));
|
|
244
|
+
return { points: points.map(round), pressure: handPressure(rand) };
|
|
245
|
+
}
|
|
246
|
+
function crossGesture(rect, seed) {
|
|
247
|
+
const rand = gestureRandom(seed);
|
|
248
|
+
const over = () => 0.02 + rand() * 0.04;
|
|
249
|
+
const left = () => rect.x - rect.width * over();
|
|
250
|
+
const right = () => rect.x + rect.width * (1 + over());
|
|
251
|
+
const top = () => rect.y - rect.height * over();
|
|
252
|
+
const bottom = () => rect.y + rect.height * (1 + over());
|
|
253
|
+
const amp = Math.min(1.5, Math.min(rect.width, rect.height) * 0.03);
|
|
254
|
+
const first = wobblyLine([left(), top()], [right(), bottom()], rand, amp);
|
|
255
|
+
const second = wobblyLine([right(), top()], [left(), bottom()], rand, amp);
|
|
256
|
+
const mid1 = Math.floor(first.length / 2);
|
|
257
|
+
const mid2 = Math.floor(second.length / 2);
|
|
258
|
+
const points = [...first, ...first.slice(mid1, -1).reverse(), ...second.slice(1, mid2 + 1).reverse(), ...second];
|
|
259
|
+
return { points: points.map(round), pressure: handPressure(rand) };
|
|
260
|
+
}
|
|
261
|
+
function checkGesture(at, seed, options = {}) {
|
|
262
|
+
const rand = gestureRandom(seed);
|
|
263
|
+
const [cx, cy] = isRect(at) ? centre(at) : at;
|
|
264
|
+
const s = Math.max(4, options.size ?? (isRect(at) ? clamp(Math.min(at.width, at.height) * 0.6, 12, 48) : 20));
|
|
265
|
+
const turn = (rand() - 0.5) * 12 * Math.PI / 180;
|
|
266
|
+
const place = ([x, y]) => [cx + s * (x * Math.cos(turn) - y * Math.sin(turn)), cy + s * (x * Math.sin(turn) + y * Math.cos(turn))];
|
|
267
|
+
const p0 = [-0.42 + rand() * 0.08, -0.05 + rand() * 0.08];
|
|
268
|
+
const p1 = [-0.12 + rand() * 0.06, 0.38 + rand() * 0.06];
|
|
269
|
+
const p2 = [0.48 + rand() * 0.06, -0.5 + rand() * 0.06];
|
|
270
|
+
const short = wobblyLine(place(p0), place(p1), rand, 0, -s * 0.03);
|
|
271
|
+
const long = wobblyLine(place(p1), place(p2), rand, Math.min(1, s * 0.02), s * 0.06);
|
|
272
|
+
return { points: [...short, ...long.slice(1)].map(round), pressure: [0.5, 0.95, 0.9, 0.7, 0.35] };
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export {
|
|
276
|
+
DEFAULT_ARRANGE_SHORTCUTS,
|
|
277
|
+
matchArrangeShortcut,
|
|
278
|
+
gestureRandom,
|
|
279
|
+
gestureSeed,
|
|
280
|
+
gestureUnion,
|
|
281
|
+
circleGesture,
|
|
282
|
+
underlineGesture,
|
|
283
|
+
gestureEdgePoint,
|
|
284
|
+
arrowGesture,
|
|
285
|
+
bracketGesture,
|
|
286
|
+
strikeGesture,
|
|
287
|
+
crossGesture,
|
|
288
|
+
checkGesture
|
|
289
|
+
};
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
var _chunkE2Z4UARJcjs = require('./chunk-E2Z4UARJ.cjs');
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
var _chunkQJVOJUTDcjs = require('./chunk-QJVOJUTD.cjs');
|
|
14
16
|
|
|
15
17
|
// src/commands/builtins.ts
|
|
16
18
|
var DEFAULT_HISTORY_SHORTCUTS = [
|
|
@@ -55,7 +57,7 @@ function createHistoryCommands(history, options = {}) {
|
|
|
55
57
|
}
|
|
56
58
|
var historyShortcutMap = null;
|
|
57
59
|
function matchHistoryShortcut(event, options = {}) {
|
|
58
|
-
historyShortcutMap ??= new (0,
|
|
60
|
+
historyShortcutMap ??= new (0, _chunkQJVOJUTDcjs.ShortcutMap)(DEFAULT_HISTORY_SHORTCUTS);
|
|
59
61
|
return _nullishCoalesce(_optionalChain([historyShortcutMap, 'access', _2 => _2.resolve, 'call', _3 => _3(event, options), 'optionalAccess', _4 => _4.command]), () => ( null));
|
|
60
62
|
}
|
|
61
63
|
var ARRANGE_LABELS = {
|
|
@@ -90,7 +92,7 @@ function createArrangeCommands(controller, options = {}) {
|
|
|
90
92
|
const prefix = _nullishCoalesce(options.prefix, () => ( "canvas."));
|
|
91
93
|
const group = _nullishCoalesce(options.group, () => ( "Arrange"));
|
|
92
94
|
const scope = options.scope === null ? void 0 : _nullishCoalesce(options.scope, () => ( "canvas"));
|
|
93
|
-
const bindings = _nullishCoalesce(options.bindings, () => (
|
|
95
|
+
const bindings = _nullishCoalesce(options.bindings, () => ( _chunkE2Z4UARJcjs.DEFAULT_ARRANGE_SHORTCUTS));
|
|
94
96
|
const count = (params) => _nullishCoalesce(_optionalChain([params, 'optionalAccess', _5 => _5.ids, 'optionalAccess', _6 => _6.length]), () => ( _optionalChain([options, 'access', _7 => _7.getSelectedIds, 'optionalCall', _8 => _8(), 'access', _9 => _9.length])));
|
|
95
97
|
const needs = (min, what) => (_, params) => {
|
|
96
98
|
const n = count(params);
|
|
@@ -441,9 +443,9 @@ function createGestureCommands(target, base, prefix, options) {
|
|
|
441
443
|
return value;
|
|
442
444
|
};
|
|
443
445
|
const end = (value, name) => Array.isArray(value) ? [value[0], value[1]] : box(value, name);
|
|
444
|
-
const boxes = (values, name) =>
|
|
446
|
+
const boxes = (values, name) => _chunkE2Z4UARJcjs.gestureUnion.call(void 0, values.map((v, i) => box(v, `${name}[${i}]`)));
|
|
445
447
|
const gesture = (spec) => {
|
|
446
|
-
const seedOf = (params) => _nullishCoalesce(params.seed, () => (
|
|
448
|
+
const seedOf = (params) => _nullishCoalesce(params.seed, () => ( _chunkE2Z4UARJcjs.gestureSeed.call(void 0, { gesture: spec.name, ...params })));
|
|
447
449
|
const generate = (params) => {
|
|
448
450
|
const seed = seedOf(params);
|
|
449
451
|
return { seed, stroke: spec.make(params, seed) };
|
|
@@ -497,7 +499,7 @@ function createGestureCommands(target, base, prefix, options) {
|
|
|
497
499
|
around: gestureBoxes("What to circle."),
|
|
498
500
|
padding: { type: "number", minimum: 0, maximum: 500, description: "Space between them and the loop, canvas units (default 8)." }
|
|
499
501
|
},
|
|
500
|
-
make: (p, seed) =>
|
|
502
|
+
make: (p, seed) => _chunkE2Z4UARJcjs.circleGesture.call(void 0, boxes(p.around, "around"), seed, { ...p.padding !== void 0 ? { padding: p.padding } : {} })
|
|
501
503
|
}),
|
|
502
504
|
gesture({
|
|
503
505
|
name: "underline",
|
|
@@ -510,7 +512,7 @@ function createGestureCommands(target, base, prefix, options) {
|
|
|
510
512
|
offset: { type: "number", minimum: 0, maximum: 200, description: "Gap below the bottom edge, canvas units (default 4)." },
|
|
511
513
|
wave: { type: "boolean", description: "A wavy (squiggly) underline instead of a straight one (default false)." }
|
|
512
514
|
},
|
|
513
|
-
make: (p, seed) =>
|
|
515
|
+
make: (p, seed) => _chunkE2Z4UARJcjs.underlineGesture.call(void 0, box(p.under, "under"), seed, { ...p.offset !== void 0 ? { offset: p.offset } : {}, ...p.wave ? { wave: true } : {} })
|
|
514
516
|
}),
|
|
515
517
|
gesture({
|
|
516
518
|
name: "arrow",
|
|
@@ -524,7 +526,7 @@ function createGestureCommands(target, base, prefix, options) {
|
|
|
524
526
|
curve: { type: "number", minimum: -1, maximum: 1, description: "Bend of the shaft \u22121..1: how far its middle bulges, as a fraction of half its length; positive bends to the left of travel, 0 is straight (default: a gentle seeded bend, about 0.1)." },
|
|
525
527
|
gap: { type: "number", minimum: 0, maximum: 200, description: "Space between a box end and the arrow, canvas units (default 6)." }
|
|
526
528
|
},
|
|
527
|
-
make: (p, seed) =>
|
|
529
|
+
make: (p, seed) => _chunkE2Z4UARJcjs.arrowGesture.call(void 0, end(p.from, "from"), end(p.to, "to"), seed, { ...p.curve !== void 0 ? { curve: p.curve } : {}, ...p.gap !== void 0 ? { gap: p.gap } : {} })
|
|
528
530
|
}),
|
|
529
531
|
gesture({
|
|
530
532
|
name: "bracket",
|
|
@@ -539,7 +541,7 @@ function createGestureCommands(target, base, prefix, options) {
|
|
|
539
541
|
padding: { type: "number", minimum: 0, maximum: 500, description: "Gap between them and the bracket, canvas units (default 8)." },
|
|
540
542
|
depth: { type: "number", exclusiveMinimum: 0, maximum: 500, description: "How far the bracket reaches out, canvas units (default: from the span, 6..20)." }
|
|
541
543
|
},
|
|
542
|
-
make: (p, seed) =>
|
|
544
|
+
make: (p, seed) => _chunkE2Z4UARJcjs.bracketGesture.call(void 0, boxes(p.around, "around"), p.side, seed, {
|
|
543
545
|
...p.shape ? { shape: p.shape } : {},
|
|
544
546
|
...p.padding !== void 0 ? { padding: p.padding } : {},
|
|
545
547
|
...p.depth !== void 0 ? { depth: p.depth } : {}
|
|
@@ -552,7 +554,7 @@ function createGestureCommands(target, base, prefix, options) {
|
|
|
552
554
|
description: "Strikes a line through the middle of a box or node, a little past both ends: for text or a value to drop. It only marks it; nothing is deleted.",
|
|
553
555
|
required: ["over"],
|
|
554
556
|
properties: { over: gestureBox("What to strike through: a box { x, y, width, height } or a node { nodeId }.") },
|
|
555
|
-
make: (p, seed) =>
|
|
557
|
+
make: (p, seed) => _chunkE2Z4UARJcjs.strikeGesture.call(void 0, box(p.over, "over"), seed)
|
|
556
558
|
}),
|
|
557
559
|
gesture({
|
|
558
560
|
name: "cross",
|
|
@@ -561,7 +563,7 @@ function createGestureCommands(target, base, prefix, options) {
|
|
|
561
563
|
description: "Crosses out a box or node with an X from corner to corner: for a rejected option. It only marks it; nothing is deleted. One stroke, so the pen runs back over part of the first diagonal before drawing the second.",
|
|
562
564
|
required: ["over"],
|
|
563
565
|
properties: { over: gestureBox("What to cross out: a box { x, y, width, height } or a node { nodeId }.") },
|
|
564
|
-
make: (p, seed) =>
|
|
566
|
+
make: (p, seed) => _chunkE2Z4UARJcjs.crossGesture.call(void 0, box(p.over, "over"), seed)
|
|
565
567
|
}),
|
|
566
568
|
gesture({
|
|
567
569
|
name: "check",
|
|
@@ -573,7 +575,7 @@ function createGestureCommands(target, base, prefix, options) {
|
|
|
573
575
|
at: gestureEnd("Where the tick goes: a box, a node { nodeId } (its centre) or a point [x, y]."),
|
|
574
576
|
size: { type: "number", exclusiveMinimum: 0, maximum: 2e3, description: "Height of the tick, canvas units (default: 60% of the box's smaller side, 12..48; 20 at a point)." }
|
|
575
577
|
},
|
|
576
|
-
make: (p, seed) =>
|
|
578
|
+
make: (p, seed) => _chunkE2Z4UARJcjs.checkGesture.call(void 0, end(p.at, "at"), seed, { ...p.size !== void 0 ? { size: p.size } : {} })
|
|
577
579
|
})
|
|
578
580
|
];
|
|
579
581
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkXRXFVRGYcjs = require('./chunk-XRXFVRGY.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 =
|
|
40
|
+
function subpathToMorphContour(sp, m = _chunkXRXFVRGYcjs.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 =
|
|
71
|
-
const pts =
|
|
70
|
+
function morphContourToSubpath(c, m = _chunkXRXFVRGYcjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunkXRXFVRGYcjs.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 = _chunkZHRVCW3Mcjs.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 =
|
|
87
|
+
const type = _chunkXRXFVRGYcjs.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 =
|
|
270
|
+
const b = _chunkXRXFVRGYcjs.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 =
|
|
459
|
+
const s = _chunkXRXFVRGYcjs.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 =
|
|
471
|
-
let stopsB =
|
|
470
|
+
let stopsA = _chunkXRXFVRGYcjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunkXRXFVRGYcjs.sortedVectorGradientStops.call(void 0, b);
|
|
472
472
|
const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
|
|
473
473
|
if (resampled) {
|
|
474
|
-
const offs = [...
|
|
474
|
+
const offs = [..._chunkXRXFVRGYcjs.expandVectorGradientStops.call(void 0, a), ..._chunkXRXFVRGYcjs.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 =
|
|
502
|
-
const eb =
|
|
501
|
+
const ea = _chunkXRXFVRGYcjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunkXRXFVRGYcjs.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 =
|
|
516
|
-
const pb =
|
|
515
|
+
const pa = _chunkXRXFVRGYcjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunkXRXFVRGYcjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunkXRXFVRGYcjs.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 =
|
|
539
|
-
const pb =
|
|
538
|
+
const pa = _chunkXRXFVRGYcjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunkXRXFVRGYcjs.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 &&
|
|
545
|
-
const gb = pb &&
|
|
544
|
+
const ga = pa && _chunkXRXFVRGYcjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunkXRXFVRGYcjs.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 =
|
|
557
|
-
const y =
|
|
556
|
+
const x = _chunkXRXFVRGYcjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunkXRXFVRGYcjs.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 =
|
|
600
|
+
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkXRXFVRGYcjs.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
|
|
626
|
+
return _chunkXRXFVRGYcjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
|
|
627
627
|
}
|
|
628
|
-
function preparePathMorph(a, b, options, ma =
|
|
628
|
+
function preparePathMorph(a, b, options, ma = _chunkXRXFVRGYcjs.nodeMatrix.call(void 0, a), mb = _chunkXRXFVRGYcjs.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 = !
|
|
633
|
+
const rigid = !_chunkXRXFVRGYcjs.isIdentityMatrix.call(void 0, ma) || !_chunkXRXFVRGYcjs.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) :
|
|
638
|
-
const back = rigid ?
|
|
637
|
+
const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkXRXFVRGYcjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunkXRXFVRGYcjs.invertMatrix.call(void 0, m) : _chunkXRXFVRGYcjs.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 = _chunkZHRVCW3Mcjs.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 && !
|
|
646
|
+
if (rigid && !_chunkXRXFVRGYcjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
|
|
647
647
|
return node;
|
|
648
648
|
};
|
|
649
649
|
}
|
|
650
|
-
function flattenPaths(node, parent =
|
|
651
|
-
const m =
|
|
650
|
+
function flattenPaths(node, parent = _chunkXRXFVRGYcjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunkXRXFVRGYcjs.multiplyMatrices.call(void 0, _chunkXRXFVRGYcjs.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(
|
|
653
|
+
if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkXRXFVRGYcjs.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 =
|
|
676
|
-
const bb =
|
|
675
|
+
const ba = _chunkXRXFVRGYcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunkXRXFVRGYcjs.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,
|
|
688
|
+
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkXRXFVRGYcjs.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,
|
|
691
|
+
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkXRXFVRGYcjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|