@algorisys/tinyfly 0.75.0 → 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.
@@ -1,6 +1,6 @@
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 = {
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 = {
4
4
  lean: 0,
5
5
  headTilt: 0,
6
6
  leftShoulder: 18,
@@ -22,12 +22,14 @@ const B = {
22
22
  browTilt: 0,
23
23
  lookX: 0,
24
24
  lookY: 0,
25
- stretch: 1
25
+ stretch: 1,
26
+ turn: 0,
27
+ sit: 0
26
28
  };
27
- function k(e) {
28
- return { ...B, ...e };
29
+ function P(e) {
30
+ return { ...Y, ...e };
29
31
  }
30
- const F = {
32
+ const le = {
31
33
  mouth: 0,
32
34
  smile: 0,
33
35
  mouthWidth: 1,
@@ -38,346 +40,532 @@ const F = {
38
40
  browTilt: 0,
39
41
  lookX: 0,
40
42
  lookY: 0
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 })
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 })
60
62
  };
61
- function D(e, t) {
62
- return { ...e, ...typeof t == "string" ? T[t] : t };
63
+ function Ee(e, t) {
64
+ return { ...e, ...typeof t == "string" ? H[t] : t };
63
65
  }
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 }),
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 }),
70
72
  // The forearm passes 180° to fold back in, so the hand reaches the chin.
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 }),
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 }),
75
77
  // 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;
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;
87
+ return l;
83
88
  }
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;
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;
87
92
  return {
88
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,
89
99
  // Left foot forward while swing > 0, right foot back; then the other way.
90
- leftHip: -X * r,
91
- rightHip: -X * r,
100
+ leftHip: -K * l,
101
+ rightHip: -K * l,
92
102
  // The leg swinging forward lifts, its shin trailing backward (-x). A positive
93
103
  // knee folds toward the centre, which is backward only for the right leg.
94
104
  leftKnee: -30 * Math.max(0, n),
95
105
  rightKnee: 30 * Math.max(0, -n),
96
106
  // Arms swing against the legs: left arm back while the left foot is forward.
97
- leftShoulder: i(t.leftShoulder),
98
- rightShoulder: i(t.rightShoulder)
107
+ leftShoulder: h(t.leftShoulder),
108
+ rightShoulder: h(t.rightShoulder)
99
109
  };
100
110
  }
101
- function se(e, t = 1) {
102
- return 4 * ((K + L) * e) * Math.sin(X * t * Math.PI / 180);
111
+ function Qe(e, t = 1) {
112
+ return 4 * ((C + N) * e) * Math.sin(K * t * Math.PI / 180);
103
113
  }
104
- function Q(e) {
114
+ function ke(e) {
105
115
  const t = Math.abs(Math.sin(e / 65)), o = 0.55 + 0.45 * Math.sin(e / 310);
106
116
  return t * o;
107
117
  }
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 }
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;
121
+ }
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 }
113
128
  ];
114
129
  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();
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();
120
135
  } else {
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;
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;
124
139
  }
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();
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();
127
142
  }
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();
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();
130
145
  }
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();
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();
134
149
  return;
135
150
  }
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();
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();
138
153
  }
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
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
145
160
  };
146
- h.push({ x: a.x + (y.x - a.x) * r, y: a.y + (y.y - a.y) * r });
161
+ h.push({ x: a.x + (y.x - a.x) * l, y: a.y + (y.y - a.y) * l });
147
162
  }
148
163
  return h;
149
164
  }
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();
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 };
169
169
  };
170
- for (const [d, p, M] of [
171
- [-1, t.leftHip, t.leftKnee],
172
- [1, t.rightHip, t.rightKnee]
173
- ]) {
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));
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;
176
174
  }
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]
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]
182
226
  ]) {
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
- );
227
+ const g = ce(D, 1, u, fe(c, t.blink));
228
+ y = Math.min(y, g, g - t.browTilt * 0.1);
189
229
  }
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());
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);
201
269
  }
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 };
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 };
204
375
  return {
205
376
  type: "custom",
206
- x: e.x - r / 2,
377
+ x: e.x - l / 2,
207
378
  y: e.y - o,
208
- width: r,
379
+ width: l,
209
380
  height: o,
210
381
  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);
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);
215
386
  }
216
387
  };
217
388
  }
218
- function ae(e, t) {
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) {
219
400
  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}`,
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}`,
225
406
  target: e,
226
- property: r,
227
- keyframes: t.map((n, i) => ({
407
+ property: l,
408
+ keyframes: t.map((n, s) => ({
228
409
  time: n.time,
229
- value: o[i][r],
410
+ value: o[s][l],
230
411
  ...n.easing ? { easing: n.easing } : {}
231
412
  }))
232
413
  }));
233
414
  }
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 }]
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 }]
241
422
  ];
242
- for (const a of s) J(e, a, r);
423
+ for (const a of r) we(e, a, l);
243
424
  e.restore();
244
425
  }
245
- function N(e, t, o = {}, r) {
246
- const n = o.length ?? 90, i = o.thickness ?? 34;
426
+ function me(e, t, o = {}, l) {
427
+ const n = o.length ?? 90, s = o.thickness ?? 34;
247
428
  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 = [
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 = [
251
432
  { x: 0, y: h },
252
433
  { x: n, y: h },
253
434
  { x: n, y: -h },
254
435
  { x: 0, y: -h },
255
436
  { 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);
437
+ ], r = [{ x: n * 0.45, y: h }, { x: n * 0.45, y: -h }];
438
+ if (l)
439
+ l.line(i), l.line(r);
259
440
  else
260
- for (const a of [l, s]) {
441
+ for (const a of [i, r]) {
261
442
  e.beginPath(), e.moveTo(a[0].x, a[0].y);
262
443
  for (const f of a.slice(1)) e.lineTo(f.x, f.y);
263
444
  e.stroke();
264
445
  }
265
446
  e.restore();
266
447
  }
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 };
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 };
269
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";
270
- const f = (g, S, w, b) => {
271
- for (const [E, P] of [
272
- [h, w + 6],
273
- [b, w]
451
+ const f = (d, m, b, E) => {
452
+ for (const [u, c] of [
453
+ [h, b + 6],
454
+ [E, b]
274
455
  ])
275
- e.strokeStyle = E, e.lineWidth = P, e.beginPath(), e.moveTo(g.x, g.y), e.lineTo(S.x, S.y), e.stroke();
456
+ e.strokeStyle = u, e.lineWidth = c, e.beginPath(), e.moveTo(d.x, d.y), e.lineTo(m.x, m.y), e.stroke();
276
457
  };
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();
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();
280
461
  }
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 });
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 });
286
467
  }
287
468
  return h;
288
469
  }
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;
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;
291
472
  return {
292
473
  type: "custom",
293
474
  x: n,
294
- y: i,
475
+ y: s,
295
476
  width: Math.max(1, Math.max(...o) - n),
296
- height: Math.max(1, Math.max(...r) - i),
477
+ height: Math.max(1, Math.max(...l) - s),
297
478
  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);
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);
303
484
  }
304
485
  };
305
486
  }
306
- function J(e, t, o) {
487
+ function we(e, t, o) {
307
488
  if (!(t.length < 2)) {
308
489
  if (o) return o.line(t);
309
490
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
310
- for (const r of t.slice(1)) e.lineTo(r.x, r.y);
491
+ for (const l of t.slice(1)) e.lineTo(l.x, l.y);
311
492
  e.stroke();
312
493
  }
313
494
  }
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;
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;
320
501
  }
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");
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");
325
506
  };
326
- for (const l of n)
507
+ for (const i of n)
327
508
  h(() => {
328
- e.moveTo(l.x + i, l.y), e.arc(l.x, l.y, i, 0, Math.PI * 2);
509
+ e.moveTo(i.x + s, i.y), e.arc(i.x, i.y, s, 0, Math.PI * 2);
329
510
  });
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);
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);
332
513
  if (f === 0) continue;
333
- const y = -(a.y - s.y) / f * i, u = (a.x - s.x) / f * i;
514
+ const y = -(a.y - r.y) / f * s, w = (a.x - r.x) / f * s;
334
515
  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();
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();
336
517
  });
337
518
  }
338
519
  }
339
- function de(e, t, o, r, n) {
340
- e.save(), G(e, t, o, r), n(), e.restore();
520
+ function lt(e, t, o, l, n) {
521
+ e.save(), be(e, t, o, l), n(), e.restore();
341
522
  }
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;
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;
344
525
  return {
345
526
  ...e,
346
527
  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);
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);
352
533
  }
353
534
  };
354
535
  }
355
536
  export {
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
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
383
571
  };