@algorisys/tinyfly 0.74.1 → 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.
@@ -1,4 +1,6 @@
1
- const k = {
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 p(t) {
25
- return { ...k, ...t };
27
+ function k(e) {
28
+ return { ...B, ...e };
26
29
  }
27
- const v = {
30
+ const F = {
28
31
  mouth: 0,
29
32
  smile: 0,
30
33
  mouthWidth: 1,
@@ -35,177 +38,346 @@ const v = {
35
38
  browTilt: 0,
36
39
  lookX: 0,
37
40
  lookY: 0
38
- }, a = (t) => ({ ...v, ...t }), b = {
39
- neutral: v,
40
- happy: a({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
41
- joyful: a({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
42
- sad: a({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
43
- crying: a({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
44
- surprised: a({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
45
- shocked: a({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
46
- angry: a({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
47
- furious: a({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
48
- worried: a({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
49
- scared: a({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
50
- confused: a({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
51
- skeptical: a({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
52
- thinking: a({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
53
- sleepy: a({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
54
- disgusted: a({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
55
- smug: a({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
56
- wink: a({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
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 R(t, e) {
59
- return { ...t, ...typeof e == "string" ? b[e] : e };
60
- }
61
- const A = {
62
- rest: k,
63
- wave: p({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...b.happy }),
64
- cheer: p({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...b.joyful }),
65
- shrug: p({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...b.confused, lookX: 0, lookY: 0 }),
66
- point: p({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
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: p({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...b.thinking }),
69
- handsOnHips: p({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
70
- sad: p({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...b.sad }),
71
- surprised: p({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...b.surprised })
72
- }, I = Object.keys(k);
73
- function O(t, e, o) {
74
- const l = { ...t };
75
- for (const h of I) l[h] = t[h] + (e[h] - t[h]) * o;
76
- return l;
77
- }
78
- const P = 24, _ = 40;
79
- function F(t, e = k, o = 1) {
80
- const l = Math.sin(t * Math.PI * 2) * o, h = Math.cos(t * Math.PI * 2) * o, u = (g) => g <= _ ? 22 * l : g;
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;
81
87
  return {
82
- ...e,
88
+ ...t,
83
89
  // Left foot forward while swing > 0, right foot back; then the other way.
84
- leftHip: -P * l,
85
- rightHip: -P * l,
90
+ leftHip: -X * r,
91
+ rightHip: -X * r,
86
92
  // The leg swinging forward lifts, its shin trailing backward (-x). A positive
87
93
  // knee folds toward the centre, which is backward only for the right leg.
88
- leftKnee: -30 * Math.max(0, h),
89
- rightKnee: 30 * Math.max(0, -h),
94
+ leftKnee: -30 * Math.max(0, n),
95
+ rightKnee: 30 * Math.max(0, -n),
90
96
  // Arms swing against the legs: left arm back while the left foot is forward.
91
- leftShoulder: u(e.leftShoulder),
92
- rightShoulder: u(e.rightShoulder)
97
+ leftShoulder: i(t.leftShoulder),
98
+ rightShoulder: i(t.rightShoulder)
93
99
  };
94
100
  }
95
- function U(t, e = 1) {
96
- return 4 * ((Y + H) * t) * Math.sin(P * e * Math.PI / 180);
101
+ function se(e, t = 1) {
102
+ return 4 * ((K + L) * e) * Math.sin(X * t * Math.PI / 180);
97
103
  }
98
- function K(t) {
99
- const e = Math.abs(Math.sin(t / 65)), o = 0.55 + 0.45 * Math.sin(t / 310);
100
- return e * o;
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;
101
107
  }
102
- const C = 0.12, N = 0.1, L = 0.21, q = 0.19, Y = 0.24, H = 0.22, M = (t) => t * Math.PI / 180, G = (t, e) => ({ x: e * Math.sin(M(t)), y: Math.cos(M(t)) });
103
- function j(t, e, o, l, h, u) {
104
- const g = Math.max(1, u * 0.6), i = 0.12 * o, n = l - 0.12 * o, E = i + e.lookX * 0.08 * o, y = e.lookY * 0.07 * o, S = [
105
- { x: -0.34 * o, open: e.leftEye, brow: e.leftBrow, side: -1 },
106
- { x: 0.34 * o, open: e.rightEye, brow: e.rightBrow, side: 1 }
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 }
107
113
  ];
108
- t.fillStyle = h, t.strokeStyle = h, t.lineWidth = g;
109
- for (const s of S) {
110
- const f = Math.max(0, s.open) * (1 - Math.min(1, Math.max(0, e.blink)));
111
- if (f < 0.2) {
112
- const T = e.smile > 0.5 ? -0.12 * o : 0.06 * o;
113
- t.beginPath(), t.moveTo(s.x + i - 0.12 * o, n), t.quadraticCurveTo(s.x + i, n + T, s.x + i + 0.12 * o, n), t.stroke();
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();
114
120
  } else {
115
- if (f > 1.2) {
116
- const W = 0.13 * o * f;
117
- t.beginPath(), t.ellipse(s.x + i, n, W * 0.85, W, 0, 0, Math.PI * 2), t.fillStyle = "#ffffff", t.fill(), t.stroke(), t.fillStyle = h;
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;
118
124
  }
119
- const T = f > 1.2 ? 0.075 * o : 0.1 * o;
120
- t.beginPath(), t.ellipse(s.x + E, n + y, T, T * 1.1 * Math.min(f, 1), 0, 0, Math.PI * 2), t.fill();
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();
121
127
  }
122
- const c = n - 0.3 * o - s.brow * 0.14 * o - Math.max(0, f - 1) * 0.12 * o, B = s.x + i - s.side * 0.13 * o, X = s.x + i + s.side * 0.13 * o;
123
- t.beginPath(), t.moveTo(X, c), t.lineTo(B, c - e.browTilt * 0.1 * o), t.stroke();
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();
124
130
  }
125
- const w = l + 0.4 * o, m = 0.25 * o * Math.max(0.3, e.mouthWidth), d = Math.min(1, Math.max(0, e.mouth));
126
- if (t.beginPath(), d <= 0.05) {
127
- t.moveTo(i - m, w), t.quadraticCurveTo(i, w + e.smile * 0.25 * o, i + m, w), t.stroke();
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();
128
134
  return;
129
135
  }
130
- const r = 0.3 * o * d;
131
- e.smile > 0.3 ? (t.moveTo(i - m, w - 0.05 * o), t.lineTo(i + m, w - 0.05 * o), t.quadraticCurveTo(i, w + r * 2, i - m, w - 0.05 * o)) : e.smile < -0.3 ? (t.moveTo(i - m, w + r * 0.6), t.lineTo(i + m, w + r * 0.6), t.quadraticCurveTo(i, w - r * 1.4, i - m, w + r * 0.6)) : t.ellipse(i, w, m * 0.8, r, 0, 0, Math.PI * 2), t.fill();
132
- }
133
- function D(t, e, o = {}) {
134
- const l = o.height ?? 300, h = o.color ?? "#1e293b", u = (o.facing ?? 1) < 0 ? -1 : 1, g = C * l, i = -0.46 * l, n = -0.76 * l;
135
- t.save(), t.scale(u, 1), t.strokeStyle = h, t.lineWidth = o.lineWidth ?? l * 0.025, t.lineCap = "round", t.lineJoin = "round";
136
- const E = (d, r, s, f, c) => {
137
- const B = G(s, f);
138
- return { x: d + B.x * c * l, y: r + B.y * c * l };
139
- }, y = (...d) => {
140
- t.beginPath(), t.moveTo(d[0].x, d[0].y);
141
- for (const r of d.slice(1)) t.lineTo(r.x, r.y);
142
- t.stroke();
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();
143
169
  };
144
- for (const [d, r, s] of [
145
- [-1, e.leftHip, e.leftKnee],
146
- [1, e.rightHip, e.rightKnee]
170
+ for (const [d, p, M] of [
171
+ [-1, t.leftHip, t.leftKnee],
172
+ [1, t.rightHip, t.rightKnee]
147
173
  ]) {
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));
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));
150
176
  }
151
- t.translate(0, i), t.rotate(M(e.lean)), t.translate(0, -i), y({ x: 0, y: i }, { x: 0, y: n });
152
- const S = n + N * l;
153
- for (const [d, r, s] of [
154
- [-1, e.leftShoulder, e.leftElbow],
155
- [1, e.rightShoulder, e.rightElbow]
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]
156
182
  ]) {
157
- const f = E(0, S, r, d, L);
158
- y({ x: 0, y: S }, f, E(f.x, f.y, r + s, d, q));
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
+ );
159
189
  }
160
- t.translate(0, n), t.rotate(M(e.headTilt));
161
- const w = -g;
162
- t.beginPath(), t.arc(0, w, g, 0, Math.PI * 2);
163
- const m = o.headFill ?? "#ffffff";
164
- m !== "none" && (t.fillStyle = m, t.fill()), t.stroke(), j(t, e, g, w, h, o.lineWidth ?? l * 0.025), t.restore(), o.label && (t.save(), t.fillStyle = h, t.font = o.labelFont ?? `700 ${Math.round(l * 0.11)}px sans-serif`, t.textAlign = "center", t.textBaseline = "bottom", t.fillText(o.label, 0, -l - 0.04 * l), t.restore());
165
- }
166
- function $(t) {
167
- const e = t.style ?? {}, o = e.height ?? 300, l = o * 0.8, h = { ...p(t.pose ?? {}), walk: 0, walking: 0, talk: 0 };
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 };
168
204
  return {
169
205
  type: "custom",
170
- x: t.x - l / 2,
171
- y: t.y - o,
172
- width: l,
206
+ x: e.x - r / 2,
207
+ y: e.y - o,
208
+ width: r,
173
209
  height: o,
174
- props: { ...h },
175
- draw(u, g, i) {
176
- const n = g.props, E = { ...n };
177
- let y = n.walking > 0 ? O(E, F(n.walk, E), n.walking) : E;
178
- n.talk > 0 && (y = { ...y, mouth: Math.max(y.mouth, n.talk * K(i)) }), u.translate(l / 2, o), D(u, y, e);
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);
179
215
  }
180
216
  };
181
217
  }
182
- function J(t, e) {
218
+ function ae(e, t) {
183
219
  const o = [];
184
- return e.forEach((l, h) => {
185
- const u = h === 0 ? k : o[h - 1], g = typeof l.pose == "string" ? A[l.pose] : { ...u, ...l.pose };
186
- o.push(l.expression ? R(g, l.expression) : g);
187
- }), I.filter((l) => o.some((h) => h[l] !== k[l])).map((l) => ({
188
- id: `${t}-${l}`,
189
- target: t,
190
- property: l,
191
- keyframes: e.map((h, u) => ({
192
- time: h.time,
193
- value: o[u][l],
194
- ...h.easing ? { easing: h.easing } : {}
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 } : {}
195
231
  }))
196
232
  }));
197
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
+ }
198
355
  export {
199
- b as EXPRESSIONS,
200
- A as POSES,
201
- k as REST_POSE,
202
- O as blendPose,
203
- D as drawStickFigure,
204
- p as pose,
205
- J as poseTracks,
206
- $ as stickFigureTarget,
207
- U as strideLength,
208
- K as talkingMouth,
209
- F as walkPose,
210
- R as withExpression
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
211
383
  };