@algorisys/tinyfly 0.74.0 → 0.75.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 +9 -6
- package/lib/addons/adapters.js +236 -121
- package/lib/addons/characters.js +323 -144
- 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 +3117 -2819
- 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 +300 -1
- 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 +42 -5
- package/package.json +1 -1
package/lib/addons/characters.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { s as A, p as O, a as C } from "./sketch-CB6VNfnR.js";
|
|
2
|
+
import { b as be, c as pe } from "./sketch-CB6VNfnR.js";
|
|
3
|
+
const B = {
|
|
2
4
|
lean: 0,
|
|
3
5
|
headTilt: 0,
|
|
4
6
|
leftShoulder: 18,
|
|
@@ -19,12 +21,13 @@ const k = {
|
|
|
19
21
|
rightBrow: 0,
|
|
20
22
|
browTilt: 0,
|
|
21
23
|
lookX: 0,
|
|
22
|
-
lookY: 0
|
|
24
|
+
lookY: 0,
|
|
25
|
+
stretch: 1
|
|
23
26
|
};
|
|
24
|
-
function
|
|
25
|
-
return { ...
|
|
27
|
+
function k(e) {
|
|
28
|
+
return { ...B, ...e };
|
|
26
29
|
}
|
|
27
|
-
const
|
|
30
|
+
const F = {
|
|
28
31
|
mouth: 0,
|
|
29
32
|
smile: 0,
|
|
30
33
|
mouthWidth: 1,
|
|
@@ -35,170 +38,346 @@ const W = {
|
|
|
35
38
|
browTilt: 0,
|
|
36
39
|
lookX: 0,
|
|
37
40
|
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:
|
|
41
|
+
}, m = (e) => ({ ...F, ...e }), T = {
|
|
42
|
+
neutral: F,
|
|
43
|
+
happy: m({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
|
|
44
|
+
joyful: m({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
|
|
45
|
+
sad: m({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
|
|
46
|
+
crying: m({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
|
|
47
|
+
surprised: m({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
|
|
48
|
+
shocked: m({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
|
|
49
|
+
angry: m({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
|
|
50
|
+
furious: m({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
|
|
51
|
+
worried: m({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
|
|
52
|
+
scared: m({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
|
|
53
|
+
confused: m({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
|
|
54
|
+
skeptical: m({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
|
|
55
|
+
thinking: m({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
|
|
56
|
+
sleepy: m({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
|
|
57
|
+
disgusted: m({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
|
|
58
|
+
smug: m({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
|
|
59
|
+
wink: m({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
|
|
57
60
|
};
|
|
58
|
-
function
|
|
59
|
-
return { ...
|
|
60
|
-
}
|
|
61
|
-
const
|
|
62
|
-
rest:
|
|
63
|
-
wave:
|
|
64
|
-
cheer:
|
|
65
|
-
shrug:
|
|
66
|
-
point:
|
|
61
|
+
function D(e, t) {
|
|
62
|
+
return { ...e, ...typeof t == "string" ? T[t] : t };
|
|
63
|
+
}
|
|
64
|
+
const U = {
|
|
65
|
+
rest: B,
|
|
66
|
+
wave: k({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...T.happy }),
|
|
67
|
+
cheer: k({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...T.joyful }),
|
|
68
|
+
shrug: k({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...T.confused, lookX: 0, lookY: 0 }),
|
|
69
|
+
point: k({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
|
|
67
70
|
// 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
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
think: k({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...T.thinking }),
|
|
72
|
+
handsOnHips: k({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
|
|
73
|
+
sad: k({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...T.sad }),
|
|
74
|
+
surprised: k({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...T.surprised }),
|
|
75
|
+
// Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
|
|
76
|
+
crouch: k({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
|
|
77
|
+
jump: k({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...T.joyful })
|
|
78
|
+
}, _ = Object.keys(B);
|
|
79
|
+
function $(e, t, o) {
|
|
80
|
+
const r = { ...e };
|
|
81
|
+
for (const n of _) r[n] = e[n] + (t[n] - e[n]) * o;
|
|
82
|
+
return r;
|
|
83
|
+
}
|
|
84
|
+
const X = 24, V = 40;
|
|
85
|
+
function z(e, t = B, o = 1) {
|
|
86
|
+
const r = Math.sin(e * Math.PI * 2) * o, n = Math.cos(e * Math.PI * 2) * o, i = (h) => h <= V ? 22 * r : h;
|
|
80
87
|
return {
|
|
81
|
-
...
|
|
82
|
-
//
|
|
83
|
-
leftHip:
|
|
84
|
-
rightHip:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
...t,
|
|
89
|
+
// Left foot forward while swing > 0, right foot back; then the other way.
|
|
90
|
+
leftHip: -X * r,
|
|
91
|
+
rightHip: -X * r,
|
|
92
|
+
// The leg swinging forward lifts, its shin trailing backward (-x). A positive
|
|
93
|
+
// knee folds toward the centre, which is backward only for the right leg.
|
|
94
|
+
leftKnee: -30 * Math.max(0, n),
|
|
95
|
+
rightKnee: 30 * Math.max(0, -n),
|
|
96
|
+
// Arms swing against the legs: left arm back while the left foot is forward.
|
|
97
|
+
leftShoulder: i(t.leftShoulder),
|
|
98
|
+
rightShoulder: i(t.rightShoulder)
|
|
90
99
|
};
|
|
91
100
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
function se(e, t = 1) {
|
|
102
|
+
return 4 * ((K + L) * e) * Math.sin(X * t * Math.PI / 180);
|
|
103
|
+
}
|
|
104
|
+
function Q(e) {
|
|
105
|
+
const t = Math.abs(Math.sin(e / 65)), o = 0.55 + 0.45 * Math.sin(e / 310);
|
|
106
|
+
return t * o;
|
|
95
107
|
}
|
|
96
|
-
const
|
|
97
|
-
function
|
|
98
|
-
const
|
|
99
|
-
{ x: -0.34 *
|
|
100
|
-
{ x: 0.34 *
|
|
108
|
+
const Z = 0.12, j = 0.1, x = 0.21, ee = 0.19, K = 0.24, L = 0.22, Y = (e) => e * Math.PI / 180, oe = (e, t) => ({ x: t * Math.sin(Y(e)), y: Math.cos(Y(e)) });
|
|
109
|
+
function te(e, t, o, r, n, i) {
|
|
110
|
+
const h = Math.max(1, i * 0.6), l = 0.12 * o, s = r - 0.12 * o, a = l + t.lookX * 0.08 * o, f = t.lookY * 0.07 * o, y = [
|
|
111
|
+
{ x: -0.34 * o, open: t.leftEye, brow: t.leftBrow, side: -1 },
|
|
112
|
+
{ x: 0.34 * o, open: t.rightEye, brow: t.rightBrow, side: 1 }
|
|
101
113
|
];
|
|
102
|
-
|
|
103
|
-
for (const
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
|
|
114
|
+
e.fillStyle = n, e.strokeStyle = n, e.lineWidth = h;
|
|
115
|
+
for (const b of y) {
|
|
116
|
+
const E = Math.max(0, b.open) * (1 - Math.min(1, Math.max(0, t.blink)));
|
|
117
|
+
if (E < 0.2) {
|
|
118
|
+
const d = t.smile > 0.5 ? -0.12 * o : 0.06 * o;
|
|
119
|
+
e.beginPath(), e.moveTo(b.x + l - 0.12 * o, s), e.quadraticCurveTo(b.x + l, s + d, b.x + l + 0.12 * o, s), e.stroke();
|
|
108
120
|
} else {
|
|
109
|
-
if (
|
|
110
|
-
const
|
|
111
|
-
|
|
121
|
+
if (E > 1.2) {
|
|
122
|
+
const p = 0.13 * o * E;
|
|
123
|
+
e.beginPath(), e.ellipse(b.x + l, s, p * 0.85, p, 0, 0, Math.PI * 2), e.fillStyle = "#ffffff", e.fill(), e.stroke(), e.fillStyle = n;
|
|
112
124
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
125
|
+
const d = E > 1.2 ? 0.075 * o : 0.1 * o;
|
|
126
|
+
e.beginPath(), e.ellipse(b.x + a, s + f, d, d * 1.1 * Math.min(E, 1), 0, 0, Math.PI * 2), e.fill();
|
|
115
127
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
128
|
+
const P = s - 0.3 * o - b.brow * 0.14 * o - Math.max(0, E - 1) * 0.12 * o, W = b.x + l - b.side * 0.13 * o, H = b.x + l + b.side * 0.13 * o;
|
|
129
|
+
e.beginPath(), e.moveTo(H, P), e.lineTo(W, P - t.browTilt * 0.1 * o), e.stroke();
|
|
118
130
|
}
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
|
|
131
|
+
const u = r + 0.4 * o, g = 0.25 * o * Math.max(0.3, t.mouthWidth), S = Math.min(1, Math.max(0, t.mouth));
|
|
132
|
+
if (e.beginPath(), S <= 0.05) {
|
|
133
|
+
e.moveTo(l - g, u), e.quadraticCurveTo(l, u + t.smile * 0.25 * o, l + g, u), e.stroke();
|
|
122
134
|
return;
|
|
123
135
|
}
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
function
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
const w = 0.3 * o * S;
|
|
137
|
+
t.smile > 0.3 ? (e.moveTo(l - g, u - 0.05 * o), e.lineTo(l + g, u - 0.05 * o), e.quadraticCurveTo(l, u + w * 2, l - g, u - 0.05 * o)) : t.smile < -0.3 ? (e.moveTo(l - g, u + w * 0.6), e.lineTo(l + g, u + w * 0.6), e.quadraticCurveTo(l, u - w * 1.4, l - g, u + w * 0.6)) : e.ellipse(l, u, g * 0.8, w, 0, 0, Math.PI * 2), e.fill();
|
|
138
|
+
}
|
|
139
|
+
function le(e, t, o, r, n = 16) {
|
|
140
|
+
const i = { x: 2 * t.x - (e.x + o.x) / 2, y: 2 * t.y - (e.y + o.y) / 2 }, h = [];
|
|
141
|
+
for (let l = 0; l <= n; l++) {
|
|
142
|
+
const s = l / n, a = s < 0.5 ? { x: e.x + (t.x - e.x) * 2 * s, y: e.y + (t.y - e.y) * 2 * s } : { x: t.x + (o.x - t.x) * (2 * s - 1), y: t.y + (o.y - t.y) * (2 * s - 1) }, f = 1 - s, y = {
|
|
143
|
+
x: f * f * e.x + 2 * f * s * i.x + s * s * o.x,
|
|
144
|
+
y: f * f * e.y + 2 * f * s * i.y + s * s * o.y
|
|
145
|
+
};
|
|
146
|
+
h.push({ x: a.x + (y.x - a.x) * r, y: a.y + (y.y - a.y) * r });
|
|
147
|
+
}
|
|
148
|
+
return h;
|
|
149
|
+
}
|
|
150
|
+
function ne(e, t, o = {}, r = 0) {
|
|
151
|
+
const n = o.height ?? 300, i = o.color ?? "#1e293b", h = (o.facing ?? 1) < 0 ? -1 : 1, l = Math.min(3, Math.max(0.3, t.stretch ?? 1)), s = Math.sqrt(l), a = Z * n, f = a / Math.sqrt(l), y = a * Math.sqrt(l), u = -0.46 * n * l, g = -0.76 * n * l;
|
|
152
|
+
e.save(), e.scale(h, 1), e.strokeStyle = i, e.lineWidth = o.lineWidth ?? n * 0.025, e.lineCap = "round", e.lineJoin = "round";
|
|
153
|
+
const S = (d, p, M, c, v) => {
|
|
154
|
+
const I = oe(M, c);
|
|
155
|
+
return { x: d + I.x * v * n, y: p + I.y * v * n };
|
|
156
|
+
}, w = o.sketch ? A(e, o.sketch, r) : void 0, b = (...d) => {
|
|
157
|
+
if (w) return w.line(d);
|
|
158
|
+
e.beginPath(), e.moveTo(d[0].x, d[0].y);
|
|
159
|
+
for (const p of d.slice(1)) e.lineTo(p.x, p.y);
|
|
160
|
+
e.stroke();
|
|
161
|
+
}, E = (d, p, M) => {
|
|
162
|
+
const c = Math.min(1, Math.max(0, o.rubber ?? 0));
|
|
163
|
+
if (c === 0) return b(d, p, M);
|
|
164
|
+
const v = le(d, p, M, c);
|
|
165
|
+
if (w) return w.curve(v);
|
|
166
|
+
e.beginPath(), e.moveTo(v[0].x, v[0].y);
|
|
167
|
+
for (const I of v.slice(1)) e.lineTo(I.x, I.y);
|
|
168
|
+
e.stroke();
|
|
137
169
|
};
|
|
138
|
-
for (const [
|
|
139
|
-
[-1,
|
|
140
|
-
[1,
|
|
170
|
+
for (const [d, p, M] of [
|
|
171
|
+
[-1, t.leftHip, t.leftKnee],
|
|
172
|
+
[1, t.rightHip, t.rightKnee]
|
|
141
173
|
]) {
|
|
142
|
-
const
|
|
143
|
-
|
|
174
|
+
const c = S(0, u, p, d, K * l);
|
|
175
|
+
E({ x: 0, y: u }, c, S(c.x, c.y, p - M, d, L * l));
|
|
144
176
|
}
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
for (const [
|
|
148
|
-
[-1,
|
|
149
|
-
[1,
|
|
177
|
+
e.translate(0, u), e.rotate(Y(t.lean)), e.translate(0, -u), b({ x: 0, y: u }, { x: 0, y: g });
|
|
178
|
+
const P = g + j * n * l;
|
|
179
|
+
for (const [d, p, M] of [
|
|
180
|
+
[-1, t.leftShoulder, t.leftElbow],
|
|
181
|
+
[1, t.rightShoulder, t.rightElbow]
|
|
150
182
|
]) {
|
|
151
|
-
const
|
|
152
|
-
|
|
183
|
+
const c = S(0, P, p, d, x * s);
|
|
184
|
+
E(
|
|
185
|
+
{ x: 0, y: P },
|
|
186
|
+
c,
|
|
187
|
+
S(c.x, c.y, p + M, d, ee * s)
|
|
188
|
+
);
|
|
153
189
|
}
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
190
|
+
e.translate(0, g), e.rotate(Y(t.headTilt));
|
|
191
|
+
const W = -y;
|
|
192
|
+
e.beginPath(), e.ellipse(0, W, f, y, 0, 0, Math.PI * 2);
|
|
193
|
+
const H = o.headFill ?? "#ffffff";
|
|
194
|
+
if (H !== "none" && (e.fillStyle = H, e.fill()), w) {
|
|
195
|
+
w.ellipse(0, W, f, y);
|
|
196
|
+
const d = w.nudge();
|
|
197
|
+
e.translate(d.x, d.y);
|
|
198
|
+
} else
|
|
199
|
+
e.stroke();
|
|
200
|
+
e.translate(0, W), e.scale(f / a, y / a), te(e, t, a, 0, i, o.lineWidth ?? n * 0.025), e.restore(), o.label && (e.save(), e.fillStyle = i, e.font = o.labelFont ?? `700 ${Math.round(n * 0.11)}px sans-serif`, e.textAlign = "center", e.textBaseline = "bottom", e.fillText(o.label, 0, -n * l - 0.04 * n), e.restore());
|
|
201
|
+
}
|
|
202
|
+
function he(e) {
|
|
203
|
+
const t = e.style ?? {}, o = t.height ?? 300, r = o * 0.8, n = { ...k(e.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: t.rubber ?? 0 };
|
|
162
204
|
return {
|
|
163
205
|
type: "custom",
|
|
164
|
-
x:
|
|
165
|
-
y:
|
|
166
|
-
width:
|
|
167
|
-
height:
|
|
168
|
-
props: { ...
|
|
169
|
-
draw(
|
|
170
|
-
const
|
|
171
|
-
let
|
|
172
|
-
|
|
206
|
+
x: e.x - r / 2,
|
|
207
|
+
y: e.y - o,
|
|
208
|
+
width: r,
|
|
209
|
+
height: o,
|
|
210
|
+
props: { ...n },
|
|
211
|
+
draw(i, h, l) {
|
|
212
|
+
const s = h.props, a = { ...s };
|
|
213
|
+
let f = s.walking > 0 ? $(a, z(s.walk, a), s.walking) : a;
|
|
214
|
+
s.talk > 0 && (f = { ...f, mouth: Math.max(f.mouth, s.talk * Q(l)) }), i.translate(r / 2, o), ne(i, f, { ...t, rubber: s.rubber }, l);
|
|
173
215
|
}
|
|
174
216
|
};
|
|
175
217
|
}
|
|
176
|
-
function
|
|
177
|
-
const
|
|
178
|
-
return
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
}),
|
|
182
|
-
id: `${
|
|
183
|
-
target:
|
|
184
|
-
property:
|
|
185
|
-
keyframes:
|
|
186
|
-
time:
|
|
187
|
-
value:
|
|
188
|
-
...
|
|
218
|
+
function ae(e, t) {
|
|
219
|
+
const o = [];
|
|
220
|
+
return t.forEach((r, n) => {
|
|
221
|
+
const i = n === 0 ? B : o[n - 1], h = typeof r.pose == "string" ? U[r.pose] : { ...i, ...r.pose };
|
|
222
|
+
o.push(r.expression ? D(h, r.expression) : h);
|
|
223
|
+
}), _.filter((r) => o.some((n) => n[r] !== B[r])).map((r) => ({
|
|
224
|
+
id: `${e}-${r}`,
|
|
225
|
+
target: e,
|
|
226
|
+
property: r,
|
|
227
|
+
keyframes: t.map((n, i) => ({
|
|
228
|
+
time: n.time,
|
|
229
|
+
value: o[i][r],
|
|
230
|
+
...n.easing ? { easing: n.easing } : {}
|
|
189
231
|
}))
|
|
190
232
|
}));
|
|
191
233
|
}
|
|
234
|
+
function ie(e, t, o = {}, r) {
|
|
235
|
+
const n = o.length ?? 240, i = 9, h = 28, l = n - 22;
|
|
236
|
+
e.save(), e.translate(t.x, t.y), e.rotate((o.angle ?? -30) * Math.PI / 180), e.fillStyle = o.color ?? "#f4c542", e.fillRect(h, -i, l - h, 2 * i), e.fillStyle = "#e8b4a0", e.fillRect(l, -i, n - l, 2 * i), e.fillStyle = "#f1dcbf", e.beginPath(), e.moveTo(0, 0), e.lineTo(h, -i), e.lineTo(h, i), e.closePath(), e.fill(), e.fillStyle = o.outline ?? "#2f2f33", e.beginPath(), e.moveTo(0, 0), e.lineTo(h * 0.35, -i * 0.35), e.lineTo(h * 0.35, i * 0.35), e.closePath(), e.fill(), e.strokeStyle = o.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round", e.lineCap = "round";
|
|
237
|
+
const s = [
|
|
238
|
+
[{ x: 0, y: 0 }, { x: h, y: -i }, { x: n, y: -i }, { x: n, y: i }, { x: h, y: i }, { x: 0, y: 0 }],
|
|
239
|
+
[{ x: h, y: -i }, { x: h, y: i }],
|
|
240
|
+
[{ x: l, y: -i }, { x: l, y: i }]
|
|
241
|
+
];
|
|
242
|
+
for (const a of s) J(e, a, r);
|
|
243
|
+
e.restore();
|
|
244
|
+
}
|
|
245
|
+
function N(e, t, o = {}, r) {
|
|
246
|
+
const n = o.length ?? 90, i = o.thickness ?? 34;
|
|
247
|
+
e.save(), e.translate(t.x, t.y), e.rotate((o.angle ?? -35) * Math.PI / 180);
|
|
248
|
+
const h = -i / 2;
|
|
249
|
+
e.fillStyle = o.color ?? "#f4a7b9", e.fillRect(0, h, n, i), e.fillStyle = "#e9edf2", e.fillRect(n * 0.45, h, n * 0.55, i), e.strokeStyle = o.outline ?? "#2f2f33", e.lineWidth = 3, e.lineJoin = "round";
|
|
250
|
+
const l = [
|
|
251
|
+
{ x: 0, y: h },
|
|
252
|
+
{ x: n, y: h },
|
|
253
|
+
{ x: n, y: -h },
|
|
254
|
+
{ x: 0, y: -h },
|
|
255
|
+
{ x: 0, y: h }
|
|
256
|
+
], s = [{ x: n * 0.45, y: h }, { x: n * 0.45, y: -h }];
|
|
257
|
+
if (r)
|
|
258
|
+
r.line(l), r.line(s);
|
|
259
|
+
else
|
|
260
|
+
for (const a of [l, s]) {
|
|
261
|
+
e.beginPath(), e.moveTo(a[0].x, a[0].y);
|
|
262
|
+
for (const f of a.slice(1)) e.lineTo(f.x, f.y);
|
|
263
|
+
e.stroke();
|
|
264
|
+
}
|
|
265
|
+
e.restore();
|
|
266
|
+
}
|
|
267
|
+
function q(e, t, o = {}, r) {
|
|
268
|
+
const n = o.tool ?? "pencil", i = o.skin ?? "#f1c9a5", h = o.outline ?? "#2f2f33", l = n === "eraser" ? 17 : 9, s = n === "eraser" ? -40 : 0, a = r ? r.nudge(0.6) : { x: 0, y: 0 };
|
|
269
|
+
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";
|
|
270
|
+
const f = (g, S, w, b) => {
|
|
271
|
+
for (const [E, P] of [
|
|
272
|
+
[h, w + 6],
|
|
273
|
+
[b, w]
|
|
274
|
+
])
|
|
275
|
+
e.strokeStyle = E, e.lineWidth = P, e.beginPath(), e.moveTo(g.x, g.y), e.lineTo(S.x, S.y), e.stroke();
|
|
276
|
+
};
|
|
277
|
+
e.save(), e.translate(s, 0);
|
|
278
|
+
const y = { x: 165, y: -l - 26 }, u = (g) => ({ x: y.x + g * 0.8, y: y.y + g * 0.6 });
|
|
279
|
+
f(y, u(2e3), 64, i), f(u(110), u(2e3), 92, o.sleeve ?? "#5b7db1"), e.fillStyle = i, 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" ? N(e, { x: 0, y: 0 }, { angle: 0, outline: h }, r) : ie(e, { x: 0, y: 0 }, { angle: 0, outline: h }, r), e.translate(s, 0), f({ x: 150, y: l + 8 }, { x: 92, y: l + 12 }, 22, i), f({ x: 140, y: -l - 18 }, { x: 58, y: -l - 6 }, 20, i), f({ x: 150, y: -l - 30 }, { x: 112, y: -l + 2 }, 20, i), f({ x: 172, y: -l - 30 }, { x: 140, y: -l + 4 }, 20, i), e.restore();
|
|
280
|
+
}
|
|
281
|
+
function fe(e, t, o, r = 0.08, n = 32) {
|
|
282
|
+
const i = Math.PI * 2 * (1 + r), h = [];
|
|
283
|
+
for (let l = 0; l <= n; l++) {
|
|
284
|
+
const s = -Math.PI / 2 + i * l / n;
|
|
285
|
+
h.push({ x: e + Math.cos(s) * o, y: t + Math.sin(s) * o });
|
|
286
|
+
}
|
|
287
|
+
return h;
|
|
288
|
+
}
|
|
289
|
+
function ue(e) {
|
|
290
|
+
const { path: t } = e, o = t.map((l) => l.x), r = t.map((l) => l.y), n = Math.min(...o), i = Math.min(...r), h = e.hand === !1 ? void 0 : e.hand === !0 || e.hand === void 0 ? {} : e.hand;
|
|
291
|
+
return {
|
|
292
|
+
type: "custom",
|
|
293
|
+
x: n,
|
|
294
|
+
y: i,
|
|
295
|
+
width: Math.max(1, Math.max(...o) - n),
|
|
296
|
+
height: Math.max(1, Math.max(...r) - i),
|
|
297
|
+
props: { draw: 0 },
|
|
298
|
+
draw(l, s, a) {
|
|
299
|
+
const f = Math.min(1, Math.max(0, Number(s.props?.draw ?? 0)));
|
|
300
|
+
l.translate(-n, -i), l.strokeStyle = e.color ?? "#2f2f33", l.lineWidth = e.lineWidth ?? 5, l.lineCap = "round", l.lineJoin = "round";
|
|
301
|
+
const y = e.sketch ? A(l, e.sketch, a) : void 0;
|
|
302
|
+
f > 0 && (y ? e.smooth ? y.curve(t, f) : y.line(t, f) : J(l, O(t, f))), h && f > 0 && f < 1 && q(l, C(t, f), h, y);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function J(e, t, o) {
|
|
307
|
+
if (!(t.length < 2)) {
|
|
308
|
+
if (o) return o.line(t);
|
|
309
|
+
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
310
|
+
for (const r of t.slice(1)) e.lineTo(r.x, r.y);
|
|
311
|
+
e.stroke();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const R = 1e5;
|
|
315
|
+
function ye(e, t, o, r, n = 6) {
|
|
316
|
+
const i = [], h = Math.max(1, Math.round(n));
|
|
317
|
+
for (let l = 0; l <= h; l++)
|
|
318
|
+
i.push({ x: l % 2 === 0 ? e : e + o, y: t + r * l / h });
|
|
319
|
+
return i;
|
|
320
|
+
}
|
|
321
|
+
function G(e, t, o, r) {
|
|
322
|
+
if (r <= 0 || t.length === 0) return;
|
|
323
|
+
const n = O(t, r), i = o / 2, h = (l) => {
|
|
324
|
+
e.beginPath(), e.rect(-R, -R, 2 * R, 2 * R), l(), e.clip("evenodd");
|
|
325
|
+
};
|
|
326
|
+
for (const l of n)
|
|
327
|
+
h(() => {
|
|
328
|
+
e.moveTo(l.x + i, l.y), e.arc(l.x, l.y, i, 0, Math.PI * 2);
|
|
329
|
+
});
|
|
330
|
+
for (let l = 1; l < n.length; l++) {
|
|
331
|
+
const s = n[l - 1], a = n[l], f = Math.hypot(a.x - s.x, a.y - s.y);
|
|
332
|
+
if (f === 0) continue;
|
|
333
|
+
const y = -(a.y - s.y) / f * i, u = (a.x - s.x) / f * i;
|
|
334
|
+
h(() => {
|
|
335
|
+
e.moveTo(s.x + y, s.y + u), e.lineTo(a.x + y, a.y + u), e.lineTo(a.x - y, a.y - u), e.lineTo(s.x - y, s.y - u), e.closePath();
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function de(e, t, o, r, n) {
|
|
340
|
+
e.save(), G(e, t, o, r), n(), e.restore();
|
|
341
|
+
}
|
|
342
|
+
function ge(e, t) {
|
|
343
|
+
const o = t.width ?? 40, r = t.hand === !0 ? {} : t.hand || void 0, n = t.eraser === !1 ? void 0 : t.eraser === !0 || t.eraser === void 0 ? {} : t.eraser;
|
|
344
|
+
return {
|
|
345
|
+
...e,
|
|
346
|
+
props: { ...e.props, erase: 0 },
|
|
347
|
+
draw(i, h, l) {
|
|
348
|
+
const s = Number(h.props?.erase ?? 0);
|
|
349
|
+
if (i.save(), G(i, t.path, o, s), e.draw(i, h, l), i.restore(), !n || s <= 0 || s >= 1) return;
|
|
350
|
+
const a = C(t.path, s);
|
|
351
|
+
r ? q(i, a, { ...r, tool: "eraser" }) : N(i, a, n);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
192
355
|
export {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
356
|
+
T as EXPRESSIONS,
|
|
357
|
+
U as POSES,
|
|
358
|
+
B as REST_POSE,
|
|
359
|
+
$ as blendPose,
|
|
360
|
+
be as boilFrame,
|
|
361
|
+
fe as circlePath,
|
|
362
|
+
G as clipErased,
|
|
363
|
+
N as drawEraser,
|
|
364
|
+
q as drawHand,
|
|
365
|
+
ie as drawPencil,
|
|
366
|
+
ne as drawStickFigure,
|
|
367
|
+
ue as drawnPathTarget,
|
|
368
|
+
ge as erasable,
|
|
369
|
+
O as partialPath,
|
|
370
|
+
pe as pathLength,
|
|
371
|
+
C as pointAlong,
|
|
372
|
+
k as pose,
|
|
373
|
+
ae as poseTracks,
|
|
374
|
+
le as rubberLimb,
|
|
375
|
+
ye as scrubPath,
|
|
376
|
+
A as sketchPen,
|
|
377
|
+
he as stickFigureTarget,
|
|
378
|
+
se as strideLength,
|
|
379
|
+
Q as talkingMouth,
|
|
380
|
+
z as walkPose,
|
|
381
|
+
de as withErased,
|
|
382
|
+
D as withExpression
|
|
204
383
|
};
|