@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
|
@@ -74,7 +74,7 @@ function profileAlongPolyline(points, values, count = 32) {
|
|
|
74
74
|
var round3 = (v) => Math.round(v * 1e3) / 1e3;
|
|
75
75
|
var loading = null;
|
|
76
76
|
function loadCanvasBrushstrokeRenderer() {
|
|
77
|
-
loading ??= import("./brushstrokeRender-
|
|
77
|
+
loading ??= import("./brushstrokeRender-KD453OBX.js").catch((error) => {
|
|
78
78
|
loading = null;
|
|
79
79
|
throw error;
|
|
80
80
|
});
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkQJVOJUTDcjs = require('./chunk-QJVOJUTD.cjs');
|
|
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 (0, _chunkQJVOJUTDcjs.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 _nullishCoalesce(_optionalChain([arrangeShortcutMap, 'call', _2 => _2(bindings), 'access', _3 => _3.resolve, 'call', _4 => _4(event), 'optionalAccess', _5 => _5.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 = _nullishCoalesce(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, _nullishCoalesce(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, _nullishCoalesce(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, _nullishCoalesce(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(_nullishCoalesce(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, _nullishCoalesce(options.padding, () => ( 8)));
|
|
205
|
+
const vertical = side === "left" || side === "right";
|
|
206
|
+
const span = vertical ? rect.height : rect.width;
|
|
207
|
+
const depth = Math.max(1, _nullishCoalesce(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, _nullishCoalesce(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
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
exports.DEFAULT_ARRANGE_SHORTCUTS = DEFAULT_ARRANGE_SHORTCUTS; exports.matchArrangeShortcut = matchArrangeShortcut; exports.gestureRandom = gestureRandom; exports.gestureSeed = gestureSeed; exports.gestureUnion = gestureUnion; exports.circleGesture = circleGesture; exports.underlineGesture = underlineGesture; exports.gestureEdgePoint = gestureEdgePoint; exports.arrowGesture = arrowGesture; exports.bracketGesture = bracketGesture; exports.strikeGesture = strikeGesture; exports.crossGesture = crossGesture; exports.checkGesture = checkGesture;
|