@algorisys/tinyfly 0.74.1 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/lib/addons/adapters.js +236 -121
- package/lib/addons/characters.js +501 -141
- package/lib/addons/{dom-adapter-ChrbtkLC.js → dom-adapter-CrNwoomd.js} +52 -52
- package/lib/addons/gsap-compat.js +1 -1
- package/lib/addons/sketch-CB6VNfnR.js +128 -0
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3526 -3047
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +2 -0
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +70 -70
- package/lib/headless/headless.js +302 -2
- package/lib/player/tinyfly-player.es.js +73 -73
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +18 -0
- package/lib/types/adapters/canvas/index.d.ts +3 -0
- package/lib/types/adapters/canvas/outline.d.ts +26 -0
- package/lib/types/adapters/canvas/polyline.d.ts +12 -0
- package/lib/types/adapters/canvas/sketch.d.ts +54 -0
- package/lib/types/characters/erase.d.ts +31 -0
- package/lib/types/characters/hand.d.ts +81 -0
- package/lib/types/characters/index.d.ts +7 -1
- package/lib/types/characters/polyline.d.ts +12 -0
- package/lib/types/characters/sketch.d.ts +54 -0
- package/lib/types/characters/stick-figure.d.ts +214 -5
- package/package.json +1 -1
package/lib/addons/characters.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { s as X, p as oe, a as ne } from "./sketch-CB6VNfnR.js";
|
|
2
|
+
import { b as ht, c as at } from "./sketch-CB6VNfnR.js";
|
|
3
|
+
const Y = {
|
|
2
4
|
lean: 0,
|
|
3
5
|
headTilt: 0,
|
|
4
6
|
leftShoulder: 18,
|
|
@@ -19,12 +21,15 @@ const k = {
|
|
|
19
21
|
rightBrow: 0,
|
|
20
22
|
browTilt: 0,
|
|
21
23
|
lookX: 0,
|
|
22
|
-
lookY: 0
|
|
24
|
+
lookY: 0,
|
|
25
|
+
stretch: 1,
|
|
26
|
+
turn: 0,
|
|
27
|
+
sit: 0
|
|
23
28
|
};
|
|
24
|
-
function
|
|
25
|
-
return { ...
|
|
29
|
+
function P(e) {
|
|
30
|
+
return { ...Y, ...e };
|
|
26
31
|
}
|
|
27
|
-
const
|
|
32
|
+
const le = {
|
|
28
33
|
mouth: 0,
|
|
29
34
|
smile: 0,
|
|
30
35
|
mouthWidth: 1,
|
|
@@ -35,177 +40,532 @@ const v = {
|
|
|
35
40
|
browTilt: 0,
|
|
36
41
|
lookX: 0,
|
|
37
42
|
lookY: 0
|
|
38
|
-
},
|
|
39
|
-
neutral:
|
|
40
|
-
happy:
|
|
41
|
-
joyful:
|
|
42
|
-
sad:
|
|
43
|
-
crying:
|
|
44
|
-
surprised:
|
|
45
|
-
shocked:
|
|
46
|
-
angry:
|
|
47
|
-
furious:
|
|
48
|
-
worried:
|
|
49
|
-
scared:
|
|
50
|
-
confused:
|
|
51
|
-
skeptical:
|
|
52
|
-
thinking:
|
|
53
|
-
sleepy:
|
|
54
|
-
disgusted:
|
|
55
|
-
smug:
|
|
56
|
-
wink:
|
|
43
|
+
}, p = (e) => ({ ...le, ...e }), H = {
|
|
44
|
+
neutral: le,
|
|
45
|
+
happy: p({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
|
|
46
|
+
joyful: p({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
|
|
47
|
+
sad: p({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
|
|
48
|
+
crying: p({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
|
|
49
|
+
surprised: p({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
|
|
50
|
+
shocked: p({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
|
|
51
|
+
angry: p({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
|
|
52
|
+
furious: p({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
|
|
53
|
+
worried: p({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
|
|
54
|
+
scared: p({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
|
|
55
|
+
confused: p({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
|
|
56
|
+
skeptical: p({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
|
|
57
|
+
thinking: p({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
|
|
58
|
+
sleepy: p({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
|
|
59
|
+
disgusted: p({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
|
|
60
|
+
smug: p({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
|
|
61
|
+
wink: p({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
|
|
57
62
|
};
|
|
58
|
-
function
|
|
59
|
-
return { ...
|
|
60
|
-
}
|
|
61
|
-
const
|
|
62
|
-
rest:
|
|
63
|
-
wave:
|
|
64
|
-
cheer:
|
|
65
|
-
shrug:
|
|
66
|
-
point:
|
|
63
|
+
function Ee(e, t) {
|
|
64
|
+
return { ...e, ...typeof t == "string" ? H[t] : t };
|
|
65
|
+
}
|
|
66
|
+
const pe = {
|
|
67
|
+
rest: Y,
|
|
68
|
+
wave: P({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...H.happy }),
|
|
69
|
+
cheer: P({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...H.joyful }),
|
|
70
|
+
shrug: P({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...H.confused, lookX: 0, lookY: 0 }),
|
|
71
|
+
point: P({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
|
|
67
72
|
// The forearm passes 180° to fold back in, so the hand reaches the chin.
|
|
68
|
-
think:
|
|
69
|
-
handsOnHips:
|
|
70
|
-
sad:
|
|
71
|
-
surprised:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
think: P({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...H.thinking }),
|
|
74
|
+
handsOnHips: P({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
|
|
75
|
+
sad: P({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...H.sad }),
|
|
76
|
+
surprised: P({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...H.surprised }),
|
|
77
|
+
// Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
|
|
78
|
+
crouch: P({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
|
|
79
|
+
// Seated, hands resting on the knees. Arm angles spread outward per side, so
|
|
80
|
+
// reaching forward (+x, the way the figure faces) is negative for the left arm.
|
|
81
|
+
sit: P({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
|
|
82
|
+
jump: P({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...H.joyful })
|
|
83
|
+
}, re = Object.keys(Y);
|
|
84
|
+
function Me(e, t, o) {
|
|
85
|
+
const l = { ...e };
|
|
86
|
+
for (const n of re) l[n] = e[n] + (t[n] - e[n]) * o;
|
|
76
87
|
return l;
|
|
77
88
|
}
|
|
78
|
-
const
|
|
79
|
-
function
|
|
80
|
-
const l = Math.sin(
|
|
89
|
+
const K = 24, Q = 4, Z = 28, Se = 40;
|
|
90
|
+
function Te(e, t = Y, o = 1) {
|
|
91
|
+
const l = Math.sin(e * Math.PI * 2) * o, n = Math.cos(e * Math.PI * 2) * o, s = (a) => a <= Se, h = (a) => s(a) ? 22 * l : a, i = s(t.leftShoulder) ? t.leftElbow - Z * Math.max(0, -l) : t.leftElbow, r = s(t.rightShoulder) ? t.rightElbow + Z * Math.max(0, l) : t.rightElbow;
|
|
81
92
|
return {
|
|
82
|
-
...
|
|
93
|
+
...t,
|
|
94
|
+
// Lean into the walk, and keep the head a little more level than the body.
|
|
95
|
+
lean: t.lean + Q * o,
|
|
96
|
+
headTilt: t.headTilt - Q * 0.5 * o,
|
|
97
|
+
leftElbow: i,
|
|
98
|
+
rightElbow: r,
|
|
83
99
|
// Left foot forward while swing > 0, right foot back; then the other way.
|
|
84
|
-
leftHip: -
|
|
85
|
-
rightHip: -
|
|
100
|
+
leftHip: -K * l,
|
|
101
|
+
rightHip: -K * l,
|
|
86
102
|
// The leg swinging forward lifts, its shin trailing backward (-x). A positive
|
|
87
103
|
// knee folds toward the centre, which is backward only for the right leg.
|
|
88
|
-
leftKnee: -30 * Math.max(0,
|
|
89
|
-
rightKnee: 30 * Math.max(0, -
|
|
104
|
+
leftKnee: -30 * Math.max(0, n),
|
|
105
|
+
rightKnee: 30 * Math.max(0, -n),
|
|
90
106
|
// Arms swing against the legs: left arm back while the left foot is forward.
|
|
91
|
-
leftShoulder:
|
|
92
|
-
rightShoulder:
|
|
107
|
+
leftShoulder: h(t.leftShoulder),
|
|
108
|
+
rightShoulder: h(t.rightShoulder)
|
|
93
109
|
};
|
|
94
110
|
}
|
|
95
|
-
function
|
|
96
|
-
return 4 * ((
|
|
111
|
+
function Qe(e, t = 1) {
|
|
112
|
+
return 4 * ((C + N) * e) * Math.sin(K * t * Math.PI / 180);
|
|
113
|
+
}
|
|
114
|
+
function ke(e) {
|
|
115
|
+
const t = Math.abs(Math.sin(e / 65)), o = 0.55 + 0.45 * Math.sin(e / 310);
|
|
116
|
+
return t * o;
|
|
97
117
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return e *
|
|
118
|
+
const se = 0.12, $ = 0.46, Pe = 1 - 2 * se, ve = 0.1, Be = 0.21, Ie = 0.19, C = 0.24, N = 0.22, ie = 0.12, We = 0.14, he = 0.33, V = 0.7, j = 0.3, He = 0.35, Re = [1.7, 1.05], Ye = [1.3, 0.75], ee = [1.45, 0.85], _e = [1.15, 0.75], te = 0.06, Ae = 0.65, Oe = 0.3, Le = 0.02, Fe = 0.012, Ne = 12, L = 90, xe = 0.25, Xe = 0.01, O = (e) => Math.min(1, Math.max(0, e ?? 0));
|
|
119
|
+
function Ze(e, t = 1) {
|
|
120
|
+
return N * e * t;
|
|
101
121
|
}
|
|
102
|
-
const
|
|
103
|
-
function
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
{ x: 0.34 * o, open:
|
|
122
|
+
const D = -0.12, ae = 0.4, W = (e) => e * Math.PI / 180, Ke = (e, t) => ({ x: t * Math.sin(W(e)), y: Math.cos(W(e)) }), fe = (e, t) => Math.max(0, e) * (1 - Math.min(1, Math.max(0, t))), ce = (e, t, o, l) => e - 0.3 * t - o * 0.14 * t - Math.max(0, l - 1) * 0.12 * t;
|
|
123
|
+
function Ce(e, t, o, l, n, s) {
|
|
124
|
+
const h = Math.max(1, Math.min(s * 0.6, We * o)), i = O(t.turn), r = (ie + he * i) * o, a = l + D * o, f = r + t.lookX * 0.08 * o, y = t.lookY * 0.07 * o, w = [
|
|
125
|
+
// The left eye is on the far side; turning closes it up more than the near one.
|
|
126
|
+
{ x: -0.34 * o * (1 - V * i), squeeze: 1 - V * i, open: t.leftEye, brow: t.leftBrow, side: -1 },
|
|
127
|
+
{ x: 0.34 * o * (1 - j * i), squeeze: 1 - j * i, open: t.rightEye, brow: t.rightBrow, side: 1 }
|
|
107
128
|
];
|
|
108
|
-
|
|
109
|
-
for (const
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
-
|
|
129
|
+
e.fillStyle = n, e.strokeStyle = n, e.lineWidth = h;
|
|
130
|
+
for (const u of w) {
|
|
131
|
+
const c = fe(u.open, t.blink);
|
|
132
|
+
if (c < 0.2) {
|
|
133
|
+
const B = t.smile > 0.5 ? -0.12 * o : 0.06 * o;
|
|
134
|
+
e.beginPath(), e.moveTo(u.x + r - 0.12 * o, a), e.quadraticCurveTo(u.x + r, a + B, u.x + r + 0.12 * o, a), e.stroke();
|
|
114
135
|
} else {
|
|
115
|
-
if (
|
|
116
|
-
const
|
|
117
|
-
|
|
136
|
+
if (c > 1.2) {
|
|
137
|
+
const _ = 0.13 * o * c;
|
|
138
|
+
e.beginPath(), e.ellipse(u.x + r, a, _ * 0.85, _, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = n;
|
|
118
139
|
}
|
|
119
|
-
const
|
|
120
|
-
|
|
140
|
+
const B = c > 1.2 ? 0.075 * o : 0.1 * o;
|
|
141
|
+
e.beginPath(), e.ellipse(u.x + f, a + y, B, B * 1.1 * Math.min(c, 1), 0, 0, Math.PI * 2), e.fill();
|
|
121
142
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
143
|
+
const g = ce(a, o, u.brow, c), v = u.x + r - u.side * 0.13 * o * u.squeeze, R = u.x + r + u.side * 0.13 * o * u.squeeze;
|
|
144
|
+
e.beginPath(), e.moveTo(R, g), e.lineTo(v, g - t.browTilt * 0.1 * o), e.stroke();
|
|
124
145
|
}
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
|
|
146
|
+
const d = l + ae * o, m = 0.25 * o * Math.max(0.3, t.mouthWidth) * (1 - He * i), b = Math.min(1, Math.max(0, t.mouth));
|
|
147
|
+
if (e.beginPath(), b <= 0.05) {
|
|
148
|
+
e.moveTo(r - m, d), e.quadraticCurveTo(r, d + t.smile * 0.25 * o, r + m, d), e.stroke();
|
|
128
149
|
return;
|
|
129
150
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
function
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
151
|
+
const E = 0.3 * o * b;
|
|
152
|
+
t.smile > 0.3 ? (e.moveTo(r - m, d - 0.05 * o), e.lineTo(r + m, d - 0.05 * o), e.quadraticCurveTo(r, d + E * 2, r - m, d - 0.05 * o)) : t.smile < -0.3 ? (e.moveTo(r - m, d + E * 0.6), e.lineTo(r + m, d + E * 0.6), e.quadraticCurveTo(r, d - E * 1.4, r - m, d + E * 0.6)) : e.ellipse(r, d, m * 0.8, E, 0, 0, Math.PI * 2), e.fill();
|
|
153
|
+
}
|
|
154
|
+
function U(e, t, o, l, n = 16) {
|
|
155
|
+
const s = { x: 2 * t.x - (e.x + o.x) / 2, y: 2 * t.y - (e.y + o.y) / 2 }, h = [];
|
|
156
|
+
for (let i = 0; i <= n; i++) {
|
|
157
|
+
const r = i / n, a = r < 0.5 ? { x: e.x + (t.x - e.x) * 2 * r, y: e.y + (t.y - e.y) * 2 * r } : { x: t.x + (o.x - t.x) * (2 * r - 1), y: t.y + (o.y - t.y) * (2 * r - 1) }, f = 1 - r, y = {
|
|
158
|
+
x: f * f * e.x + 2 * f * r * s.x + r * r * o.x,
|
|
159
|
+
y: f * f * e.y + 2 * f * r * s.y + r * r * o.y
|
|
160
|
+
};
|
|
161
|
+
h.push({ x: a.x + (y.x - a.x) * l, y: a.y + (y.y - a.y) * l });
|
|
162
|
+
}
|
|
163
|
+
return h;
|
|
164
|
+
}
|
|
165
|
+
function ye(e, t) {
|
|
166
|
+
const o = t.height ?? 300, l = Math.min(3, Math.max(0.3, e.stretch ?? 1)), n = Math.sqrt(l), s = (t.headSize ?? 2 * se) / 2, h = t.headSize === void 0 ? Pe : 1 - 2 * s, i = s * o, r = O(e.sit), a = e.leftHip + (-L - e.leftHip) * r, f = e.leftKnee + (-L - e.leftKnee) * r, y = e.rightHip + (L - e.rightHip) * r, w = e.rightKnee + (L - e.rightKnee) * r, d = t.classic === !0, m = (M, T) => {
|
|
167
|
+
const k = W(M - T) / 2;
|
|
168
|
+
return d ? { x: 0, y: 0 } : { x: Math.cos(k) * te, y: Math.abs(Math.sin(k)) * te };
|
|
143
169
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const f = E(0, i, r, d, Y);
|
|
149
|
-
y({ x: 0, y: i }, f, E(f.x, f.y, r - s, d, H));
|
|
170
|
+
let b = 0;
|
|
171
|
+
if (r > 0 || !d) {
|
|
172
|
+
const M = (S, I) => C * Math.cos(W(S)) + N * Math.cos(W(S - I)) + m(S, I).y, T = Math.max(M(a, f), M(y, w)), k = d ? Math.min(1, r / xe) : 1;
|
|
173
|
+
b = ($ - T) * k * o * l;
|
|
150
174
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
175
|
+
const E = -$ * o * l + b, u = -h * o * l + b, c = d ? 0 : (Le * O(e.turn) + Fe * r) * o * l, g = c === 0 ? [{ x: 0, y: E }, { x: 0, y: u }] : U({ x: 0, y: E }, { x: -c, y: (E + u) / 2 }, { x: 0, y: u }, 1, 8), v = u + ve * o * l, R = (t.shoulderWidth ?? 0) * o * Math.cos(O(e.turn) * Math.PI / 2), B = (M, T, k, S, I) => {
|
|
176
|
+
const z = Ke(k, S);
|
|
177
|
+
return { x: M + z.x * I * o, y: T + z.y * I * o };
|
|
178
|
+
}, _ = (M, T, k) => {
|
|
179
|
+
const S = B(0, E, T, M, C * l);
|
|
180
|
+
return { root: { x: 0, y: E }, joint: S, end: B(S.x, S.y, T - k, M, N * l) };
|
|
181
|
+
}, G = (M, T, k) => {
|
|
182
|
+
const S = { x: M * R, y: v }, I = B(S.x, S.y, T, M, Be * n);
|
|
183
|
+
return { root: S, joint: I, end: B(I.x, I.y, T + k, M, Ie * n) };
|
|
184
|
+
}, x = { left: _(-1, a, f), right: _(1, y, w) }, J = (M, T, k) => {
|
|
185
|
+
const S = m(T, k);
|
|
186
|
+
return { x: M.end.x + S.x * o * l, y: M.end.y + S.y * o * l };
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
height: o,
|
|
190
|
+
facing: (t.facing ?? 1) < 0 ? -1 : 1,
|
|
191
|
+
stretch: l,
|
|
192
|
+
lineWidth: t.lineWidth ?? o * 0.025,
|
|
193
|
+
rubber: Math.min(1, Math.max(d ? 0 : Oe, t.rubber ?? 0)),
|
|
194
|
+
r: i,
|
|
195
|
+
// The head keeps its area: taller and narrower when stretched.
|
|
196
|
+
headRx: i / Math.sqrt(l),
|
|
197
|
+
headRy: i * Math.sqrt(l),
|
|
198
|
+
hipY: E,
|
|
199
|
+
neckY: u,
|
|
200
|
+
drop: b,
|
|
201
|
+
lean: d ? e.lean : e.lean + Ne * Math.sin(Math.PI * r),
|
|
202
|
+
classic: d,
|
|
203
|
+
legs: x,
|
|
204
|
+
toes: { left: J(x.left, a, f), right: J(x.right, y, w) },
|
|
205
|
+
spine: g,
|
|
206
|
+
arms: {
|
|
207
|
+
left: G(-1, e.leftShoulder, e.leftElbow),
|
|
208
|
+
right: G(1, e.rightShoulder, e.rightElbow)
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
const A = (e, t) => t === 0 ? [e.root, e.joint, e.end] : U(e.root, e.joint, e.end, t);
|
|
213
|
+
function q(e, t, o) {
|
|
214
|
+
const l = Math.cos(o), n = Math.sin(o), s = e.x - t.x, h = e.y - t.y;
|
|
215
|
+
return { x: t.x + s * l - h * n, y: t.y + s * n + h * l };
|
|
216
|
+
}
|
|
217
|
+
function de(e, t) {
|
|
218
|
+
const o = W(e.lean), l = W(t.headTilt), n = { x: 0, y: e.hipY }, s = (u) => ({ x: e.facing * u.x, y: u.y }), h = (u) => s(q(u, n, o)), i = (u) => h(q({ x: u.x, y: u.y + e.neckY }, { x: 0, y: e.neckY }, l)), r = A(e.arms.left, e.rubber).map(h), a = A(e.arms.right, e.rubber).map(h), f = (u) => {
|
|
219
|
+
const [c, g] = u.slice(-2);
|
|
220
|
+
return Math.atan2(g.y - c.y, g.x - c.x);
|
|
221
|
+
};
|
|
222
|
+
let y = 1 / 0;
|
|
223
|
+
for (const [u, c] of [
|
|
224
|
+
[t.leftBrow, t.leftEye],
|
|
225
|
+
[t.rightBrow, t.rightEye]
|
|
156
226
|
]) {
|
|
157
|
-
const
|
|
158
|
-
y
|
|
227
|
+
const g = ce(D, 1, u, fe(c, t.blink));
|
|
228
|
+
y = Math.min(y, g, g - t.browTilt * 0.1);
|
|
159
229
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
230
|
+
const w = { left: s(e.legs.left.end), right: s(e.legs.right.end) }, d = { left: s(e.toes.left), right: s(e.toes.right) }, m = { left: Math.max(w.left.y, d.left.y), right: Math.max(w.right.y, d.right.y) }, b = Math.max(m.left, m.right), E = Xe * e.height;
|
|
231
|
+
return {
|
|
232
|
+
facing: e.facing,
|
|
233
|
+
height: e.height,
|
|
234
|
+
stretch: e.stretch,
|
|
235
|
+
lineWidth: e.lineWidth,
|
|
236
|
+
hip: n,
|
|
237
|
+
neck: h({ x: 0, y: e.neckY }),
|
|
238
|
+
shoulders: { left: h(e.arms.left.root), right: h(e.arms.right.root) },
|
|
239
|
+
elbows: { left: h(e.arms.left.joint), right: h(e.arms.right.joint) },
|
|
240
|
+
hands: { left: h(e.arms.left.end), right: h(e.arms.right.end) },
|
|
241
|
+
knees: { left: s(e.legs.left.joint), right: s(e.legs.right.joint) },
|
|
242
|
+
feet: w,
|
|
243
|
+
toes: d,
|
|
244
|
+
feetY: b,
|
|
245
|
+
grounded: { left: m.left >= b - E, right: m.right >= b - E },
|
|
246
|
+
handAngle: { left: f(r), right: f(a) },
|
|
247
|
+
limbs: {
|
|
248
|
+
leftArm: r,
|
|
249
|
+
rightArm: a,
|
|
250
|
+
leftLeg: A(e.legs.left, e.rubber).map(s),
|
|
251
|
+
rightLeg: A(e.legs.right, e.rubber).map(s),
|
|
252
|
+
spine: e.spine.map(h)
|
|
253
|
+
},
|
|
254
|
+
head: {
|
|
255
|
+
center: i({ x: 0, y: -e.headRy }),
|
|
256
|
+
rx: e.headRx,
|
|
257
|
+
ry: e.headRy,
|
|
258
|
+
// Mirroring a turn reverses it.
|
|
259
|
+
angle: e.facing * (o + l),
|
|
260
|
+
eyeY: D,
|
|
261
|
+
browTopY: y,
|
|
262
|
+
mouthY: ae,
|
|
263
|
+
faceX: e.facing * (ie + he * O(t.turn))
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function De(e, t = {}) {
|
|
268
|
+
return de(ye(e, t), e);
|
|
269
|
+
}
|
|
270
|
+
function $e(e, t, o) {
|
|
271
|
+
return q({ x: e.center.x + t * e.rx, y: e.center.y + o * e.ry }, e.center, e.angle);
|
|
272
|
+
}
|
|
273
|
+
function qe(e, t, o) {
|
|
274
|
+
const l = (s) => ({ x: s.x + t, y: s.y + o }), n = (s) => ({ left: l(s.left), right: l(s.right) });
|
|
275
|
+
return {
|
|
276
|
+
...e,
|
|
277
|
+
hip: l(e.hip),
|
|
278
|
+
neck: l(e.neck),
|
|
279
|
+
shoulders: n(e.shoulders),
|
|
280
|
+
elbows: n(e.elbows),
|
|
281
|
+
hands: n(e.hands),
|
|
282
|
+
knees: n(e.knees),
|
|
283
|
+
feet: n(e.feet),
|
|
284
|
+
toes: n(e.toes),
|
|
285
|
+
feetY: e.feetY + o,
|
|
286
|
+
grounded: { ...e.grounded },
|
|
287
|
+
handAngle: { ...e.handAngle },
|
|
288
|
+
limbs: {
|
|
289
|
+
leftArm: e.limbs.leftArm.map(l),
|
|
290
|
+
rightArm: e.limbs.rightArm.map(l),
|
|
291
|
+
leftLeg: e.limbs.leftLeg.map(l),
|
|
292
|
+
rightLeg: e.limbs.rightLeg.map(l),
|
|
293
|
+
spine: e.limbs.spine.map(l)
|
|
294
|
+
},
|
|
295
|
+
head: { ...e.head, center: l(e.head.center) }
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function Ue(e, t, o, l) {
|
|
299
|
+
const n = t.length;
|
|
300
|
+
if (n < 2) return;
|
|
301
|
+
const s = [], h = [], i = (r) => o + (l - o) * r / (n - 1);
|
|
302
|
+
t.forEach((r, a) => {
|
|
303
|
+
const f = t[Math.max(0, a - 1)], y = t[Math.min(n - 1, a + 1)], w = Math.hypot(y.x - f.x, y.y - f.y) || 1, d = i(a) / 2, m = -(y.y - f.y) / w * d, b = (y.x - f.x) / w * d;
|
|
304
|
+
s.push({ x: r.x + m, y: r.y + b }), h.push({ x: r.x - m, y: r.y - b });
|
|
305
|
+
}), e.beginPath(), e.moveTo(s[0].x, s[0].y);
|
|
306
|
+
for (const r of s.slice(1)) e.lineTo(r.x, r.y);
|
|
307
|
+
for (const r of h.reverse()) e.lineTo(r.x, r.y);
|
|
308
|
+
e.closePath(), e.fill(), t.forEach((r, a) => {
|
|
309
|
+
a !== 0 && a !== n - 1 && n > 3 || (e.beginPath(), e.arc(r.x, r.y, i(a) / 2, 0, Math.PI * 2), e.fill());
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function Ge(e, t, o = {}, l = 0) {
|
|
313
|
+
const n = ye(t, o), s = o.color ?? "#1e293b", h = o.layers ?? {}, i = o.layers ? de(n, t) : void 0, r = o.sketch ? X(e, o.sketch, l) : void 0, a = o.sketch && o.layers ? X(e, o.sketch, l) : void 0, f = (c) => {
|
|
314
|
+
e.save(), c(), e.restore();
|
|
315
|
+
}, y = (c) => {
|
|
316
|
+
c && i && f(() => c(e, i, l, a));
|
|
317
|
+
}, w = () => e.scale(n.facing, 1), d = () => {
|
|
318
|
+
w(), e.translate(0, n.hipY), e.rotate(W(n.lean)), e.translate(0, -n.hipY);
|
|
319
|
+
}, m = (c, g, v) => {
|
|
320
|
+
if (r) return g ? r.curve(c) : r.line(c);
|
|
321
|
+
if (n.classic) {
|
|
322
|
+
e.beginPath(), e.moveTo(c[0].x, c[0].y);
|
|
323
|
+
for (const R of c.slice(1)) e.lineTo(R.x, R.y);
|
|
324
|
+
e.stroke();
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
Ue(e, c, v[0] * n.lineWidth, v[1] * n.lineWidth);
|
|
328
|
+
}, b = (c, g) => m(A(c, n.rubber), n.rubber > 0, g), E = (c) => {
|
|
329
|
+
n.classic || m([n.legs[c].end, n.toes[c]], !1, _e);
|
|
330
|
+
}, u = (c) => {
|
|
331
|
+
if (n.classic || r) return;
|
|
332
|
+
const g = n.arms[c].end;
|
|
333
|
+
e.beginPath(), e.arc(g.x, g.y, Ae * n.lineWidth, 0, Math.PI * 2), e.fill();
|
|
334
|
+
};
|
|
335
|
+
e.save(), e.strokeStyle = s, e.fillStyle = s, e.lineWidth = n.lineWidth, e.lineCap = "round", e.lineJoin = "round", y(h.behind), f(() => {
|
|
336
|
+
w(), b(n.legs.left, ee), E("left"), b(n.legs.right, ee), E("right");
|
|
337
|
+
}), f(() => {
|
|
338
|
+
d(), m(n.spine, n.spine.length > 2, Re);
|
|
339
|
+
const { left: c, right: g } = { left: n.arms.left.root, right: n.arms.right.root };
|
|
340
|
+
if (c.x !== g.x)
|
|
341
|
+
if (n.classic) m([c, g], !1, [1, 1]);
|
|
342
|
+
else {
|
|
343
|
+
const v = { x: (c.x + g.x) / 2, y: c.y - 0.3 * Math.abs(g.x - c.x) };
|
|
344
|
+
m(U(c, v, g, 1, 8), !0, [1.1, 1.1]);
|
|
345
|
+
}
|
|
346
|
+
}), y(h.body);
|
|
347
|
+
for (const c of ["left", "right"]) {
|
|
348
|
+
f(() => {
|
|
349
|
+
d(), b(n.arms[c], Ye), u(c);
|
|
350
|
+
});
|
|
351
|
+
const g = h.sleeve;
|
|
352
|
+
g && i && f(() => g(e, i, c, l, a));
|
|
353
|
+
}
|
|
354
|
+
y(h.behindHead), f(() => {
|
|
355
|
+
d(), e.translate(0, n.neckY), e.rotate(W(t.headTilt));
|
|
356
|
+
const c = -n.headRy;
|
|
357
|
+
e.beginPath(), e.ellipse(0, c, n.headRx, n.headRy, 0, 0, Math.PI * 2);
|
|
358
|
+
const g = o.headFill ?? "#ffffff";
|
|
359
|
+
if (g !== "none" && (e.fillStyle = g, e.fill()), r) {
|
|
360
|
+
r.ellipse(0, c, n.headRx, n.headRy);
|
|
361
|
+
const v = r.nudge();
|
|
362
|
+
e.translate(v.x, v.y);
|
|
363
|
+
} else
|
|
364
|
+
e.stroke();
|
|
365
|
+
e.translate(0, c), e.scale(n.headRx / n.r, n.headRy / n.r), Ce(e, t, n.r, 0, s, n.lineWidth);
|
|
366
|
+
}), y(h.overHead), y(h.front), e.restore(), o.label && (e.save(), e.fillStyle = s, e.font = o.labelFont ?? `700 ${Math.round(n.height * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(o.label, 0, -n.height * n.stretch - 0.04 * n.height + n.drop), e.restore());
|
|
367
|
+
}
|
|
368
|
+
function ue(e, t) {
|
|
369
|
+
const o = { ...e };
|
|
370
|
+
let l = e.walking > 0 ? Me(o, Te(e.walk, o), e.walking) : o;
|
|
371
|
+
return e.talk > 0 && (l = { ...l, mouth: Math.max(l.mouth, e.talk * ke(t)) }), l;
|
|
372
|
+
}
|
|
373
|
+
function Ve(e) {
|
|
374
|
+
const t = e.style ?? {}, o = t.height ?? 300, l = o * 0.8, n = { ...P(e.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: t.rubber ?? 0 };
|
|
168
375
|
return {
|
|
169
376
|
type: "custom",
|
|
170
|
-
x:
|
|
171
|
-
y:
|
|
377
|
+
x: e.x - l / 2,
|
|
378
|
+
y: e.y - o,
|
|
172
379
|
width: l,
|
|
173
380
|
height: o,
|
|
174
|
-
props: { ...
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
381
|
+
props: { ...n },
|
|
382
|
+
figureStyle: t,
|
|
383
|
+
draw(s, h, i) {
|
|
384
|
+
const r = h.props;
|
|
385
|
+
s.translate(l / 2, o), Ge(s, ue(r, i), { ...t, rubber: r.rubber }, i);
|
|
179
386
|
}
|
|
180
387
|
};
|
|
181
388
|
}
|
|
182
|
-
function
|
|
389
|
+
function je(e, t, o) {
|
|
390
|
+
const l = e.figureStyle;
|
|
391
|
+
if (!l) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
|
|
392
|
+
const n = { ...e.props };
|
|
393
|
+
let s = 0, h = 0;
|
|
394
|
+
for (const [a, f] of t.state?.values.get(o) ?? [])
|
|
395
|
+
typeof f == "number" && (a === "x" || a === "motionPathX" ? s = f : a === "y" || a === "motionPathY" ? h = f : a in n && (n[a] = f));
|
|
396
|
+
const i = ue(n, t.time), r = De(i, { ...l, rubber: n.rubber });
|
|
397
|
+
return { pose: i, joints: qe(r, e.x + s + e.width / 2, e.y + h + e.height) };
|
|
398
|
+
}
|
|
399
|
+
function et(e, t) {
|
|
183
400
|
const o = [];
|
|
184
|
-
return
|
|
185
|
-
const
|
|
186
|
-
o.push(l.expression ?
|
|
187
|
-
}),
|
|
188
|
-
id: `${
|
|
189
|
-
target:
|
|
401
|
+
return t.forEach((l, n) => {
|
|
402
|
+
const s = n === 0 ? Y : o[n - 1], h = typeof l.pose == "string" ? pe[l.pose] : { ...s, ...l.pose };
|
|
403
|
+
o.push(l.expression ? Ee(h, l.expression) : h);
|
|
404
|
+
}), re.filter((l) => o.some((n) => n[l] !== Y[l])).map((l) => ({
|
|
405
|
+
id: `${e}-${l}`,
|
|
406
|
+
target: e,
|
|
190
407
|
property: l,
|
|
191
|
-
keyframes:
|
|
192
|
-
time:
|
|
193
|
-
value: o[
|
|
194
|
-
...
|
|
408
|
+
keyframes: t.map((n, s) => ({
|
|
409
|
+
time: n.time,
|
|
410
|
+
value: o[s][l],
|
|
411
|
+
...n.easing ? { easing: n.easing } : {}
|
|
195
412
|
}))
|
|
196
413
|
}));
|
|
197
414
|
}
|
|
415
|
+
function Je(e, t, o = {}, l) {
|
|
416
|
+
const n = o.length ?? 240, s = 9, h = 28, i = n - 22;
|
|
417
|
+
e.save(), e.translate(t.x, t.y), e.rotate((o.angle ?? -30) * Math.PI / 180), e.fillStyle = o.color ?? "#f4c542", e.fillRect(h, -s, i - h, 2 * s), e.fillStyle = "#e8b4a0", e.fillRect(i, -s, n - i, 2 * s), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(h, -s), e.lineTo(h, s), e.closePath(), e.fill(), e.fillStyle = o.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(h * 0.35, -s * 0.35), e.lineTo(h * 0.35, s * 0.35), e.closePath(), e.fill(), e.strokeStyle = o.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
|
|
418
|
+
const r = [
|
|
419
|
+
[{ x: 0, y: 0 }, { x: h, y: -s }, { x: n, y: -s }, { x: n, y: s }, { x: h, y: s }, { x: 0, y: 0 }],
|
|
420
|
+
[{ x: h, y: -s }, { x: h, y: s }],
|
|
421
|
+
[{ x: i, y: -s }, { x: i, y: s }]
|
|
422
|
+
];
|
|
423
|
+
for (const a of r) we(e, a, l);
|
|
424
|
+
e.restore();
|
|
425
|
+
}
|
|
426
|
+
function me(e, t, o = {}, l) {
|
|
427
|
+
const n = o.length ?? 90, s = o.thickness ?? 34;
|
|
428
|
+
e.save(), e.translate(t.x, t.y), e.rotate((o.angle ?? -35) * Math.PI / 180);
|
|
429
|
+
const h = -s / 2;
|
|
430
|
+
e.fillStyle = o.color ?? "#f4a7b9", e.fillRect(0, h, n, s), e.fillStyle = "#e9edf2", e.fillRect(n * 0.45, h, n * 0.55, s), e.strokeStyle = o.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
|
|
431
|
+
const i = [
|
|
432
|
+
{ x: 0, y: h },
|
|
433
|
+
{ x: n, y: h },
|
|
434
|
+
{ x: n, y: -h },
|
|
435
|
+
{ x: 0, y: -h },
|
|
436
|
+
{ x: 0, y: h }
|
|
437
|
+
], r = [{ x: n * 0.45, y: h }, { x: n * 0.45, y: -h }];
|
|
438
|
+
if (l)
|
|
439
|
+
l.line(i), l.line(r);
|
|
440
|
+
else
|
|
441
|
+
for (const a of [i, r]) {
|
|
442
|
+
e.beginPath(), e.moveTo(a[0].x, a[0].y);
|
|
443
|
+
for (const f of a.slice(1)) e.lineTo(f.x, f.y);
|
|
444
|
+
e.stroke();
|
|
445
|
+
}
|
|
446
|
+
e.restore();
|
|
447
|
+
}
|
|
448
|
+
function ge(e, t, o = {}, l) {
|
|
449
|
+
const n = o.tool ?? "pencil", s = o.skin ?? "#f1c9a5", h = o.outline ?? "#2f2f33", i = n === "eraser" ? 17 : 9, r = n === "eraser" ? -40 : 0, a = l ? l.nudge(0.6) : { x: 0, y: 0 };
|
|
450
|
+
e.save(), e.translate(t.x + a.x, t.y + a.y), e.rotate((o.angle ?? -30) * Math.PI / 180), e.scale(o.scale ?? 1, o.scale ?? 1), e.lineCap = "round", e.lineJoin = "round";
|
|
451
|
+
const f = (d, m, b, E) => {
|
|
452
|
+
for (const [u, c] of [
|
|
453
|
+
[h, b + 6],
|
|
454
|
+
[E, b]
|
|
455
|
+
])
|
|
456
|
+
e.strokeStyle = u, e.lineWidth = c, e.beginPath(), e.moveTo(d.x, d.y), e.lineTo(m.x, m.y), e.stroke();
|
|
457
|
+
};
|
|
458
|
+
e.save(), e.translate(r, 0);
|
|
459
|
+
const y = { x: 165, y: -i - 26 }, w = (d) => ({ x: y.x + d * 0.8, y: y.y + d * 0.6 });
|
|
460
|
+
f(y, w(2e3), 64, s), f(w(110), w(2e3), 92, o.sleeve ?? "#5b7db1"), e.fillStyle = s, e.strokeStyle = h, e.lineWidth = 3, e.beginPath(), e.ellipse(y.x, y.y, 54, 40, 0.25, 0, Math.PI * 2), e.fill(), e.stroke(), e.restore(), n === "eraser" ? me(e, { x: 0, y: 0 }, { angle: 0, outline: h }, l) : Je(e, { x: 0, y: 0 }, { angle: 0, outline: h }, l), e.translate(r, 0), f({ x: 150, y: i + 8 }, { x: 92, y: i + 12 }, 22, s), f({ x: 140, y: -i - 18 }, { x: 58, y: -i - 6 }, 20, s), f({ x: 150, y: -i - 30 }, { x: 112, y: -i + 2 }, 20, s), f({ x: 172, y: -i - 30 }, { x: 140, y: -i + 4 }, 20, s), e.restore();
|
|
461
|
+
}
|
|
462
|
+
function tt(e, t, o, l = 0.08, n = 32) {
|
|
463
|
+
const s = Math.PI * 2 * (1 + l), h = [];
|
|
464
|
+
for (let i = 0; i <= n; i++) {
|
|
465
|
+
const r = -Math.PI / 2 + s * i / n;
|
|
466
|
+
h.push({ x: e + Math.cos(r) * o, y: t + Math.sin(r) * o });
|
|
467
|
+
}
|
|
468
|
+
return h;
|
|
469
|
+
}
|
|
470
|
+
function ot(e) {
|
|
471
|
+
const { path: t } = e, o = t.map((i) => i.x), l = t.map((i) => i.y), n = Math.min(...o), s = Math.min(...l), h = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
|
|
472
|
+
return {
|
|
473
|
+
type: "custom",
|
|
474
|
+
x: n,
|
|
475
|
+
y: s,
|
|
476
|
+
width: Math.max(1, Math.max(...o) - n),
|
|
477
|
+
height: Math.max(1, Math.max(...l) - s),
|
|
478
|
+
props: { draw: 0 },
|
|
479
|
+
draw(i, r, a) {
|
|
480
|
+
const f = Math.min(1, Math.max(0, Number(r.props?.draw ?? 0)));
|
|
481
|
+
i.translate(-n, -s), i.strokeStyle = e.color ?? "#2f2f33", i.lineWidth = e.lineWidth ?? 5, i.lineCap = "round", i.lineJoin = "round";
|
|
482
|
+
const y = e.sketch ? X(i, e.sketch, a) : void 0;
|
|
483
|
+
f > 0 && (y ? e.smooth ? y.curve(t, f) : y.line(t, f) : we(i, oe(t, f))), h && f > 0 && f < 1 && ge(i, ne(t, f), h, y);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function we(e, t, o) {
|
|
488
|
+
if (!(t.length < 2)) {
|
|
489
|
+
if (o) return o.line(t);
|
|
490
|
+
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
491
|
+
for (const l of t.slice(1)) e.lineTo(l.x, l.y);
|
|
492
|
+
e.stroke();
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
const F = 1e5;
|
|
496
|
+
function nt(e, t, o, l, n = 6) {
|
|
497
|
+
const s = [], h = Math.max(1, Math.round(n));
|
|
498
|
+
for (let i = 0; i <= h; i++)
|
|
499
|
+
s.push({ x: i % 2 === 0 ? e : e + o, y: t + l * i / h });
|
|
500
|
+
return s;
|
|
501
|
+
}
|
|
502
|
+
function be(e, t, o, l) {
|
|
503
|
+
if (l <= 0 || t.length === 0) return;
|
|
504
|
+
const n = oe(t, l), s = o / 2, h = (i) => {
|
|
505
|
+
e.beginPath(), e.rect(-F, -F, 2 * F, 2 * F), i(), e.clip("evenodd");
|
|
506
|
+
};
|
|
507
|
+
for (const i of n)
|
|
508
|
+
h(() => {
|
|
509
|
+
e.moveTo(i.x + s, i.y), e.arc(i.x, i.y, s, 0, Math.PI * 2);
|
|
510
|
+
});
|
|
511
|
+
for (let i = 1; i < n.length; i++) {
|
|
512
|
+
const r = n[i - 1], a = n[i], f = Math.hypot(a.x - r.x, a.y - r.y);
|
|
513
|
+
if (f === 0) continue;
|
|
514
|
+
const y = -(a.y - r.y) / f * s, w = (a.x - r.x) / f * s;
|
|
515
|
+
h(() => {
|
|
516
|
+
e.moveTo(r.x + y, r.y + w), e.lineTo(a.x + y, a.y + w), e.lineTo(a.x - y, a.y - w), e.lineTo(r.x - y, r.y - w), e.closePath();
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function lt(e, t, o, l, n) {
|
|
521
|
+
e.save(), be(e, t, o, l), n(), e.restore();
|
|
522
|
+
}
|
|
523
|
+
function rt(e, t) {
|
|
524
|
+
const o = t.width ?? 40, l = t.hand === !0 ? {} : t.hand || void 0, n = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
|
|
525
|
+
return {
|
|
526
|
+
...e,
|
|
527
|
+
props: { ...e.props, erase: 0 },
|
|
528
|
+
draw(s, h, i) {
|
|
529
|
+
const r = Number(h.props?.erase ?? 0);
|
|
530
|
+
if (s.save(), be(s, t.path, o, r), e.draw(s, h, i), s.restore(), !n || r <= 0 || r >= 1) return;
|
|
531
|
+
const a = ne(t.path, r);
|
|
532
|
+
l ? ge(s, a, { ...l, tool: "eraser" }) : me(s, a, n);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
}
|
|
198
536
|
export {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
537
|
+
H as EXPRESSIONS,
|
|
538
|
+
pe as POSES,
|
|
539
|
+
Y as REST_POSE,
|
|
540
|
+
Me as blendPose,
|
|
541
|
+
ht as boilFrame,
|
|
542
|
+
tt as circlePath,
|
|
543
|
+
be as clipErased,
|
|
544
|
+
me as drawEraser,
|
|
545
|
+
ge as drawHand,
|
|
546
|
+
Je as drawPencil,
|
|
547
|
+
Ge as drawStickFigure,
|
|
548
|
+
ot as drawnPathTarget,
|
|
549
|
+
rt as erasable,
|
|
550
|
+
$e as headPoint,
|
|
551
|
+
qe as jointsToScene,
|
|
552
|
+
oe as partialPath,
|
|
553
|
+
at as pathLength,
|
|
554
|
+
ne as pointAlong,
|
|
555
|
+
P as pose,
|
|
556
|
+
et as poseTracks,
|
|
557
|
+
ue as resolveStickPose,
|
|
558
|
+
U as rubberLimb,
|
|
559
|
+
nt as scrubPath,
|
|
560
|
+
Ze as seatHeight,
|
|
561
|
+
X as sketchPen,
|
|
562
|
+
je as stickFigureAt,
|
|
563
|
+
De as stickFigureJoints,
|
|
564
|
+
Ve as stickFigureTarget,
|
|
565
|
+
Qe as strideLength,
|
|
566
|
+
ke as talkingMouth,
|
|
567
|
+
Ue as taperedLine,
|
|
568
|
+
Te as walkPose,
|
|
569
|
+
lt as withErased,
|
|
570
|
+
Ee as withExpression
|
|
211
571
|
};
|