@algorisys/tinyfly 0.78.0 → 0.79.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,37 +1,37 @@
1
- import { s as xt, p as Dt, c as jt, b as ye } from "./sketch-CA8ZXhxI.js";
2
- import { a as jn } from "./sketch-CA8ZXhxI.js";
3
- import { createRandom as me, hashSeed as pe } from "@algorisys/tinyfly";
4
- function ht(t, e, n) {
1
+ import { s as Ht, b as We, p as ae, c as Ut } from "./sketch-CA8ZXhxI.js";
2
+ import { a as Fo } from "./sketch-CA8ZXhxI.js";
3
+ import { createRandom as $e, hashSeed as Re } from "@algorisys/tinyfly";
4
+ function yt(t, e, n) {
5
5
  const o = t.length;
6
6
  if (o < 2) return [];
7
- const r = [], s = [], h = (i) => e + (n - e) * i / (o - 1);
7
+ const s = [], r = [], h = (i) => e + (n - e) * i / (o - 1);
8
8
  return t.forEach((i, l) => {
9
- const a = t[Math.max(0, l - 1)], c = t[Math.min(o - 1, l + 1)], g = Math.hypot(c.x - a.x, c.y - a.y) || 1, y = h(l) / 2, f = -(c.y - a.y) / g * y, d = (c.x - a.x) / g * y;
10
- r.push({ x: i.x + f, y: i.y + d }), s.push({ x: i.x - f, y: i.y - d });
11
- }), [...r, ...s.reverse()];
12
- }
13
- function Jt(t, e, n, o) {
14
- const r = e.length;
15
- if (r < 2) return;
16
- const s = ht(e, n, o), h = (i) => n + (o - n) * i / (r - 1);
17
- t.beginPath(), t.moveTo(s[0].x, s[0].y);
18
- for (const i of s.slice(1)) t.lineTo(i.x, i.y);
9
+ const a = t[Math.max(0, l - 1)], f = t[Math.min(o - 1, l + 1)], g = Math.hypot(f.x - a.x, f.y - a.y) || 1, m = h(l) / 2, c = -(f.y - a.y) / g * m, d = (f.x - a.x) / g * m;
10
+ s.push({ x: i.x + c, y: i.y + d }), r.push({ x: i.x - c, y: i.y - d });
11
+ }), [...s, ...r.reverse()];
12
+ }
13
+ function Xt(t, e, n, o) {
14
+ const s = e.length;
15
+ if (s < 2) return;
16
+ const r = yt(e, n, o), h = (i) => n + (o - n) * i / (s - 1);
17
+ t.beginPath(), t.moveTo(r[0].x, r[0].y);
18
+ for (const i of r.slice(1)) t.lineTo(i.x, i.y);
19
19
  t.closePath(), t.fill(), e.forEach((i, l) => {
20
- l !== 0 && l !== r - 1 && r > 3 || (t.beginPath(), t.arc(i.x, i.y, h(l) / 2, 0, Math.PI * 2), t.fill());
20
+ l !== 0 && l !== s - 1 && s > 3 || (t.beginPath(), t.arc(i.x, i.y, h(l) / 2, 0, Math.PI * 2), t.fill());
21
21
  });
22
22
  }
23
- function z(t, e, n, o, r = 16) {
24
- const s = { x: 2 * e.x - (t.x + n.x) / 2, y: 2 * e.y - (t.y + n.y) / 2 }, h = [];
25
- for (let i = 0; i <= r; i++) {
26
- const l = i / r, a = l < 0.5 ? { x: t.x + (e.x - t.x) * 2 * l, y: t.y + (e.y - t.y) * 2 * l } : { x: e.x + (n.x - e.x) * (2 * l - 1), y: e.y + (n.y - e.y) * (2 * l - 1) }, c = 1 - l, g = {
27
- x: c * c * t.x + 2 * c * l * s.x + l * l * n.x,
28
- y: c * c * t.y + 2 * c * l * s.y + l * l * n.y
23
+ function tt(t, e, n, o, s = 16) {
24
+ const r = { x: 2 * e.x - (t.x + n.x) / 2, y: 2 * e.y - (t.y + n.y) / 2 }, h = [];
25
+ for (let i = 0; i <= s; i++) {
26
+ const l = i / s, a = l < 0.5 ? { x: t.x + (e.x - t.x) * 2 * l, y: t.y + (e.y - t.y) * 2 * l } : { x: e.x + (n.x - e.x) * (2 * l - 1), y: e.y + (n.y - e.y) * (2 * l - 1) }, f = 1 - l, g = {
27
+ x: f * f * t.x + 2 * f * l * r.x + l * l * n.x,
28
+ y: f * f * t.y + 2 * f * l * r.y + l * l * n.y
29
29
  };
30
30
  h.push({ x: a.x + (g.x - a.x) * o, y: a.y + (g.y - a.y) * o });
31
31
  }
32
32
  return h;
33
33
  }
34
- const G = {
34
+ const et = {
35
35
  lean: 0,
36
36
  headTilt: 0,
37
37
  leftShoulder: 18,
@@ -57,10 +57,10 @@ const G = {
57
57
  turn: 0,
58
58
  sit: 0
59
59
  };
60
- function B(t) {
61
- return { ...G, ...t };
60
+ function L(t) {
61
+ return { ...et, ...t };
62
62
  }
63
- const zt = {
63
+ const ce = {
64
64
  mouth: 0,
65
65
  smile: 0,
66
66
  mouthWidth: 1,
@@ -71,204 +71,204 @@ const zt = {
71
71
  browTilt: 0,
72
72
  lookX: 0,
73
73
  lookY: 0
74
- }, _ = (t) => ({ ...zt, ...t }), N = {
75
- neutral: zt,
76
- happy: _({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
77
- joyful: _({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
78
- sad: _({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
79
- crying: _({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
80
- surprised: _({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
81
- shocked: _({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
82
- angry: _({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
83
- furious: _({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
84
- worried: _({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
85
- scared: _({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
86
- confused: _({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
87
- skeptical: _({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
88
- thinking: _({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
89
- sleepy: _({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
90
- disgusted: _({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
91
- smug: _({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
92
- wink: _({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
74
+ }, $ = (t) => ({ ...ce, ...t }), X = {
75
+ neutral: ce,
76
+ happy: $({ smile: 0.9, leftBrow: 0.2, rightBrow: 0.2 }),
77
+ joyful: $({ mouth: 0.6, smile: 1, mouthWidth: 1.2, leftEye: 0, rightEye: 0, leftBrow: 0.4, rightBrow: 0.4 }),
78
+ sad: $({ smile: -0.8, leftEye: 0.8, rightEye: 0.8, browTilt: 0.9, leftBrow: -0.1, rightBrow: -0.1, lookY: 0.6 }),
79
+ crying: $({ mouth: 0.45, smile: -1, leftEye: 0, rightEye: 0, browTilt: 1, lookY: 0.4 }),
80
+ surprised: $({ mouth: 0.7, mouthWidth: 0.7, leftEye: 1.5, rightEye: 1.5, leftBrow: 1, rightBrow: 1 }),
81
+ shocked: $({ mouth: 1, mouthWidth: 0.8, leftEye: 1.6, rightEye: 1.6, leftBrow: 1, rightBrow: 1, browTilt: 0.4 }),
82
+ angry: $({ smile: -0.6, mouthWidth: 0.9, leftEye: 0.8, rightEye: 0.8, leftBrow: -0.6, rightBrow: -0.6, browTilt: -1 }),
83
+ furious: $({ mouth: 0.5, smile: -1, mouthWidth: 1.3, leftEye: 0.9, rightEye: 0.9, leftBrow: -0.9, rightBrow: -0.9, browTilt: -1 }),
84
+ worried: $({ smile: -0.3, mouthWidth: 0.8, leftEye: 1.1, rightEye: 1.1, leftBrow: 0.3, rightBrow: 0.3, browTilt: 0.8, lookX: -0.5 }),
85
+ scared: $({ mouth: 0.35, smile: -0.5, mouthWidth: 0.8, leftEye: 1.45, rightEye: 1.45, leftBrow: 0.8, rightBrow: 0.8, browTilt: 0.9 }),
86
+ confused: $({ smile: -0.2, mouthWidth: 0.8, leftEye: 0.9, rightEye: 1.15, leftBrow: -0.3, rightBrow: 0.8, lookX: 0.5, lookY: -0.4 }),
87
+ skeptical: $({ smile: -0.1, leftEye: 0.6, rightEye: 1, leftBrow: -0.4, rightBrow: 0.7, lookX: 0.4 }),
88
+ thinking: $({ smile: 0, mouthWidth: 0.7, leftBrow: 0.3, rightBrow: 0.5, lookX: 0.6, lookY: -0.8 }),
89
+ sleepy: $({ smile: 0.1, leftEye: 0.25, rightEye: 0.25, leftBrow: -0.3, rightBrow: -0.3, lookY: 0.5 }),
90
+ disgusted: $({ smile: -0.7, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.75, leftBrow: -0.5, rightBrow: -0.2, browTilt: -0.4, lookX: -0.6 }),
91
+ smug: $({ smile: 0.6, mouthWidth: 0.9, leftEye: 0.6, rightEye: 0.6, leftBrow: 0.1, rightBrow: 0.5, lookX: 0.5 }),
92
+ wink: $({ smile: 0.9, leftEye: 0, rightEye: 1, leftBrow: -0.2, rightBrow: 0.3 })
93
93
  };
94
- function we(t, e) {
95
- return { ...t, ...typeof e == "string" ? N[e] : e };
96
- }
97
- const be = {
98
- rest: G,
99
- wave: B({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...N.happy }),
100
- cheer: B({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...N.joyful }),
101
- shrug: B({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...N.confused, lookX: 0, lookY: 0 }),
102
- point: B({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
94
+ function Be(t, e) {
95
+ return { ...t, ...typeof e == "string" ? X[e] : e };
96
+ }
97
+ const Ye = {
98
+ rest: et,
99
+ wave: L({ rightShoulder: 135, rightElbow: 30, headTilt: 6, ...X.happy }),
100
+ cheer: L({ leftShoulder: 125, leftElbow: 20, rightShoulder: 125, rightElbow: 20, ...X.joyful }),
101
+ shrug: L({ leftShoulder: 30, leftElbow: 85, rightShoulder: 30, rightElbow: 85, headTilt: -10, ...X.confused, lookX: 0, lookY: 0 }),
102
+ point: L({ rightShoulder: 90, rightElbow: 0, lean: 4, smile: 0.4 }),
103
103
  // The forearm passes 180° to fold back in, so the hand reaches the chin.
104
- think: B({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...N.thinking }),
105
- handsOnHips: B({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
106
- sad: B({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...N.sad }),
107
- surprised: B({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...N.surprised }),
104
+ think: L({ rightShoulder: 60, rightElbow: 150, headTilt: 10, ...X.thinking }),
105
+ handsOnHips: L({ leftShoulder: 45, leftElbow: -100, rightShoulder: 45, rightElbow: -100, leftHip: 14, rightHip: 14, smile: 0.8 }),
106
+ sad: L({ leftShoulder: 14, rightShoulder: 14, leftElbow: -4, rightElbow: -4, headTilt: -14, lean: -3, ...X.sad }),
107
+ surprised: L({ leftShoulder: 70, leftElbow: 60, rightShoulder: 70, rightElbow: 60, ...X.surprised }),
108
108
  // Squash and stretch: the wind-up before a jump (or the landing), and the jump itself.
109
- crouch: B({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
109
+ crouch: L({ stretch: 0.72, leftShoulder: 35, rightShoulder: 35, leftElbow: -50, rightElbow: -50, leftHip: 22, rightHip: 22, headTilt: -4 }),
110
110
  // Seated, hands resting on the knees. Arm angles spread outward per side, so
111
111
  // reaching forward (+x, the way the figure faces) is negative for the left arm.
112
- sit: B({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
113
- jump: B({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...N.joyful })
114
- }, Gt = Object.keys(G);
115
- function Me(t, e, n) {
112
+ sit: L({ sit: 1, turn: 0.5, leftShoulder: -25, rightShoulder: 25, leftElbow: -55, rightElbow: 55 }),
113
+ jump: L({ stretch: 1.22, leftShoulder: 140, rightShoulder: 140, leftElbow: 20, rightElbow: 20, leftHip: 4, rightHip: 4, ...X.joyful })
114
+ }, fe = Object.keys(et);
115
+ function Le(t, e, n) {
116
116
  const o = { ...t };
117
- for (const r of Gt) o[r] = t[r] + (e[r] - t[r]) * n;
117
+ for (const s of fe) o[s] = t[s] + (e[s] - t[s]) * n;
118
118
  return o;
119
119
  }
120
- const St = 24, _t = 4, Yt = 28, ke = 40;
121
- function Ee(t, e = G, n = 1) {
122
- const o = Math.sin(t * Math.PI * 2) * n, r = Math.cos(t * Math.PI * 2) * n, s = (a) => a <= ke, h = (a) => s(a) ? 22 * o : a, i = s(e.leftShoulder) ? e.leftElbow - Yt * Math.max(0, -o) : e.leftElbow, l = s(e.rightShoulder) ? e.rightElbow + Yt * Math.max(0, o) : e.rightElbow;
120
+ const Wt = 24, Gt = 4, Jt = 28, Fe = 40;
121
+ function Ne(t, e = et, n = 1) {
122
+ const o = Math.sin(t * Math.PI * 2) * n, s = Math.cos(t * Math.PI * 2) * n, r = (a) => a <= Fe, h = (a) => r(a) ? 22 * o : a, i = r(e.leftShoulder) ? e.leftElbow - Jt * Math.max(0, -o) : e.leftElbow, l = r(e.rightShoulder) ? e.rightElbow + Jt * Math.max(0, o) : e.rightElbow;
123
123
  return {
124
124
  ...e,
125
125
  // Lean into the walk, and keep the head a little more level than the body.
126
- lean: e.lean + _t * n,
127
- headTilt: e.headTilt - _t * 0.5 * n,
126
+ lean: e.lean + Gt * n,
127
+ headTilt: e.headTilt - Gt * 0.5 * n,
128
128
  leftElbow: i,
129
129
  rightElbow: l,
130
130
  // Left foot forward while swing > 0, right foot back; then the other way.
131
- leftHip: -St * o,
132
- rightHip: -St * o,
131
+ leftHip: -Wt * o,
132
+ rightHip: -Wt * o,
133
133
  // The leg swinging forward lifts, its shin trailing backward (-x). A positive
134
134
  // knee folds toward the centre, which is backward only for the right leg.
135
- leftKnee: -30 * Math.max(0, r),
136
- rightKnee: 30 * Math.max(0, -r),
135
+ leftKnee: -30 * Math.max(0, s),
136
+ rightKnee: 30 * Math.max(0, -s),
137
137
  // Arms swing against the legs: left arm back while the left foot is forward.
138
138
  leftShoulder: h(e.leftShoulder),
139
139
  rightShoulder: h(e.rightShoulder)
140
140
  };
141
141
  }
142
- function Sn(t, e = 1) {
143
- return 4 * ((Pt + ct) * t) * Math.sin(St * e * Math.PI / 180);
142
+ function go(t, e = 1) {
143
+ return 4 * (($t + wt) * t) * Math.sin(Wt * e * Math.PI / 180);
144
144
  }
145
- function xe(t) {
145
+ function Ce(t) {
146
146
  const e = Math.abs(Math.sin(t / 65)), n = 0.55 + 0.45 * Math.sin(t / 310);
147
147
  return e * n;
148
148
  }
149
- const Zt = 0.12, $t = 0.46, Se = 1 - 2 * Zt, Pe = 0.1, Te = 0.21, ve = 0.19, Pt = 0.24, ct = 0.22, Qt = 0.12, We = 0.14, Vt = 0.33, Bt = 0.7, Rt = 0.3, Oe = 0.35, Ie = [1.7, 1.05], Ae = [1.3, 0.75], Lt = [1.45, 0.85], He = [1.15, 0.75], Ft = 0.06, _e = 0.7, Ye = 0.65, $e = 0.3, Be = 0.02, Re = 0.012, Le = 12, Fe = 0.25, ot = 90, Ne = 0.25, Ce = 0.01, J = (t) => Math.min(1, Math.max(0, t ?? 0));
150
- function Pn(t, e = 1) {
151
- return ct * t * e;
149
+ const de = 0.12, zt = 0.46, Ue = 1 - 2 * de, Xe = 0.1, De = 0.21, qe = 0.19, $t = 0.24, wt = 0.22, ue = 0.12, Ke = 0.14, ge = 0.33, jt = 0.7, Zt = 0.3, Ge = 0.35, Je = [1.7, 1.05], ze = [1.3, 0.75], Qt = [1.45, 0.85], je = [1.15, 0.75], Vt = 0.06, Ze = 0.7, Qe = 0.65, Ve = 0.3, tn = 0.02, en = 0.012, nn = 12, on = 0.25, ct = 90, sn = 0.25, rn = 0.01, V = (t) => Math.min(1, Math.max(0, t ?? 0));
150
+ function yo(t, e = 1) {
151
+ return wt * t * e;
152
152
  }
153
- const Tt = -0.12, te = 0.4, C = (t) => t * Math.PI / 180, Xe = (t, e) => ({ x: e * Math.sin(C(t)), y: Math.cos(C(t)) }), ee = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), ne = (t, e, n, o) => t - 0.3 * e - n * 0.14 * e - Math.max(0, o - 1) * 0.12 * e;
154
- function qe(t, e, n, o, r, s) {
155
- const h = Math.max(1, Math.min(s * 0.6, We * n)), i = J(e.turn), l = (Qt + Vt * i) * n, a = o + Tt * n, c = l + e.lookX * 0.08 * n, g = e.lookY * 0.07 * n, y = [
153
+ const Rt = -0.12, ye = 0.4, D = (t) => t * Math.PI / 180, ln = (t, e) => ({ x: e * Math.sin(D(t)), y: Math.cos(D(t)) }), me = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), pe = (t, e, n, o) => t - 0.3 * e - n * 0.14 * e - Math.max(0, o - 1) * 0.12 * e;
154
+ function hn(t, e, n, o, s, r) {
155
+ const h = Math.max(1, Math.min(r * 0.6, Ke * n)), i = V(e.turn), l = (ue + ge * i) * n, a = o + Rt * n, f = l + e.lookX * 0.08 * n, g = e.lookY * 0.07 * n, m = [
156
156
  // The left eye is on the far side; turning closes it up more than the near one.
157
- { x: -0.34 * n * (1 - Bt * i), squeeze: 1 - Bt * i, open: e.leftEye, brow: e.leftBrow, side: -1 },
158
- { x: 0.34 * n * (1 - Rt * i), squeeze: 1 - Rt * i, open: e.rightEye, brow: e.rightBrow, side: 1 }
157
+ { x: -0.34 * n * (1 - jt * i), squeeze: 1 - jt * i, open: e.leftEye, brow: e.leftBrow, side: -1 },
158
+ { x: 0.34 * n * (1 - Zt * i), squeeze: 1 - Zt * i, open: e.rightEye, brow: e.rightBrow, side: 1 }
159
159
  ];
160
- t.fillStyle = r, t.strokeStyle = r, t.lineWidth = h;
161
- for (const u of y) {
162
- const k = ee(u.open, e.blink);
163
- if (k < 0.2) {
164
- const P = e.smile > 0.5 ? -0.12 * n : 0.06 * n;
165
- t.beginPath(), t.moveTo(u.x + l - 0.12 * n, a), t.quadraticCurveTo(u.x + l, a + P, u.x + l + 0.12 * n, a), t.stroke();
160
+ t.fillStyle = s, t.strokeStyle = s, t.lineWidth = h;
161
+ for (const p of m) {
162
+ const x = me(p.open, e.blink);
163
+ if (x < 0.2) {
164
+ const T = e.smile > 0.5 ? -0.12 * n : 0.06 * n;
165
+ t.beginPath(), t.moveTo(p.x + l - 0.12 * n, a), t.quadraticCurveTo(p.x + l, a + T, p.x + l + 0.12 * n, a), t.stroke();
166
166
  } else {
167
- if (k > 1.2) {
168
- const S = 0.13 * n * k;
169
- t.beginPath(), t.ellipse(u.x + l, a, S * 0.85, S, 0, 0, Math.PI * 2), t.fillStyle = "#ffffff", t.fill(), t.stroke(), t.fillStyle = r;
167
+ if (x > 1.2) {
168
+ const P = 0.13 * n * x;
169
+ t.beginPath(), t.ellipse(p.x + l, a, P * 0.85, P, 0, 0, Math.PI * 2), t.fillStyle = "#ffffff", t.fill(), t.stroke(), t.fillStyle = s;
170
170
  }
171
- const P = k > 1.2 ? 0.075 * n : 0.1 * n;
172
- t.beginPath(), t.ellipse(u.x + c, a + g, P, P * 1.1 * Math.min(k, 1), 0, 0, Math.PI * 2), t.fill();
171
+ const T = x > 1.2 ? 0.075 * n : 0.1 * n;
172
+ t.beginPath(), t.ellipse(p.x + f, a + g, T, T * 1.1 * Math.min(x, 1), 0, 0, Math.PI * 2), t.fill();
173
173
  }
174
- const E = ne(a, n, u.brow, k), b = u.x + l - u.side * 0.13 * n * u.squeeze, M = u.x + l + u.side * 0.13 * n * u.squeeze;
174
+ const E = pe(a, n, p.brow, x), b = p.x + l - p.side * 0.13 * n * p.squeeze, M = p.x + l + p.side * 0.13 * n * p.squeeze;
175
175
  t.beginPath(), t.moveTo(M, E), t.lineTo(b, E - e.browTilt * 0.1 * n), t.stroke();
176
176
  }
177
- const f = o + te * n, d = 0.25 * n * Math.max(0.3, e.mouthWidth) * (1 - Oe * i), w = Math.min(1, Math.max(0, e.mouth));
178
- if (t.beginPath(), w <= 0.05) {
179
- t.moveTo(l - d, f), t.quadraticCurveTo(l, f + e.smile * 0.25 * n, l + d, f), t.stroke();
177
+ const c = o + ye * n, d = 0.25 * n * Math.max(0.3, e.mouthWidth) * (1 - Ge * i), u = Math.min(1, Math.max(0, e.mouth));
178
+ if (t.beginPath(), u <= 0.05) {
179
+ t.moveTo(l - d, c), t.quadraticCurveTo(l, c + e.smile * 0.25 * n, l + d, c), t.stroke();
180
180
  return;
181
181
  }
182
- const m = 0.3 * n * w;
183
- e.smile > 0.3 ? (t.moveTo(l - d, f - 0.05 * n), t.lineTo(l + d, f - 0.05 * n), t.quadraticCurveTo(l, f + m * 2, l - d, f - 0.05 * n)) : e.smile < -0.3 ? (t.moveTo(l - d, f + m * 0.6), t.lineTo(l + d, f + m * 0.6), t.quadraticCurveTo(l, f - m * 1.4, l - d, f + m * 0.6)) : t.ellipse(l, f, d * 0.8, m, 0, 0, Math.PI * 2), t.fill();
182
+ const y = 0.3 * n * u;
183
+ e.smile > 0.3 ? (t.moveTo(l - d, c - 0.05 * n), t.lineTo(l + d, c - 0.05 * n), t.quadraticCurveTo(l, c + y * 2, l - d, c - 0.05 * n)) : e.smile < -0.3 ? (t.moveTo(l - d, c + y * 0.6), t.lineTo(l + d, c + y * 0.6), t.quadraticCurveTo(l, c - y * 1.4, l - d, c + y * 0.6)) : t.ellipse(l, c, d * 0.8, y, 0, 0, Math.PI * 2), t.fill();
184
184
  }
185
- function oe(t, e) {
186
- const n = e.height ?? 300, o = Math.min(3, Math.max(0.3, t.stretch ?? 1)), r = Math.sqrt(o), s = (e.headSize ?? 2 * Zt) / 2, h = e.headSize === void 0 ? Se : 1 - 2 * s, i = s * n, l = J(t.sit), a = t.leftHip + (-ot - t.leftHip) * l, c = t.leftKnee + (-ot - t.leftKnee) * l, g = t.rightHip + (ot - t.rightHip) * l, y = t.rightKnee + (ot - t.rightKnee) * l, f = e.classic === !0, d = J(t.turn), w = (x, p, T) => {
187
- const v = C(p - T) / 2, O = d + (1 - d) * x * _e;
188
- return f ? { x: 0, y: 0 } : { x: Math.cos(v) * Ft * O, y: Math.abs(Math.sin(v)) * Ft };
185
+ function we(t, e) {
186
+ const n = e.height ?? 300, o = Math.min(3, Math.max(0.3, t.stretch ?? 1)), s = Math.sqrt(o), r = (e.headSize ?? 2 * de) / 2, h = e.headSize === void 0 ? Ue : 1 - 2 * r, i = r * n, l = V(t.sit), a = t.leftHip + (-ct - t.leftHip) * l, f = t.leftKnee + (-ct - t.leftKnee) * l, g = t.rightHip + (ct - t.rightHip) * l, m = t.rightKnee + (ct - t.rightKnee) * l, c = e.classic === !0, d = V(t.turn), u = (k, w, S) => {
187
+ const v = D(w - S) / 2, A = d + (1 - d) * k * Ze;
188
+ return c ? { x: 0, y: 0 } : { x: Math.cos(v) * Vt * A, y: Math.abs(Math.sin(v)) * Vt };
189
189
  };
190
- let m = 0;
191
- if (l > 0 || !f) {
192
- const x = (v, O, A) => Pt * Math.cos(C(O)) + ct * Math.cos(C(O - A)) + w(v, O, A).y, p = Math.max(x(-1, a, c), x(1, g, y)), T = f ? Math.min(1, l / Ne) : 1;
193
- m = ($t - p) * T * n * o;
190
+ let y = 0;
191
+ if (l > 0 || !c) {
192
+ const k = (v, A, W) => $t * Math.cos(D(A)) + wt * Math.cos(D(A - W)) + u(v, A, W).y, w = Math.max(k(-1, a, f), k(1, g, m)), S = c ? Math.min(1, l / sn) : 1;
193
+ y = (zt - w) * S * n * o;
194
194
  }
195
- const u = -$t * n * o + m, k = -h * n * o + m, E = f ? 0 : (Be * J(t.turn) + Re * l) * n * o, b = E === 0 ? [{ x: 0, y: u }, { x: 0, y: k }] : z({ x: 0, y: u }, { x: -E, y: (u + k) / 2 }, { x: 0, y: k }, 1, 8), M = k + Pe * n * o, P = (e.shoulderWidth ?? 0) * n * Math.cos(d * Math.PI / 2), S = (x, p, T, v, O) => {
196
- const A = Xe(T, v);
197
- return { x: x + A.x * O * n, y: p + A.y * O * n };
198
- }, W = (x, p, T) => {
199
- const v = S(0, u, p, x, Pt * o);
200
- return { root: { x: 0, y: u }, joint: v, end: S(v.x, v.y, p - T, x, ct * o) };
201
- }, H = (x, p, T) => {
202
- const v = { x: x * P, y: M }, O = S(v.x, v.y, p, x, Te * r);
203
- return { root: v, joint: O, end: S(O.x, O.y, p + T, x, ve * r) };
204
- }, Y = { left: W(-1, a, c), right: W(1, g, y) }, I = (x, p, T, v) => {
205
- const O = w(x, T, v);
206
- return { x: p.end.x + O.x * n * o, y: p.end.y + O.y * n * o };
195
+ const p = -zt * n * o + y, x = -h * n * o + y, E = c ? 0 : (tn * V(t.turn) + en * l) * n * o, b = E === 0 ? [{ x: 0, y: p }, { x: 0, y: x }] : tt({ x: 0, y: p }, { x: -E, y: (p + x) / 2 }, { x: 0, y: x }, 1, 8), M = x + Xe * n * o, T = (e.shoulderWidth ?? 0) * n * Math.cos(d * Math.PI / 2), P = (k, w, S, v, A) => {
196
+ const W = ln(S, v);
197
+ return { x: k + W.x * A * n, y: w + W.y * A * n };
198
+ }, I = (k, w, S) => {
199
+ const v = P(0, p, w, k, $t * o);
200
+ return { root: { x: 0, y: p }, joint: v, end: P(v.x, v.y, w - S, k, wt * o) };
201
+ }, O = (k, w, S) => {
202
+ const v = { x: k * T, y: M }, A = P(v.x, v.y, w, k, De * s);
203
+ return { root: v, joint: A, end: P(A.x, A.y, w + S, k, qe * s) };
204
+ }, H = { left: I(-1, a, f), right: I(1, g, m) }, _ = (k, w, S, v) => {
205
+ const A = u(k, S, v);
206
+ return { x: w.end.x + A.x * n * o, y: w.end.y + A.y * n * o };
207
207
  };
208
208
  return {
209
209
  height: n,
210
210
  facing: (e.facing ?? 1) < 0 ? -1 : 1,
211
211
  stretch: o,
212
212
  lineWidth: e.lineWidth ?? n * 0.025,
213
- rubber: Math.min(1, Math.max(f ? 0 : $e, e.rubber ?? 0)),
213
+ rubber: Math.min(1, Math.max(c ? 0 : Ve, e.rubber ?? 0)),
214
214
  r: i,
215
215
  // The head keeps its area: taller and narrower when stretched.
216
216
  headRx: i / Math.sqrt(o),
217
217
  headRy: i * Math.sqrt(o),
218
- hipY: u,
219
- neckY: k,
220
- drop: m,
221
- lean: f ? t.lean : t.lean + Le * Math.sin(Math.PI * l),
222
- classic: f,
223
- legs: Y,
224
- toes: { left: I(-1, Y.left, a, c), right: I(1, Y.right, g, y) },
218
+ hipY: p,
219
+ neckY: x,
220
+ drop: y,
221
+ lean: c ? t.lean : t.lean + nn * Math.sin(Math.PI * l),
222
+ classic: c,
223
+ legs: H,
224
+ toes: { left: _(-1, H.left, a, f), right: _(1, H.right, g, m) },
225
225
  spine: b,
226
226
  arms: {
227
- left: H(-1, t.leftShoulder, t.leftElbow),
228
- right: H(1, t.rightShoulder, t.rightElbow)
227
+ left: O(-1, t.leftShoulder, t.leftElbow),
228
+ right: O(1, t.rightShoulder, t.rightElbow)
229
229
  }
230
230
  };
231
231
  }
232
- const V = (t, e) => e === 0 ? [t.root, t.joint, t.end] : z(t.root, t.joint, t.end, e);
233
- function vt(t, e, n) {
234
- const o = Math.cos(n), r = Math.sin(n), s = t.x - e.x, h = t.y - e.y;
235
- return { x: e.x + s * o - h * r, y: e.y + s * r + h * o };
232
+ const rt = (t, e) => e === 0 ? [t.root, t.joint, t.end] : tt(t.root, t.joint, t.end, e);
233
+ function Bt(t, e, n) {
234
+ const o = Math.cos(n), s = Math.sin(n), r = t.x - e.x, h = t.y - e.y;
235
+ return { x: e.x + r * o - h * s, y: e.y + r * s + h * o };
236
236
  }
237
- function se(t, e) {
238
- const n = C(t.lean), o = C(e.headTilt), r = { x: 0, y: t.hipY }, s = (u) => ({ x: t.facing * u.x, y: u.y }), h = (u) => s(vt(u, r, n)), i = (u) => h(vt({ x: u.x, y: u.y + t.neckY }, { x: 0, y: t.neckY }, o)), l = V(t.arms.left, t.rubber).map(h), a = V(t.arms.right, t.rubber).map(h), c = (u) => {
239
- const [k, E] = u.slice(-2);
240
- return Math.atan2(E.y - k.y, E.x - k.x);
237
+ function be(t, e) {
238
+ const n = D(t.lean), o = D(e.headTilt), s = { x: 0, y: t.hipY }, r = (p) => ({ x: t.facing * p.x, y: p.y }), h = (p) => r(Bt(p, s, n)), i = (p) => h(Bt({ x: p.x, y: p.y + t.neckY }, { x: 0, y: t.neckY }, o)), l = rt(t.arms.left, t.rubber).map(h), a = rt(t.arms.right, t.rubber).map(h), f = (p) => {
239
+ const [x, E] = p.slice(-2);
240
+ return Math.atan2(E.y - x.y, E.x - x.x);
241
241
  };
242
242
  let g = 1 / 0;
243
- for (const [u, k] of [
243
+ for (const [p, x] of [
244
244
  [e.leftBrow, e.leftEye],
245
245
  [e.rightBrow, e.rightEye]
246
246
  ]) {
247
- const E = ne(Tt, 1, u, ee(k, e.blink));
247
+ const E = pe(Rt, 1, p, me(x, e.blink));
248
248
  g = Math.min(g, E, E - e.browTilt * 0.1);
249
249
  }
250
- const y = { left: s(t.legs.left.end), right: s(t.legs.right.end) }, f = { left: s(t.toes.left), right: s(t.toes.right) }, d = { left: Math.max(y.left.y, f.left.y), right: Math.max(y.right.y, f.right.y) }, w = Math.max(d.left, d.right), m = Ce * t.height;
250
+ const m = { left: r(t.legs.left.end), right: r(t.legs.right.end) }, c = { left: r(t.toes.left), right: r(t.toes.right) }, d = { left: Math.max(m.left.y, c.left.y), right: Math.max(m.right.y, c.right.y) }, u = Math.max(d.left, d.right), y = rn * t.height;
251
251
  return {
252
252
  facing: t.facing,
253
253
  height: t.height,
254
254
  stretch: t.stretch,
255
255
  lineWidth: t.lineWidth,
256
- hip: r,
256
+ hip: s,
257
257
  neck: h({ x: 0, y: t.neckY }),
258
258
  shoulders: { left: h(t.arms.left.root), right: h(t.arms.right.root) },
259
259
  elbows: { left: h(t.arms.left.joint), right: h(t.arms.right.joint) },
260
260
  hands: { left: h(t.arms.left.end), right: h(t.arms.right.end) },
261
- knees: { left: s(t.legs.left.joint), right: s(t.legs.right.joint) },
262
- feet: y,
263
- toes: f,
264
- feetY: w,
265
- grounded: { left: d.left >= w - m, right: d.right >= w - m },
266
- handAngle: { left: c(l), right: c(a) },
261
+ knees: { left: r(t.legs.left.joint), right: r(t.legs.right.joint) },
262
+ feet: m,
263
+ toes: c,
264
+ feetY: u,
265
+ grounded: { left: d.left >= u - y, right: d.right >= u - y },
266
+ handAngle: { left: f(l), right: f(a) },
267
267
  limbs: {
268
268
  leftArm: l,
269
269
  rightArm: a,
270
- leftLeg: V(t.legs.left, t.rubber).map(s),
271
- rightLeg: V(t.legs.right, t.rubber).map(s),
270
+ leftLeg: rt(t.legs.left, t.rubber).map(r),
271
+ rightLeg: rt(t.legs.right, t.rubber).map(r),
272
272
  spine: t.spine.map(h)
273
273
  },
274
274
  head: {
@@ -277,31 +277,31 @@ function se(t, e) {
277
277
  ry: t.headRy,
278
278
  // Mirroring a turn reverses it.
279
279
  angle: t.facing * (n + o),
280
- eyeY: Tt,
280
+ eyeY: Rt,
281
281
  browTopY: g,
282
- mouthY: te,
283
- faceX: t.facing * (Qt + Vt * J(e.turn))
282
+ mouthY: ye,
283
+ faceX: t.facing * (ue + ge * V(e.turn))
284
284
  }
285
285
  };
286
286
  }
287
- function Ue(t, e = {}) {
288
- return se(oe(t, e), t);
287
+ function an(t, e = {}) {
288
+ return be(we(t, e), t);
289
289
  }
290
- function Tn(t, e, n) {
291
- return vt({ x: t.center.x + e * t.rx, y: t.center.y + n * t.ry }, t.center, t.angle);
290
+ function mo(t, e, n) {
291
+ return Bt({ x: t.center.x + e * t.rx, y: t.center.y + n * t.ry }, t.center, t.angle);
292
292
  }
293
- function Ke(t, e, n) {
294
- const o = (s) => ({ x: s.x + e, y: s.y + n }), r = (s) => ({ left: o(s.left), right: o(s.right) });
293
+ function cn(t, e, n) {
294
+ const o = (r) => ({ x: r.x + e, y: r.y + n }), s = (r) => ({ left: o(r.left), right: o(r.right) });
295
295
  return {
296
296
  ...t,
297
297
  hip: o(t.hip),
298
298
  neck: o(t.neck),
299
- shoulders: r(t.shoulders),
300
- elbows: r(t.elbows),
301
- hands: r(t.hands),
302
- knees: r(t.knees),
303
- feet: r(t.feet),
304
- toes: r(t.toes),
299
+ shoulders: s(t.shoulders),
300
+ elbows: s(t.elbows),
301
+ hands: s(t.hands),
302
+ knees: s(t.knees),
303
+ feet: s(t.feet),
304
+ toes: s(t.toes),
305
305
  feetY: t.feetY + n,
306
306
  grounded: { ...t.grounded },
307
307
  handAngle: { ...t.handAngle },
@@ -315,182 +315,628 @@ function Ke(t, e, n) {
315
315
  head: { ...t.head, center: o(t.head.center) }
316
316
  };
317
317
  }
318
- function De(t, e, n = {}, o = 0) {
319
- const r = oe(e, n), s = n.color ?? "#1e293b", h = n.layers ?? {}, i = n.layers ? se(r, e) : void 0, l = n.sketch ? xt(t, n.sketch, o) : void 0, a = n.sketch && n.layers ? xt(t, n.sketch, o) : void 0, c = (b) => {
318
+ function fn(t, e, n = {}, o = 0) {
319
+ const s = we(e, n), r = n.color ?? "#1e293b", h = n.layers ?? {}, i = n.layers ? be(s, e) : void 0, l = n.sketch ? Ht(t, n.sketch, o) : void 0, a = n.sketch && n.layers ? Ht(t, n.sketch, o) : void 0, f = (b) => {
320
320
  t.save(), b(), t.restore();
321
321
  }, g = (b) => {
322
- b && i && c(() => b(t, i, o, a));
323
- }, y = () => t.scale(r.facing, 1), f = () => {
324
- y(), t.translate(0, r.hipY), t.rotate(C(r.lean)), t.translate(0, -r.hipY);
325
- }, d = (b, M, P) => {
322
+ b && i && f(() => b(t, i, o, a));
323
+ }, m = () => t.scale(s.facing, 1), c = () => {
324
+ m(), t.translate(0, s.hipY), t.rotate(D(s.lean)), t.translate(0, -s.hipY);
325
+ }, d = (b, M, T) => {
326
326
  if (l) return M ? l.curve(b) : l.line(b);
327
- if (r.classic) {
327
+ if (s.classic) {
328
328
  t.beginPath(), t.moveTo(b[0].x, b[0].y);
329
- for (const S of b.slice(1)) t.lineTo(S.x, S.y);
329
+ for (const P of b.slice(1)) t.lineTo(P.x, P.y);
330
330
  t.stroke();
331
331
  return;
332
332
  }
333
- Jt(t, b, P[0] * r.lineWidth, P[1] * r.lineWidth);
334
- }, w = (b, M) => d(V(b, r.rubber), r.rubber > 0, M), m = (b) => {
335
- r.classic || d([r.legs[b].end, r.toes[b]], !1, He);
336
- }, u = (b) => {
337
- if (r.classic || l) return;
338
- const M = r.arms[b].end;
339
- t.beginPath(), t.arc(M.x, M.y, Ye * r.lineWidth, 0, Math.PI * 2), t.fill();
333
+ Xt(t, b, T[0] * s.lineWidth, T[1] * s.lineWidth);
334
+ }, u = (b, M) => d(rt(b, s.rubber), s.rubber > 0, M), y = (b) => {
335
+ s.classic || d([s.legs[b].end, s.toes[b]], !1, je);
336
+ }, p = (b) => {
337
+ if (s.classic || l) return;
338
+ const M = s.arms[b].end;
339
+ t.beginPath(), t.arc(M.x, M.y, Qe * s.lineWidth, 0, Math.PI * 2), t.fill();
340
340
  };
341
- t.save(), t.strokeStyle = s, t.fillStyle = s, t.lineWidth = r.lineWidth, t.lineCap = "round", t.lineJoin = "round";
342
- const k = (b) => {
343
- c(() => {
344
- f(), w(r.arms[b], Ae), u(b);
341
+ t.save(), t.strokeStyle = r, t.fillStyle = r, t.lineWidth = s.lineWidth, t.lineCap = "round", t.lineJoin = "round";
342
+ const x = (b) => {
343
+ f(() => {
344
+ c(), u(s.arms[b], ze), p(b);
345
345
  });
346
346
  const M = h.sleeve;
347
- M && i && c(() => M(t, i, b, o, a));
348
- }, E = J(e.turn) > Fe;
349
- g(h.behind), c(() => {
350
- y(), w(r.legs.left, Lt), m("left"), w(r.legs.right, Lt), m("right");
351
- }), E && k("left"), c(() => {
352
- f(), d(r.spine, r.spine.length > 2, Ie);
353
- const { left: b, right: M } = { left: r.arms.left.root, right: r.arms.right.root };
347
+ M && i && f(() => M(t, i, b, o, a));
348
+ }, E = V(e.turn) > on;
349
+ g(h.behind), f(() => {
350
+ m(), u(s.legs.left, Qt), y("left"), u(s.legs.right, Qt), y("right");
351
+ }), E && x("left"), f(() => {
352
+ c(), d(s.spine, s.spine.length > 2, Je);
353
+ const { left: b, right: M } = { left: s.arms.left.root, right: s.arms.right.root };
354
354
  if (b.x !== M.x)
355
- if (r.classic) d([b, M], !1, [1, 1]);
355
+ if (s.classic) d([b, M], !1, [1, 1]);
356
356
  else {
357
- const P = { x: (b.x + M.x) / 2, y: b.y - 0.3 * Math.abs(M.x - b.x) };
358
- d(z(b, P, M, 1, 8), !0, [1.1, 1.1]);
357
+ const T = { x: (b.x + M.x) / 2, y: b.y - 0.3 * Math.abs(M.x - b.x) };
358
+ d(tt(b, T, M, 1, 8), !0, [1.1, 1.1]);
359
359
  }
360
- }), g(h.body), E || k("left"), k("right"), g(h.behindHead), c(() => {
361
- f(), t.translate(0, r.neckY), t.rotate(C(e.headTilt));
362
- const b = -r.headRy;
363
- t.beginPath(), t.ellipse(0, b, r.headRx, r.headRy, 0, 0, Math.PI * 2);
360
+ }), g(h.body), E || x("left"), x("right"), g(h.behindHead), f(() => {
361
+ c(), t.translate(0, s.neckY), t.rotate(D(e.headTilt));
362
+ const b = -s.headRy;
363
+ t.beginPath(), t.ellipse(0, b, s.headRx, s.headRy, 0, 0, Math.PI * 2);
364
364
  const M = n.headFill ?? "#ffffff";
365
365
  if (M !== "none" && (t.fillStyle = M, t.fill()), l) {
366
- l.ellipse(0, b, r.headRx, r.headRy);
367
- const P = l.nudge();
368
- t.translate(P.x, P.y);
366
+ l.ellipse(0, b, s.headRx, s.headRy);
367
+ const T = l.nudge();
368
+ t.translate(T.x, T.y);
369
369
  } else
370
370
  t.stroke();
371
- t.translate(0, b), t.scale(r.headRx / r.r, r.headRy / r.r), qe(t, e, r.r, 0, s, r.lineWidth);
372
- }), g(h.overHead), g(h.front), t.restore(), n.label && (t.save(), t.fillStyle = s, t.font = n.labelFont ?? `700 ${Math.round(r.height * 0.11)}px sans-serif`, t.textAlign = "center", t.textBaseline = "bottom", t.fillText(n.label, 0, -r.height * r.stretch - 0.04 * r.height + r.drop), t.restore());
371
+ t.translate(0, b), t.scale(s.headRx / s.r, s.headRy / s.r), hn(t, e, s.r, 0, r, s.lineWidth);
372
+ }), g(h.overHead), g(h.front), t.restore(), n.label && (t.save(), t.fillStyle = r, t.font = n.labelFont ?? `700 ${Math.round(s.height * 0.11)}px sans-serif`, t.textAlign = "center", t.textBaseline = "bottom", t.fillText(n.label, 0, -s.height * s.stretch - 0.04 * s.height + s.drop), t.restore());
373
373
  }
374
- function re(t, e) {
374
+ function Me(t, e) {
375
375
  const n = { ...t };
376
- let o = t.walking > 0 ? Me(n, Ee(t.walk, n), t.walking) : n;
377
- return t.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, t.talk * xe(e)) }), o;
376
+ let o = t.walking > 0 ? Le(n, Ne(t.walk, n), t.walking) : n;
377
+ return t.talk > 0 && (o = { ...o, mouth: Math.max(o.mouth, t.talk * Ce(e)) }), o;
378
378
  }
379
- function vn(t) {
380
- const e = t.style ?? {}, n = e.height ?? 300, o = n * 0.8, r = { ...B(t.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: e.rubber ?? 0 };
379
+ function po(t) {
380
+ const e = t.style ?? {}, n = e.height ?? 300, o = n * 0.8, s = { ...L(t.pose ?? {}), walk: 0, walking: 0, talk: 0, rubber: e.rubber ?? 0 };
381
381
  return {
382
382
  type: "custom",
383
383
  x: t.x - o / 2,
384
384
  y: t.y - n,
385
385
  width: o,
386
386
  height: n,
387
- props: { ...r },
387
+ props: { ...s },
388
388
  figureStyle: e,
389
- draw(s, h, i) {
389
+ draw(r, h, i) {
390
390
  const l = h.props;
391
- s.translate(o / 2, n), De(s, re(l, i), { ...e, rubber: l.rubber }, i);
391
+ r.translate(o / 2, n), fn(r, Me(l, i), { ...e, rubber: l.rubber }, i);
392
392
  }
393
393
  };
394
394
  }
395
- function Wn(t, e, n) {
395
+ function wo(t, e, n) {
396
396
  const o = t.figureStyle;
397
397
  if (!o) throw new Error("stickFigureAt: the target was not made by stickFigureTarget");
398
- const r = { ...t.props };
399
- let s = 0, h = 0;
400
- for (const [a, c] of e.state?.values.get(n) ?? [])
401
- typeof c == "number" && (a === "x" || a === "motionPathX" ? s = c : a === "y" || a === "motionPathY" ? h = c : a in r && (r[a] = c));
402
- const i = re(r, e.time), l = Ue(i, { ...o, rubber: r.rubber });
403
- return { pose: i, joints: Ke(l, t.x + s + t.width / 2, t.y + h + t.height) };
404
- }
405
- function On(t, e) {
398
+ const s = { ...t.props };
399
+ let r = 0, h = 0;
400
+ for (const [a, f] of e.state?.values.get(n) ?? [])
401
+ typeof f == "number" && (a === "x" || a === "motionPathX" ? r = f : a === "y" || a === "motionPathY" ? h = f : a in s && (s[a] = f));
402
+ const i = Me(s, e.time), l = an(i, { ...o, rubber: s.rubber });
403
+ return { pose: i, joints: cn(l, t.x + r + t.width / 2, t.y + h + t.height) };
404
+ }
405
+ function bo(t, e) {
406
406
  const n = [];
407
- return e.forEach((o, r) => {
408
- const s = r === 0 ? G : n[r - 1], h = typeof o.pose == "string" ? be[o.pose] : { ...s, ...o.pose };
409
- n.push(o.expression ? we(h, o.expression) : h);
410
- }), Gt.filter((o) => n.some((r) => r[o] !== G[o])).map((o) => ({
407
+ return e.forEach((o, s) => {
408
+ const r = s === 0 ? et : n[s - 1], h = typeof o.pose == "string" ? Ye[o.pose] : { ...r, ...o.pose };
409
+ n.push(o.expression ? Be(h, o.expression) : h);
410
+ }), fe.filter((o) => n.some((s) => s[o] !== et[o])).map((o) => ({
411
411
  id: `${t}-${o}`,
412
412
  target: t,
413
413
  property: o,
414
- keyframes: e.map((r, s) => ({
415
- time: r.time,
416
- value: n[s][o],
417
- ...r.easing ? { easing: r.easing } : {}
414
+ keyframes: e.map((s, r) => ({
415
+ time: s.time,
416
+ value: n[r][o],
417
+ ...s.easing ? { easing: s.easing } : {}
418
418
  }))
419
419
  }));
420
420
  }
421
- function je(t, e, n = {}, o) {
422
- const r = n.length ?? 240, s = 9, h = 28, i = r - 22;
423
- t.save(), t.translate(e.x, e.y), t.rotate((n.angle ?? -30) * Math.PI / 180), t.fillStyle = n.color ?? "#f4c542", t.fillRect(h, -s, i - h, 2 * s), t.fillStyle = "#e8b4a0", t.fillRect(i, -s, r - i, 2 * s), t.fillStyle = "#f1dcbf", t.beginPath(), t.moveTo(0, 0), t.lineTo(h, -s), t.lineTo(h, s), t.closePath(), t.fill(), t.fillStyle = n.outline ?? "#2f2f33", t.beginPath(), t.moveTo(0, 0), t.lineTo(h * 0.35, -s * 0.35), t.lineTo(h * 0.35, s * 0.35), t.closePath(), t.fill(), t.strokeStyle = n.outline ?? "#2f2f33", t.lineWidth = 3, t.lineJoin = "round", t.lineCap = "round";
421
+ const dn = ["thumb", "index", "middle", "ring", "pinky"], kt = {
422
+ "thumb.curl": 0.15,
423
+ "thumb.across": 0.15,
424
+ "index.curl": 0.12,
425
+ "middle.curl": 0.16,
426
+ "ring.curl": 0.2,
427
+ "pinky.curl": 0.25,
428
+ spread: 0.25,
429
+ turn: 0,
430
+ bend: 0,
431
+ tilt: 0,
432
+ roll: 0
433
+ };
434
+ function R(t = {}) {
435
+ return { ...kt, ...t };
436
+ }
437
+ const B = (t, e, n, o, s) => ({
438
+ "thumb.curl": t,
439
+ "index.curl": e,
440
+ "middle.curl": n,
441
+ "ring.curl": o,
442
+ "pinky.curl": s
443
+ }), un = {
444
+ relaxed: kt,
445
+ open: R({ ...B(0, 0, 0, 0, 0), "thumb.across": 0, spread: 0.55 }),
446
+ spread: R({ ...B(0, 0, 0, 0, 0), "thumb.across": 0, spread: 1 }),
447
+ flat: R({ ...B(0, 0, 0, 0, 0), "thumb.across": 0.35, spread: 0 }),
448
+ fist: R({ ...B(0.7, 1, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
449
+ point: R({ ...B(0.75, 0, 1, 1, 1), "thumb.across": 0.9, spread: 0 }),
450
+ /** The fist on its side, knuckles toward the viewer, the thumb up */
451
+ thumbsUp: R({ ...B(0, 1, 1, 1, 1), "thumb.across": 0, spread: 0, roll: 70 }),
452
+ peace: R({ ...B(0.75, 0, 0, 1, 1), "thumb.across": 0.9, spread: 1 }),
453
+ ok: R({ ...B(0.12, 0.6, 0.1, 0.15, 0.2), "thumb.across": 0.55, spread: 0.6 }),
454
+ pinch: R({ ...B(0.1, 0.65, 0.75, 0.85, 0.9), "thumb.across": 0.55, spread: 0 }),
455
+ cupped: R({ ...B(0.25, 0.4, 0.4, 0.4, 0.4), "thumb.across": 0.4, spread: 0.05, turn: 2 }),
456
+ wave: R({ ...B(0, 0.05, 0.05, 0.1, 0.12), "thumb.across": 0, spread: 0.7, turn: 2 }),
457
+ /** Holding a pencil to write: thumb and middle finger pinch it, the index finger rests on top */
458
+ pencilGrip: R({ ...B(0.1, 0.6, 0.72, 0.88, 0.95), "thumb.across": 0.5, spread: 0, turn: 0.8, bend: 10 }),
459
+ /** Holding a handle, a cup or a bar: every finger wrapped round it */
460
+ hold: R({ ...B(0.5, 0.7, 0.72, 0.74, 0.76), "thumb.across": 0.75, spread: 0, turn: 1 })
461
+ };
462
+ function Mo(t, e, n) {
463
+ const o = { ...t };
464
+ for (const [s, r] of Object.entries(e)) {
465
+ const h = t[s] ?? r;
466
+ o[s] = h + (r - h) * n;
467
+ }
468
+ return o;
469
+ }
470
+ const gn = {
471
+ index: { knuckle: [-0.16, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.125, fan: -1 },
472
+ middle: { knuckle: [-0.055, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.13, fan: -0.2 },
473
+ ring: { knuckle: [0.05, 0.475, -0.02], bones: [0.2, 0.125, 0.1], width: 0.122, fan: 0.55 },
474
+ pinky: { knuckle: [0.15, 0.43, -0.02], bones: [0.16, 0.1, 0.085], width: 0.108, fan: 1.25 }
475
+ }, yn = {
476
+ index: { knuckle: [-0.14, 0.47, -0.02], bones: [0.2, 0.125, 0.1], width: 0.15, fan: -1 },
477
+ middle: { knuckle: [0, 0.49, -0.02], bones: [0.22, 0.135, 0.1], width: 0.155, fan: 0 },
478
+ pinky: { knuckle: [0.14, 0.45, -0.02], bones: [0.19, 0.115, 0.095], width: 0.145, fan: 1 }
479
+ }, C = {
480
+ base: [-0.11, 0.1, -0.05],
481
+ bones: [0.2, 0.15, 0.12],
482
+ widths: [0.2, 0.145, 0.135],
483
+ /** Where the thumb points with `across` 0 and 1 */
484
+ out: [-0.7, 0.68, -0.22],
485
+ across: [0.35, 0.5, -0.8]
486
+ }, mn = [82, 100, 62], pn = [48, 72], wn = 3, bn = 13, Mn = 0.035, kn = -0.075, xn = [
487
+ [-0.17, 0],
488
+ [-0.215, 0.12],
489
+ [-0.235, 0.26],
490
+ [-0.225, 0.4],
491
+ [-0.185, 0.49],
492
+ [-0.075, 0.525],
493
+ [0.05, 0.51],
494
+ [0.16, 0.465],
495
+ [0.215, 0.4],
496
+ [0.225, 0.26],
497
+ [0.2, 0.1],
498
+ [0.16, 0]
499
+ ], J = (t) => t * Math.PI / 180, Yt = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]], mt = (t, e) => [t[0] * e, t[1] * e, t[2] * e], Lt = (t, e) => [t[1] * e[2] - t[2] * e[1], t[2] * e[0] - t[0] * e[2], t[0] * e[1] - t[1] * e[0]], st = (t) => {
500
+ const e = Math.hypot(t[0], t[1], t[2]) || 1;
501
+ return [t[0] / e, t[1] / e, t[2] / e];
502
+ };
503
+ function j(t, e, n) {
504
+ const o = Math.cos(n), s = Math.sin(n), r = Lt(e, t), h = e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
505
+ return [
506
+ t[0] * o + r[0] * s + e[0] * h * (1 - o),
507
+ t[1] * o + r[1] * s + e[1] * h * (1 - o),
508
+ t[2] * o + r[2] * s + e[2] * h * (1 - o)
509
+ ];
510
+ }
511
+ const te = [1, 0, 0], ee = [0, 1, 0], lt = [0, 0, 1];
512
+ function En(t, e, n) {
513
+ const o = J(t.fan * (wn + bn * n)), s = [Math.sin(o), Math.cos(o), 0], r = [Math.cos(o), -Math.sin(o), 0], h = [t.knuckle];
514
+ let i = 0;
515
+ t.bones.forEach((f, g) => {
516
+ i += J(mn[g] * e), h.push(Yt(h[g], mt(j(s, r, -i), f)));
517
+ });
518
+ const l = j(lt, r, -i), a = h.map((f, g) => t.width * (1 - 0.14 * (g / (h.length - 1))));
519
+ return { joints: h, back: l, widths: a };
520
+ }
521
+ function Sn(t, e, n = 1, o = 1) {
522
+ const s = Math.min(1, Math.max(0, e)), r = st(Yt(mt(st(C.out), 1 - s), mt(st(C.across), s))), h = st(Lt(lt, r)), i = st(Lt(r, h)), l = [[C.base[0] * o, C.base[1], C.base[2]]];
523
+ let a = 0;
524
+ C.bones.forEach((m, c) => {
525
+ c > 0 && (a += J(pn[c - 1] * t)), l.push(Yt(l[c], mt(j(r, h, a), m)));
526
+ });
527
+ const f = j(i, h, a), g = [...C.widths, C.widths[C.widths.length - 1] * 0.92].map((m) => m * n);
528
+ return { joints: l, back: f, widths: g };
529
+ }
530
+ function Ft(t, e = {}) {
531
+ const n = { ...kt, ...t }, o = e.size ?? 100, s = e.side ?? "right", r = s === "left" ? -1 : 1, h = J(e.angle ?? 0), i = e.fingers === 4, l = Math.max(0.5, e.plump ?? 1), a = 1 + (l - 1) * 0.7, f = (k) => ({
532
+ ...k,
533
+ knuckle: [k.knuckle[0] * a, k.knuckle[1], k.knuckle[2]],
534
+ width: k.width * l
535
+ }), g = J(n.bend ?? 0), m = J(n.tilt ?? 0), c = J(90 * (n.turn ?? 0)), d = (k) => j(j(j(k, te, -g), lt, -m), ee, c), u = Math.cos(h), y = Math.sin(h), p = J(n.roll ?? 0), x = Math.cos(p), E = Math.sin(p), b = (k) => {
536
+ const w = k[0] * o, S = -k[1] * o, v = (w * x - S * E) * r, A = w * E + S * x;
537
+ return { x: v * u - A * y, y: v * y + A * u };
538
+ }, M = (k) => {
539
+ const w = b(k), S = Math.hypot(w.x, w.y);
540
+ return S > 1e-6 * o ? { x: w.x / S, y: w.y / S } : { x: 0, y: 0 };
541
+ }, T = {
542
+ thumb: Sn(n["thumb.curl"] ?? 0, n["thumb.across"] ?? 0, l, a)
543
+ }, P = i ? yn : gn;
544
+ for (const k of dn) {
545
+ const w = P[k];
546
+ w && (T[k] = En(f(w), n[`${k}.curl`] ?? 0, n.spread ?? 0));
547
+ }
548
+ const I = {};
549
+ for (const [k, w] of Object.entries(T)) {
550
+ const S = w.joints.map(d), v = d(w.back);
551
+ I[k] = {
552
+ points: S.map(b),
553
+ depths: S.map((A) => A[2] * o),
554
+ widths: w.widths.map((A) => A * o),
555
+ nail: v[2],
556
+ back: M(v)
557
+ };
558
+ }
559
+ const O = xn.flatMap(([k, w]) => [d([k * a, w, Mn]), d([k * a, w, kn])]), H = Tn(O.map(b)), _ = O.reduce((k, w) => k + w[2], 0) / O.length * o;
560
+ return {
561
+ size: o,
562
+ side: s,
563
+ wrist: { x: 0, y: 0 },
564
+ palm: H,
565
+ palmDepth: _,
566
+ palmFacing: -d(lt)[2],
567
+ fingers: I,
568
+ axes: { up: M(d(ee)), across: M(d(te)), out: M(d(lt)) },
569
+ curls: Object.fromEntries(Object.keys(I).map((k) => [k, n[`${k}.curl`] ?? 0]))
570
+ };
571
+ }
572
+ function Pn(t, e) {
573
+ const n = (s) => ({ x: s.x + e.x - t.wrist.x, y: s.y + e.y - t.wrist.y }), o = {};
574
+ for (const [s, r] of Object.entries(t.fingers))
575
+ o[s] = { ...r, points: r.points.map(n) };
576
+ return { ...t, wrist: n(t.wrist), palm: t.palm.map(n), fingers: o };
577
+ }
578
+ function Tn(t) {
579
+ const e = [...t].sort((r, h) => r.x - h.x || r.y - h.y);
580
+ if (e.length < 3) return e;
581
+ const n = (r, h, i) => (h.x - r.x) * (i.y - r.y) - (h.y - r.y) * (i.x - r.x), o = [];
582
+ for (const r of e) {
583
+ for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], r) <= 0; ) o.pop();
584
+ o.push(r);
585
+ }
586
+ const s = [];
587
+ for (const r of [...e].reverse()) {
588
+ for (; s.length >= 2 && n(s[s.length - 2], s[s.length - 1], r) <= 0; ) s.pop();
589
+ s.push(r);
590
+ }
591
+ return [...o.slice(0, -1), ...s.slice(0, -1)];
592
+ }
593
+ function ne(t, e, n, o, s, r = 0, h = 1, i = 40) {
594
+ const l = Math.cos(s), a = Math.sin(s);
595
+ return Array.from({ length: i + 1 }, (f, g) => {
596
+ const m = r + Math.PI * 2 * h * g / i, c = Math.cos(m) * n, d = Math.sin(m) * o;
597
+ return { x: t + c * l - d * a, y: e + c * a + d * l };
598
+ });
599
+ }
600
+ function ke(t, e) {
601
+ return e.look === "pencil" ? On(t, e) : vn(t, e.ink, e.look);
602
+ }
603
+ function bt(t, e, n = !1) {
604
+ t.beginPath(), t.moveTo(e[0].x, e[0].y);
605
+ for (const o of e.slice(1)) t.lineTo(o.x, o.y);
606
+ n && t.closePath();
607
+ }
608
+ function vn(t, e, n) {
609
+ const o = n === "silhouette", s = o ? 1.25 : 1;
610
+ return {
611
+ look: n,
612
+ ink: e,
613
+ limb(r, h, i) {
614
+ t.fillStyle = e, Xt(t, r, h * s, i * s);
615
+ },
616
+ line(r, h) {
617
+ r.length < 2 || (t.strokeStyle = e, t.lineWidth = h * s, t.lineCap = "round", t.lineJoin = "round", bt(t, r), t.stroke());
618
+ },
619
+ shape(r, h, i) {
620
+ bt(t, r, !0), (h !== null || o) && (t.fillStyle = o ? e : h, t.fill()), !(i <= 0) && (t.strokeStyle = e, t.lineWidth = i * s, t.lineJoin = "round", t.stroke());
621
+ },
622
+ ellipse(r, h, i, l, a, f, g) {
623
+ t.beginPath(), t.ellipse(r, h, i, l, a, 0, Math.PI * 2), (f !== null || o) && (t.fillStyle = o ? e : f, t.fill()), !(g <= 0) && (t.strokeStyle = e, t.lineWidth = g * s, t.stroke());
624
+ },
625
+ dot(r, h, i) {
626
+ t.fillStyle = e, t.beginPath(), t.arc(r, h, i * s, 0, Math.PI * 2), t.fill();
627
+ },
628
+ guide() {
629
+ },
630
+ guideEllipse() {
631
+ }
632
+ };
633
+ }
634
+ function In(t, e) {
635
+ const n = [t[0]];
636
+ let o = 0;
637
+ for (let h = 1; h < t.length; h++) {
638
+ const i = t[h - 1], l = t[h], a = Math.hypot(l.x - i.x, l.y - i.y);
639
+ let f = e - o;
640
+ for (; f < a; ) {
641
+ const g = f / a;
642
+ n.push({ x: i.x + (l.x - i.x) * g, y: i.y + (l.y - i.y) * g }), f += e;
643
+ }
644
+ o = a - (f - e);
645
+ }
646
+ const s = t[t.length - 1], r = n[n.length - 1];
647
+ return Math.hypot(s.x - r.x, s.y - r.y) > e * 0.25 ? n.push(s) : n[n.length - 1] = s, n;
648
+ }
649
+ function An(t, e) {
650
+ const n = t.length;
651
+ return t.map((o, s) => {
652
+ const r = t[Math.max(0, s - 1)], h = t[Math.min(n - 1, s + 1)], i = Math.hypot(h.x - r.x, h.y - r.y) || 1, l = e(n === 1 ? 0 : s / (n - 1));
653
+ return { x: o.x - (h.y - r.y) / i * l, y: o.y + (h.x - r.x) / i * l };
654
+ });
655
+ }
656
+ function oe(t) {
657
+ const e = [0.6, 1.4, 2.9].map((o) => ({
658
+ frequency: o * (0.8 + t.next() * 0.4),
659
+ phase: t.next() * Math.PI * 2,
660
+ amount: 0.5 + t.next() * 0.5
661
+ })), n = e.reduce((o, s) => o + s.amount, 0);
662
+ return (o) => e.reduce((s, r) => s + r.amount * Math.sin(Math.PI * 2 * r.frequency * o + r.phase), 0) / n;
663
+ }
664
+ function On(t, e) {
665
+ const n = e.pencil ?? {}, o = e.ink, s = n.roughness ?? Math.max(1, e.lineWidth * 0.12), r = Math.max(1, Math.round(n.passes ?? 2)), h = Math.min(1, Math.max(0, n.pressure ?? 0.25)), i = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), l = We(e.time, n.boil ?? 8);
666
+ let a = 0;
667
+ const f = (d, u, y = !1) => $e(Re(`${e.seed}:${y ? "paper" : l}:${d}:${u}`)), g = (d, u, y, p, x, E = 0) => {
668
+ if (d.length < 2) return;
669
+ const b = d.slice(1).reduce((_, k, w) => _ + Math.hypot(k.x - d[w].x, k.y - d[w].y), 0);
670
+ let M = In(d, Math.max(1.5, Math.min(e.lineWidth * 0.8, b / 24)));
671
+ if (E > 0 && M.length >= 2) {
672
+ const [_, k] = [M[M.length - 2], M[M.length - 1]], w = Math.hypot(k.x - _.x, k.y - _.y) || 1;
673
+ M = [...M, { x: k.x + (k.x - _.x) / w * E, y: k.y + (k.y - _.y) / w * E }];
674
+ }
675
+ const T = oe(y), P = oe(y), I = M.length, O = [], H = [];
676
+ M.forEach((_, k) => {
677
+ const w = I === 1 ? 0 : k / (I - 1), S = M[Math.max(0, k - 1)], v = M[Math.min(I - 1, k + 1)], A = Math.hypot(v.x - S.x, v.y - S.y) || 1, W = -(v.y - S.y) / A, nt = (v.x - S.x) / A, at = T(w) * x, xt = Math.min(1, w / 0.08, (1 - w) / 0.08), Et = (0.55 + 0.45 * Math.sqrt(Math.max(0, xt))) * (1 + h * P(w)), q = Math.max(0.3, u(w) * Et / 2), ot = _.x + W * at, Z = _.y + nt * at;
678
+ O.push({ x: ot + W * q, y: Z + nt * q }), H.push({ x: ot - W * q, y: Z - nt * q });
679
+ }), t.save(), t.globalAlpha *= p, t.fillStyle = o, bt(t, [...O, ...H.reverse()], !0), t.fill(), t.restore();
680
+ }, m = (d, u) => {
681
+ const y = a++, p = f(y, 99, !0);
682
+ if (p.next() < i) {
683
+ const M = (p.next() * 2 - 1) * e.lineWidth * 1.4, T = (p.next() * 2 - 1) * e.lineWidth * 1.4, P = d.map((I) => ({ x: I.x + M, y: I.y + T }));
684
+ g(P, (I) => u(I) * 1.8, f(y, 98, !0), 0.035, s), g(P, (I) => u(I) * 0.45, f(y, 97, !0), 0.12, s * 1.5);
685
+ }
686
+ const x = d.slice(1).reduce((M, T, P) => M + Math.hypot(T.x - d[P].x, T.y - d[P].y), 0), E = u(0.5) > 4 && x > u(0.5) * 6, b = E ? [-0.3, 0.3, 0] : [0];
687
+ for (let M = 0; M < r; M++) {
688
+ const T = M === 0;
689
+ b.forEach((P, I) => {
690
+ const O = f(y, M * 10 + I), H = P === 0 ? d : An(d, (k) => u(k) * P * Math.sqrt(Math.sin(Math.PI * k))), _ = !T && P === 0 ? e.lineWidth * (0.3 + O.next() * 0.8) : 0;
691
+ g(H, (k) => u(k) * (E ? 0.5 : 1) * (T ? 1 : 0.6), O, T ? 0.85 : 0.45, s * (T ? 0.6 : 1), _);
692
+ });
693
+ }
694
+ }, c = (d, u, y, p, x, E) => {
695
+ const M = f(a, 50).next() * Math.PI * 2;
696
+ m(ne(d, u, y, p, x, M, 1.08, 48), () => E);
697
+ };
698
+ return {
699
+ look: "pencil",
700
+ ink: o,
701
+ limb(d, u, y) {
702
+ m(d, (p) => u + (y - u) * p);
703
+ },
704
+ line(d, u) {
705
+ m(d, () => u);
706
+ },
707
+ shape(d, u, y) {
708
+ u !== null && (t.save(), t.globalAlpha *= 0.88, t.fillStyle = u, bt(t, d, !0), t.fill(), t.restore()), y > 0 && m([...d, d[0]], () => y);
709
+ },
710
+ ellipse(d, u, y, p, x, E, b) {
711
+ E !== null && (t.save(), t.globalAlpha *= 0.9, t.fillStyle = E, t.beginPath(), t.ellipse(d, u, y, p, x, 0, Math.PI * 2), t.fill(), t.restore()), c(d, u, y, p, x, b);
712
+ },
713
+ dot(d, u, y) {
714
+ t.save(), t.globalAlpha *= 0.9, t.fillStyle = o, t.beginPath(), t.arc(d, u, y, 0, Math.PI * 2), t.fill(), t.restore();
715
+ },
716
+ guide(d) {
717
+ if (n.construction === !1 || d.length < 2) return;
718
+ const u = a++;
719
+ g(d, () => Math.max(0.6, e.lineWidth * 0.18), f(u, 0), 0.28, s * 1.2, e.lineWidth);
720
+ },
721
+ guideEllipse(d, u, y, p, x) {
722
+ if (n.construction === !1) return;
723
+ const E = a++, b = f(E, 0), M = ne(d, u, y, p, x, b.next() * Math.PI * 2, 1.12, 48);
724
+ g(M, () => Math.max(0.6, e.lineWidth * 0.18), b, 0.28, s * 1.5);
725
+ }
726
+ };
727
+ }
728
+ const _n = "#f1c9a5", Hn = "#2f2f33";
729
+ function xe(t, e, n, o = {}, s = 0) {
730
+ const r = Pn(Ft(n, o), e), h = o.ink ?? Hn, i = o.lineWidth ?? r.size * 0.035, l = o.pen ?? ke(t, {
731
+ look: o.look ?? "clean",
732
+ ink: h,
733
+ lineWidth: i,
734
+ seed: o.seed ?? 1,
735
+ time: s,
736
+ pencil: { construction: !1, ...o.pencil }
737
+ }), a = o.skin ?? _n, f = o.nails ?? !0, g = [
738
+ {
739
+ depth: r.palmDepth,
740
+ draw: () => Wn(l, r, a, i)
741
+ }
742
+ ];
743
+ for (const m of Object.values(r.fingers)) {
744
+ const c = m.depths.reduce((d, u) => d + u, 0) / m.depths.length;
745
+ g.push({
746
+ depth: c,
747
+ draw: () => $n(t, l, m, a, i, f)
748
+ });
749
+ }
750
+ if (o.prop) {
751
+ const m = o.prop;
752
+ g.push({ depth: m.depth, draw: () => m.draw(l) });
753
+ }
754
+ t.save(), t.lineCap = "round", t.lineJoin = "round";
755
+ for (const m of [...g].sort((c, d) => c.depth - d.depth)) m.draw();
756
+ return t.restore(), r;
757
+ }
758
+ function Wn(t, e, n, o) {
759
+ if (t.shape(e.palm, n, o), e.palmFacing < -0.3 && t.look !== "silhouette") {
760
+ const { up: s } = e.axes;
761
+ for (const [r, h] of Object.entries(e.fingers)) {
762
+ const i = e.curls[r] ?? 0;
763
+ if (r === "thumb" || i < 0.5) continue;
764
+ const l = h.points[0], a = h.widths[0] * 0.42, f = { x: l.x - s.x * a * 0.2, y: l.y - s.y * a * 0.2 }, g = Math.atan2(s.y, s.x), m = Array.from({ length: 7 }, (c, d) => {
765
+ const u = g - Math.PI / 2 + Math.PI * d / 6;
766
+ return { x: f.x + Math.cos(u) * a, y: f.y + Math.sin(u) * a };
767
+ });
768
+ t.line(m, o * 0.6);
769
+ }
770
+ }
771
+ if (e.palmFacing > 0.45 && t.look !== "silhouette") {
772
+ const { up: s, across: r } = e.axes, h = e.size, i = e.wrist, l = (f, g) => ({
773
+ x: i.x + (r.x * f + s.x * g) * h,
774
+ y: i.y + (r.y * f + s.y * g) * h
775
+ }), a = e.side === "left" ? -1 : 1;
776
+ t.line([l(-0.15 * a, 0.36), l(-0.04 * a, 0.3), l(0.1 * a, 0.33)], o * 0.5);
777
+ }
778
+ }
779
+ function $n(t, e, n, o, s, r) {
780
+ const { widths: h } = n, i = Rn(n.points, 2), l = n.points[0], a = i[i.length - 1], f = h[0], g = h[h.length - 1];
781
+ if (t.save(), e.look !== "silhouette") {
782
+ t.beginPath(), t.rect(l.x - 1e5, l.y - 1e5, 2e5, 2e5);
783
+ const u = f / 2 + s * 1.6;
784
+ t.moveTo(l.x + u, l.y), t.arc(l.x, l.y, u, 0, Math.PI * 2), t.clip("evenodd");
785
+ }
786
+ if (e.limb(i, f + 2 * s, g + 2 * s), t.restore(), e.look !== "silhouette" && (t.fillStyle = o, Xt(t, i, f, g)), e.look === "silhouette" || !r || n.nail < 0.25) return;
787
+ const m = i[i.length - 2], c = Bn({ x: a.x - m.x, y: a.y - m.y }) ?? {
788
+ x: 0,
789
+ y: -1
790
+ }, d = {
791
+ x: a.x - c.x * g * 0.22 + n.back.x * g * 0.1,
792
+ y: a.y - c.y * g * 0.22 + n.back.y * g * 0.1
793
+ };
794
+ e.ellipse(d.x, d.y, g * 0.24 * Math.max(0.35, n.nail), g * 0.19, Math.atan2(c.y, c.x), "#f8e3d3", s * 0.45);
795
+ }
796
+ function Rn(t, e) {
797
+ let n = t;
798
+ for (let o = 0; o < e; o++) {
799
+ if (n.length < 3) return n;
800
+ const s = [n[0]];
801
+ for (let r = 0; r < n.length - 1; r++) {
802
+ const h = n[r], i = n[r + 1];
803
+ r > 0 && s.push({ x: h.x * 0.75 + i.x * 0.25, y: h.y * 0.75 + i.y * 0.25 }), r < n.length - 2 && s.push({ x: h.x * 0.25 + i.x * 0.75, y: h.y * 0.25 + i.y * 0.75 });
804
+ }
805
+ s.push(n[n.length - 1]), n = s;
806
+ }
807
+ return n;
808
+ }
809
+ const Bn = (t) => {
810
+ const e = Math.hypot(t.x, t.y);
811
+ return e > 1e-6 ? { x: t.x / e, y: t.y / e } : null;
812
+ };
813
+ function Yn(t, e, n = {}, o) {
814
+ const s = n.length ?? 240, r = 9, h = 28, i = s - 22;
815
+ t.save(), t.translate(e.x, e.y), t.rotate((n.angle ?? -30) * Math.PI / 180), t.fillStyle = n.color ?? "#f4c542", t.fillRect(h, -r, i - h, 2 * r), t.fillStyle = "#e8b4a0", t.fillRect(i, -r, s - i, 2 * r), t.fillStyle = "#f1dcbf", t.beginPath(), t.moveTo(0, 0), t.lineTo(h, -r), t.lineTo(h, r), t.closePath(), t.fill(), t.fillStyle = n.outline ?? "#2f2f33", t.beginPath(), t.moveTo(0, 0), t.lineTo(h * 0.35, -r * 0.35), t.lineTo(h * 0.35, r * 0.35), t.closePath(), t.fill(), t.strokeStyle = n.outline ?? "#2f2f33", t.lineWidth = 3, t.lineJoin = "round", t.lineCap = "round";
424
816
  const l = [
425
- [{ x: 0, y: 0 }, { x: h, y: -s }, { x: r, y: -s }, { x: r, y: s }, { x: h, y: s }, { x: 0, y: 0 }],
426
- [{ x: h, y: -s }, { x: h, y: s }],
427
- [{ x: i, y: -s }, { x: i, y: s }]
817
+ [{ x: 0, y: 0 }, { x: h, y: -r }, { x: s, y: -r }, { x: s, y: r }, { x: h, y: r }, { x: 0, y: 0 }],
818
+ [{ x: h, y: -r }, { x: h, y: r }],
819
+ [{ x: i, y: -r }, { x: i, y: r }]
428
820
  ];
429
- for (const a of l) he(t, a, o);
821
+ for (const a of l) Te(t, a, o);
430
822
  t.restore();
431
823
  }
432
- function ie(t, e, n = {}, o) {
433
- const r = n.length ?? 90, s = n.thickness ?? 34;
824
+ function Ee(t, e, n = {}, o) {
825
+ const s = n.length ?? 90, r = n.thickness ?? 34;
434
826
  t.save(), t.translate(e.x, e.y), t.rotate((n.angle ?? -35) * Math.PI / 180);
435
- const h = -s / 2;
436
- t.fillStyle = n.color ?? "#f4a7b9", t.fillRect(0, h, r, s), t.fillStyle = "#e9edf2", t.fillRect(r * 0.45, h, r * 0.55, s), t.strokeStyle = n.outline ?? "#2f2f33", t.lineWidth = 3, t.lineJoin = "round";
827
+ const h = -r / 2;
828
+ t.fillStyle = n.color ?? "#f4a7b9", t.fillRect(0, h, s, r), t.fillStyle = "#e9edf2", t.fillRect(s * 0.45, h, s * 0.55, r), t.strokeStyle = n.outline ?? "#2f2f33", t.lineWidth = 3, t.lineJoin = "round";
437
829
  const i = [
438
830
  { x: 0, y: h },
439
- { x: r, y: h },
440
- { x: r, y: -h },
831
+ { x: s, y: h },
832
+ { x: s, y: -h },
441
833
  { x: 0, y: -h },
442
834
  { x: 0, y: h }
443
- ], l = [{ x: r * 0.45, y: h }, { x: r * 0.45, y: -h }];
835
+ ], l = [{ x: s * 0.45, y: h }, { x: s * 0.45, y: -h }];
444
836
  if (o)
445
837
  o.line(i), o.line(l);
446
838
  else
447
839
  for (const a of [i, l]) {
448
840
  t.beginPath(), t.moveTo(a[0].x, a[0].y);
449
- for (const c of a.slice(1)) t.lineTo(c.x, c.y);
841
+ for (const f of a.slice(1)) t.lineTo(f.x, f.y);
450
842
  t.stroke();
451
843
  }
452
844
  t.restore();
453
845
  }
454
- function le(t, e, n = {}, o) {
455
- const r = n.tool ?? "pencil", s = n.skin ?? "#f1c9a5", h = n.outline ?? "#2f2f33", i = r === "eraser" ? 17 : 9, l = r === "eraser" ? -40 : 0, a = o ? o.nudge(0.6) : { x: 0, y: 0 };
456
- t.save(), t.translate(e.x + a.x, e.y + a.y), t.rotate((n.angle ?? -30) * Math.PI / 180), t.scale(n.scale ?? 1, n.scale ?? 1), t.lineCap = "round", t.lineJoin = "round";
457
- const c = (f, d, w, m) => {
458
- for (const [u, k] of [
459
- [h, w + 6],
460
- [m, w]
461
- ])
462
- t.strokeStyle = u, t.lineWidth = k, t.beginPath(), t.moveTo(f.x, f.y), t.lineTo(d.x, d.y), t.stroke();
463
- };
464
- t.save(), t.translate(l, 0);
465
- const g = { x: 165, y: -i - 26 }, y = (f) => ({ x: g.x + f * 0.8, y: g.y + f * 0.6 });
466
- c(g, y(2e3), 64, s), c(y(110), y(2e3), 92, n.sleeve ?? "#5b7db1"), t.fillStyle = s, t.strokeStyle = h, t.lineWidth = 3, t.beginPath(), t.ellipse(g.x, g.y, 54, 40, 0.25, 0, Math.PI * 2), t.fill(), t.stroke(), t.restore(), r === "eraser" ? ie(t, { x: 0, y: 0 }, { angle: 0, outline: h }, o) : je(t, { x: 0, y: 0 }, { angle: 0, outline: h }, o), t.translate(l, 0), c({ x: 150, y: i + 8 }, { x: 92, y: i + 12 }, 22, s), c({ x: 140, y: -i - 18 }, { x: 58, y: -i - 6 }, 20, s), c({ x: 150, y: -i - 30 }, { x: 112, y: -i + 2 }, 20, s), c({ x: 172, y: -i - 30 }, { x: 140, y: -i + 4 }, 20, s), t.restore();
467
- }
468
- function In(t, e, n, o = 0.08, r = 32) {
469
- const s = Math.PI * 2 * (1 + o), h = [];
470
- for (let i = 0; i <= r; i++) {
471
- const l = -Math.PI / 2 + s * i / r;
846
+ const Se = 150, Ln = { pencil: 44, eraser: 30 };
847
+ function Pe(t, e, n = {}, o) {
848
+ const s = n.tool ?? "pencil", r = n.skin ?? "#f1c9a5", h = n.outline ?? "#2f2f33", i = n.scale ?? 1, l = Math.min(1, Math.max(0, n.lift ?? 0)), a = (n.angle ?? -30) * Math.PI / 180, f = o ? o.nudge(0.6) : { x: 0, y: 0 }, g = Se * i * (1 + 0.05 * l);
849
+ l > 0 && (t.save(), t.fillStyle = h, t.globalAlpha = 0.15 * l, t.beginPath(), t.ellipse(e.x, e.y, 9 * i, 4 * i, 0, 0, Math.PI * 2), t.fill(), t.restore());
850
+ const m = { x: e.x + f.x + 6 * l * i, y: e.y + f.y - 18 * l * i }, c = un.pencilGrip, d = (P) => {
851
+ const I = P.fingers.thumb, O = P.fingers.index, H = P.fingers.middle, _ = se([I.points[3], O.points[3], H.points[3]]), k = se([I.points[1], O.points[0]]), w = (I.depths[3] + O.depths[3] + H.depths[3]) / 3;
852
+ return { pinch: _, direction: Math.atan2(k.y - _.y, k.x - _.x), depth: w };
853
+ }, u = Ft(c, { size: g }), y = a - d(u).direction, p = Ft(c, { size: g, angle: y * 180 / Math.PI }), x = d(p), E = Ln[s] * i, b = { x: x.pinch.x - Math.cos(a) * E, y: x.pinch.y - Math.sin(a) * E }, M = { x: m.x - b.x, y: m.y - b.y }, T = p.axes.up;
854
+ Fn(t, M, { x: -T.x, y: -T.y }, g, n.arm ?? 300 * i, r, n.sleeve ?? "#5b7db1", h), xe(t, M, c, {
855
+ size: g,
856
+ angle: y * 180 / Math.PI,
857
+ skin: r,
858
+ ink: h,
859
+ lineWidth: 3 * i,
860
+ prop: {
861
+ depth: x.depth,
862
+ draw: () => {
863
+ t.save(), t.translate(m.x, m.y), t.scale(i, i), s === "eraser" ? Ee(t, { x: 0, y: 0 }, { angle: a * 180 / Math.PI, outline: h }, o) : Yn(t, { x: 0, y: 0 }, { angle: a * 180 / Math.PI, length: 190, outline: h }, o), t.restore();
864
+ }
865
+ }
866
+ });
867
+ }
868
+ const se = (t) => ({
869
+ x: t.reduce((e, n) => e + n.x, 0) / t.length,
870
+ y: t.reduce((e, n) => e + n.y, 0) / t.length
871
+ });
872
+ function Fn(t, e, n, o, s, r, h, i) {
873
+ const l = { x: -n.y, y: n.x }, a = o * 0.15, f = (u, y, p) => ({
874
+ x: e.x + n.x * u + l.x * y * p,
875
+ y: e.y + n.y * u + l.y * y * p
876
+ }), g = f(s, 0, 0), m = (u) => {
877
+ const y = t.createLinearGradient(e.x, e.y, g.x, g.y);
878
+ return y.addColorStop(0, u), y.addColorStop(0.6, u), y.addColorStop(1, Nn(u)), y;
879
+ }, c = Math.min(o * 0.55, s * 0.35);
880
+ t.save(), t.lineJoin = "round", t.lineCap = "round", t.lineWidth = 3 * (o / Se), t.beginPath(), t.moveTo(f(-o * 0.1, -1, a).x, f(-o * 0.1, -1, a).y), t.lineTo(f(c + 4, -1, a * 1.1).x, f(c + 4, -1, a * 1.1).y), t.lineTo(f(c + 4, 1, a * 1.1).x, f(c + 4, 1, a * 1.1).y), t.lineTo(f(-o * 0.1, 1, a).x, f(-o * 0.1, 1, a).y), t.closePath(), t.fillStyle = r, t.fill(), t.strokeStyle = i, t.beginPath(), t.moveTo(f(0, -1, a).x, f(0, -1, a).y), t.lineTo(f(c, -1, a * 1.1).x, f(c, -1, a * 1.1).y), t.moveTo(f(0, 1, a).x, f(0, 1, a).y), t.lineTo(f(c, 1, a * 1.1).x, f(c, 1, a * 1.1).y), t.stroke();
881
+ const d = [f(c, -1, a * 1.3), f(s, -1, a * 1.5), f(s, 1, a * 1.5), f(c, 1, a * 1.3)];
882
+ t.beginPath(), d.forEach((u, y) => y ? t.lineTo(u.x, u.y) : t.moveTo(u.x, u.y)), t.closePath(), t.fillStyle = m(h), t.fill(), t.strokeStyle = m(i), t.beginPath(), t.moveTo(d[1].x, d[1].y), t.lineTo(d[0].x, d[0].y), t.lineTo(d[3].x, d[3].y), t.lineTo(d[2].x, d[2].y), t.stroke(), t.restore();
883
+ }
884
+ function ko(t, e, n = {}) {
885
+ const o = n.offstage ?? { x: 2e3, y: 1400 }, s = n.enter ?? 450, r = n.exit ?? 450, h = n.linger ?? 1500, i = [...t].filter((u) => u.path.length > 0).sort((u, y) => u.start - y.start), l = (u) => u.tool ?? "pencil", a = (u) => {
886
+ const y = Math.min(1, Math.max(0, u));
887
+ return y * y * (3 - 2 * y);
888
+ }, f = (u, y, p) => ({ x: u.x + (y.x - u.x) * p, y: u.y + (y.y - u.y) * p }), g = i.find((u) => e >= u.start && e <= u.end);
889
+ if (g) {
890
+ const u = g.end - g.start, y = u > 0 ? (e - g.start) / u : 1;
891
+ return { at: Ut(g.path, y), tool: l(g), lift: 0, drawing: !0 };
892
+ }
893
+ const m = [...i].reverse().find((u) => u.end < e), c = i.find((u) => u.start > e), d = (u) => u.path[u.path.length - 1];
894
+ if (m && c && c.start - m.end <= h) {
895
+ const u = (e - m.end) / (c.start - m.end), y = u < 0.5 ? l(m) : l(c);
896
+ return { at: f(d(m), c.path[0], a(u)), tool: y, lift: Math.sin(Math.PI * u), drawing: !1 };
897
+ }
898
+ if (c && c.start - e <= s) {
899
+ const u = 1 - (c.start - e) / s;
900
+ return { at: f(o, c.path[0], a(u)), tool: l(c), lift: 1 - a(u), drawing: !1 };
901
+ }
902
+ if (m && e - m.end <= r) {
903
+ const u = (e - m.end) / r;
904
+ return { at: f(d(m), o, a(u)), tool: l(m), lift: a(u), drawing: !1 };
905
+ }
906
+ return null;
907
+ }
908
+ function xo(t, e, n, o = 0.08, s = 32) {
909
+ const r = Math.PI * 2 * (1 + o), h = [];
910
+ for (let i = 0; i <= s; i++) {
911
+ const l = -Math.PI / 2 + r * i / s;
472
912
  h.push({ x: t + Math.cos(l) * n, y: e + Math.sin(l) * n });
473
913
  }
474
914
  return h;
475
915
  }
476
- function An(t) {
477
- const { path: e } = t, n = e.map((i) => i.x), o = e.map((i) => i.y), r = Math.min(...n), s = Math.min(...o), h = t.hand === !1 ? void 0 : t.hand === !0 || t.hand === void 0 ? {} : t.hand;
916
+ function Eo(t) {
917
+ const { path: e } = t, n = e.map((i) => i.x), o = e.map((i) => i.y), s = Math.min(...n), r = Math.min(...o), h = t.hand === !1 ? void 0 : t.hand === !0 || t.hand === void 0 ? {} : t.hand;
478
918
  return {
479
919
  type: "custom",
480
- x: r,
481
- y: s,
482
- width: Math.max(1, Math.max(...n) - r),
483
- height: Math.max(1, Math.max(...o) - s),
920
+ x: s,
921
+ y: r,
922
+ width: Math.max(1, Math.max(...n) - s),
923
+ height: Math.max(1, Math.max(...o) - r),
484
924
  props: { draw: 0 },
485
925
  draw(i, l, a) {
486
- const c = Math.min(1, Math.max(0, Number(l.props?.draw ?? 0)));
487
- i.translate(-r, -s), i.strokeStyle = t.color ?? "#2f2f33", i.lineWidth = t.lineWidth ?? 5, i.lineCap = "round", i.lineJoin = "round";
488
- const g = t.sketch ? xt(i, t.sketch, a) : void 0;
489
- c > 0 && (g ? t.smooth ? g.curve(e, c) : g.line(e, c) : he(i, Dt(e, c))), h && c > 0 && c < 1 && le(i, jt(e, c), h, g);
926
+ const f = Math.min(1, Math.max(0, Number(l.props?.draw ?? 0)));
927
+ i.translate(-s, -r), i.strokeStyle = t.color ?? "#2f2f33", i.lineWidth = t.lineWidth ?? 5, i.lineCap = "round", i.lineJoin = "round";
928
+ const g = t.sketch ? Ht(i, t.sketch, a) : void 0;
929
+ f > 0 && (g ? t.smooth ? g.curve(e, f) : g.line(e, f) : Te(i, ae(e, f))), h && f > 0 && f < 1 && Pe(i, Ut(e, f), h, g);
490
930
  }
491
931
  };
492
932
  }
493
- function he(t, e, n) {
933
+ function Nn(t) {
934
+ const e = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());
935
+ if (!e) return "rgba(0, 0, 0, 0)";
936
+ const n = e[1].length === 3 ? [...e[1]].map((h) => h + h).join("") : e[1], [o, s, r] = [0, 2, 4].map((h) => parseInt(n.slice(h, h + 2), 16));
937
+ return `rgba(${o}, ${s}, ${r}, 0)`;
938
+ }
939
+ function Te(t, e, n) {
494
940
  if (!(e.length < 2)) {
495
941
  if (n) return n.line(e);
496
942
  t.beginPath(), t.moveTo(e[0].x, e[0].y);
@@ -498,352 +944,217 @@ function he(t, e, n) {
498
944
  t.stroke();
499
945
  }
500
946
  }
501
- const st = 1e5;
502
- function Hn(t, e, n, o, r = 6) {
503
- const s = [], h = Math.max(1, Math.round(r));
947
+ const ft = 1e5;
948
+ function So(t, e, n, o, s = 6) {
949
+ const r = [], h = Math.max(1, Math.round(s));
504
950
  for (let i = 0; i <= h; i++)
505
- s.push({ x: i % 2 === 0 ? t : t + n, y: e + o * i / h });
506
- return s;
951
+ r.push({ x: i % 2 === 0 ? t : t + n, y: e + o * i / h });
952
+ return r;
507
953
  }
508
- function ae(t, e, n, o) {
954
+ function ve(t, e, n, o) {
509
955
  if (o <= 0 || e.length === 0) return;
510
- const r = Dt(e, o), s = n / 2, h = (i) => {
511
- t.beginPath(), t.rect(-st, -st, 2 * st, 2 * st), i(), t.clip("evenodd");
956
+ const s = ae(e, o), r = n / 2, h = (i) => {
957
+ t.beginPath(), t.rect(-ft, -ft, 2 * ft, 2 * ft), i(), t.clip("evenodd");
512
958
  };
513
- for (const i of r)
959
+ for (const i of s)
514
960
  h(() => {
515
- t.moveTo(i.x + s, i.y), t.arc(i.x, i.y, s, 0, Math.PI * 2);
961
+ t.moveTo(i.x + r, i.y), t.arc(i.x, i.y, r, 0, Math.PI * 2);
516
962
  });
517
- for (let i = 1; i < r.length; i++) {
518
- const l = r[i - 1], a = r[i], c = Math.hypot(a.x - l.x, a.y - l.y);
519
- if (c === 0) continue;
520
- const g = -(a.y - l.y) / c * s, y = (a.x - l.x) / c * s;
963
+ for (let i = 1; i < s.length; i++) {
964
+ const l = s[i - 1], a = s[i], f = Math.hypot(a.x - l.x, a.y - l.y);
965
+ if (f === 0) continue;
966
+ const g = -(a.y - l.y) / f * r, m = (a.x - l.x) / f * r;
521
967
  h(() => {
522
- t.moveTo(l.x + g, l.y + y), t.lineTo(a.x + g, a.y + y), t.lineTo(a.x - g, a.y - y), t.lineTo(l.x - g, l.y - y), t.closePath();
968
+ t.moveTo(l.x + g, l.y + m), t.lineTo(a.x + g, a.y + m), t.lineTo(a.x - g, a.y - m), t.lineTo(l.x - g, l.y - m), t.closePath();
523
969
  });
524
970
  }
525
971
  }
526
- function _n(t, e, n, o, r) {
527
- t.save(), ae(t, e, n, o), r(), t.restore();
972
+ function Po(t, e, n, o, s) {
973
+ t.save(), ve(t, e, n, o), s(), t.restore();
528
974
  }
529
- function Yn(t, e) {
530
- const n = e.width ?? 40, o = e.hand === !0 ? {} : e.hand || void 0, r = e.eraser === !1 ? void 0 : e.eraser === !0 || e.eraser === void 0 ? {} : e.eraser;
975
+ function To(t, e) {
976
+ const n = e.width ?? 40, o = e.hand === !0 ? {} : e.hand || void 0, s = e.eraser === !1 ? void 0 : e.eraser === !0 || e.eraser === void 0 ? {} : e.eraser;
531
977
  return {
532
978
  ...t,
533
979
  props: { ...t.props, erase: 0 },
534
- draw(s, h, i) {
980
+ draw(r, h, i) {
535
981
  const l = Number(h.props?.erase ?? 0);
536
- if (s.save(), ae(s, e.path, n, l), t.draw(s, h, i), s.restore(), !r || l <= 0 || l >= 1) return;
537
- const a = jt(e.path, l);
538
- o ? le(s, a, { ...o, tool: "eraser" }) : ie(s, a, r);
982
+ if (r.save(), ve(r, e.path, n, l), t.draw(r, h, i), r.restore(), !s || l <= 0 || l >= 1) return;
983
+ const a = Ut(e.path, l);
984
+ o ? Pe(r, a, { ...o, tool: "eraser" }) : Ee(r, a, s);
539
985
  }
540
986
  };
541
987
  }
542
- const q = (t) => t * Math.PI / 180;
543
- function ce([t, e, n], o) {
544
- const r = Math.cos(o), s = Math.sin(o);
545
- return [t, e * r + n * s, -e * s + n * r];
988
+ const K = (t) => t * Math.PI / 180;
989
+ function Ie([t, e, n], o) {
990
+ const s = Math.cos(o), r = Math.sin(o);
991
+ return [t, e * s + n * r, -e * r + n * s];
546
992
  }
547
- function fe([t, e, n], o) {
548
- const r = Math.cos(o), s = Math.sin(o);
549
- return [t * r - e * s, t * s + e * r, n];
993
+ function Ae([t, e, n], o) {
994
+ const s = Math.cos(o), r = Math.sin(o);
995
+ return [t * s - e * r, t * r + e * s, n];
550
996
  }
551
- function et([t, e, n], o) {
552
- const r = Math.cos(o), s = Math.sin(o);
553
- return [t * r + n * s, e, -t * s + n * r];
997
+ function ht([t, e, n], o) {
998
+ const s = Math.cos(o), r = Math.sin(o);
999
+ return [t * s + n * r, e, -t * r + n * s];
554
1000
  }
555
- const pt = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]], Nt = (t, e) => [t[0] * e, t[1] * e, t[2] * e], at = (t, e) => fe(ce(t, e.swing), e.spread);
556
- function wt(t, e) {
557
- const n = et(t, e);
1001
+ const Tt = (t, e) => [t[0] + e[0], t[1] + e[1], t[2] + e[2]], re = (t, e) => [t[0] * e, t[1] * e, t[2] * e], pt = (t, e) => Ae(Ie(t, e.swing), e.spread);
1002
+ function vt(t, e) {
1003
+ const n = ht(t, e);
558
1004
  return { point: { x: n[0], y: -n[1] }, depth: n[2] };
559
1005
  }
560
- function It(t, e, n) {
561
- const o = n.height, r = q(90 * (e.turn ?? 0)), h = [0, t.hipHeight * o * (t.boneScale?.(e, null) ?? 1), 0], i = {};
562
- for (const p of t.chains) {
563
- const T = p.parent ? i[p.parent] : void 0;
564
- if (p.parent && !T) throw new Error(`body plan ${t.id}: chain ${p.id} comes before its parent ${p.parent}`);
565
- const v = p.at ?? (T ? T.joints3.length - 1 : 0), O = T ? T.joints3[v] : h, A = T ? T.frames[Math.max(0, v - 1)] : { swing: 0, spread: 0 }, Z = p.offset ? pt(O, at(Nt(p.offset, o), A)) : O, nt = p.side ?? 1, ut = t.boneScale?.(e, p) ?? 1, gt = t.angles(e, p), X = [Z], Q = [];
566
- let D = A.swing, yt = A.spread;
567
- p.bones.forEach((ue, Ht) => {
568
- const mt = gt[Ht] ?? { swing: 0, spread: 0 };
569
- D += q(mt.swing), yt += q(mt.spread) * nt, Q.push({ swing: D, spread: yt });
570
- const ge = et(at(p.rest, { swing: D, spread: yt }), q(mt.yaw ?? 0));
571
- X.push(pt(X[Ht], Nt(ge, ue.length * o * ut)));
572
- }), i[p.id] = { joints3: X, frames: Q };
1006
+ function Dt(t, e, n) {
1007
+ const o = n.height, s = K(90 * (e.turn ?? 0)), h = [0, t.hipHeight * o * (t.boneScale?.(e, null) ?? 1), 0], i = {};
1008
+ for (const w of t.chains) {
1009
+ const S = w.parent ? i[w.parent] : void 0;
1010
+ if (w.parent && !S) throw new Error(`body plan ${t.id}: chain ${w.id} comes before its parent ${w.parent}`);
1011
+ const v = w.at ?? (S ? S.joints3.length - 1 : 0), A = S ? S.joints3[v] : h, W = S ? S.frames[Math.max(0, v - 1)] : { swing: 0, spread: 0 }, nt = w.offset ? Tt(A, pt(re(w.offset, o), W)) : A, at = w.side ?? 1, xt = t.boneScale?.(e, w) ?? 1, Et = t.angles(e, w), q = [nt], ot = [];
1012
+ let Z = W.swing, St = W.spread;
1013
+ w.bones.forEach((_e, Kt) => {
1014
+ const Pt = Et[Kt] ?? { swing: 0, spread: 0 };
1015
+ Z += K(Pt.swing), St += K(Pt.spread) * at, ot.push({ swing: Z, spread: St });
1016
+ const He = ht(pt(w.rest, { swing: Z, spread: St }), K(Pt.yaw ?? 0));
1017
+ q.push(Tt(q[Kt], re(He, _e.length * o * xt)));
1018
+ }), i[w.id] = { joints3: q, frames: ot };
573
1019
  }
574
- const l = i[t.head.on], a = t.headPose?.(e) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, c = l.frames[l.frames.length - 1], g = t.head.size / 2 * o, y = g * a.sx, f = g * a.sy, d = (p) => at(et(ce(fe(p, -q(a.tilt)), -q(a.nod)), q(a.yaw)), c), w = pt(l.joints3[l.joints3.length - 1], d([0, f, 0])), m = {};
575
- for (const p of t.chains) {
576
- const { joints3: T, frames: v } = i[p.id], O = T.map((A) => wt(A, r));
577
- m[p.id] = {
578
- id: p.id,
579
- joints3: T,
1020
+ const l = i[t.head.on], a = t.headPose?.(e) ?? { yaw: 0, nod: 0, tilt: 0, sx: 1, sy: 1 }, f = l.frames[l.frames.length - 1], g = t.head.size / 2 * o, m = g * a.sx, c = g * a.sy, d = (w) => pt(ht(Ie(Ae(w, -K(a.tilt)), -K(a.nod)), K(a.yaw)), f), u = Tt(l.joints3[l.joints3.length - 1], d([0, c, 0])), y = {};
1021
+ for (const w of t.chains) {
1022
+ const { joints3: S, frames: v } = i[w.id], A = S.map((W) => vt(W, s));
1023
+ y[w.id] = {
1024
+ id: w.id,
1025
+ joints3: S,
580
1026
  frames: v,
581
- points: O.map((A) => A.point),
582
- depths: O.map((A) => A.depth)
1027
+ points: A.map((W) => W.point),
1028
+ depths: A.map((W) => W.depth)
583
1029
  };
584
1030
  }
585
- const u = wt(w, r), k = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((p) => et(d(p), r)), E = wt(h, r).point, b = q(e.roll ?? 0), M = (p) => {
586
- const T = p.x - E.x, v = p.y - E.y;
587
- return { x: E.x + T * Math.cos(b) - v * Math.sin(b), y: E.y + T * Math.sin(b) + v * Math.cos(b) };
588
- }, P = ([p, T, v]) => [p * Math.cos(b) + T * Math.sin(b), -p * Math.sin(b) + T * Math.cos(b), v];
589
- for (const p of Object.values(m)) p.points = p.points.map(M);
590
- const S = {
591
- center: M(u.point),
592
- depth: u.depth,
593
- rx: y,
594
- ry: f,
1031
+ const p = vt(u, s), x = [[1, 0, 0], [0, 1, 0], [0, 0, 1]].map((w) => ht(d(w), s)), E = vt(h, s).point, b = K(e.roll ?? 0), M = (w) => {
1032
+ const S = w.x - E.x, v = w.y - E.y;
1033
+ return { x: E.x + S * Math.cos(b) - v * Math.sin(b), y: E.y + S * Math.sin(b) + v * Math.cos(b) };
1034
+ }, T = ([w, S, v]) => [w * Math.cos(b) + S * Math.sin(b), -w * Math.sin(b) + S * Math.cos(b), v];
1035
+ for (const w of Object.values(y)) w.points = w.points.map(M);
1036
+ const P = {
1037
+ center: M(p.point),
1038
+ depth: p.depth,
1039
+ rx: m,
1040
+ ry: c,
595
1041
  angle: 0,
596
- axes: k.map(P)
597
- }, W = S.axes[1];
598
- S.angle = Math.atan2(W[0], W[1]);
599
- const H = (p) => {
600
- if ("head" in p) return { x: S.center.x + W[0] * f, y: S.center.y - W[1] * f };
601
- const T = m[p.chain];
602
- return T.points[Math.min(p.joint, T.points.length - 1)];
1042
+ axes: x.map(T)
1043
+ }, I = P.axes[1];
1044
+ P.angle = Math.atan2(I[0], I[1]);
1045
+ const O = (w) => {
1046
+ if ("head" in w) return { x: P.center.x + I[0] * c, y: P.center.y - I[1] * c };
1047
+ const S = y[w.chain];
1048
+ return S.points[Math.min(w.joint, S.points.length - 1)];
603
1049
  };
604
- let Y = 0;
605
- (n.contact ?? "ground") === "ground" && (Y = -Math.max(...t.contacts.map((p) => H(p).y))), Y -= (e.lift ?? 0) * o;
606
- const I = (p) => ({ x: p.x, y: p.y + Y });
607
- for (const p of Object.values(m)) p.points = p.points.map(I);
608
- S.center = I(S.center);
609
- const x = t.contacts.map((p) => ({ spec: p, point: H(p) }));
1050
+ let H = 0;
1051
+ (n.contact ?? "ground") === "ground" && (H = -Math.max(...t.contacts.map((w) => O(w).y))), H -= (e.lift ?? 0) * o;
1052
+ const _ = (w) => ({ x: w.x, y: w.y + H });
1053
+ for (const w of Object.values(y)) w.points = w.points.map(_);
1054
+ P.center = _(P.center);
1055
+ const k = t.contacts.map((w) => ({ spec: w, point: O(w) }));
610
1056
  return {
611
1057
  height: o,
612
- view: r,
613
- chains: m,
614
- head: S,
615
- hip: I(M(E)),
616
- contacts: x,
617
- groundY: Math.max(...x.map((p) => p.point.y))
1058
+ view: s,
1059
+ chains: y,
1060
+ head: P,
1061
+ hip: _(M(E)),
1062
+ contacts: k,
1063
+ groundY: Math.max(...k.map((w) => w.point.y))
618
1064
  };
619
1065
  }
620
- function de(t, [e, n, o]) {
621
- const [r, s, h] = t.axes, i = [
622
- r[0] * e * t.rx + s[0] * n * t.ry + h[0] * o * t.rx,
623
- r[1] * e * t.rx + s[1] * n * t.ry + h[1] * o * t.rx,
624
- r[2] * e * t.rx + s[2] * n * t.ry + h[2] * o * t.rx
625
- ], l = Math.hypot(e, n, o) || 1, a = (r[2] * e + s[2] * n + h[2] * o) / l;
1066
+ function Oe(t, [e, n, o]) {
1067
+ const [s, r, h] = t.axes, i = [
1068
+ s[0] * e * t.rx + r[0] * n * t.ry + h[0] * o * t.rx,
1069
+ s[1] * e * t.rx + r[1] * n * t.ry + h[1] * o * t.rx,
1070
+ s[2] * e * t.rx + r[2] * n * t.ry + h[2] * o * t.rx
1071
+ ], l = Math.hypot(e, n, o) || 1, a = (s[2] * e + r[2] * n + h[2] * o) / l;
626
1072
  return { point: { x: t.center.x + i[0], y: t.center.y - i[1] }, depth: t.depth + i[2], facing: a };
627
1073
  }
628
- const rt = (t) => t * 180 / Math.PI, j = (t, e) => [t[0] - e[0], t[1] - e[1], t[2] - e[2]], bt = (t, e) => t[0] * e[0] + t[1] * e[1] + t[2] * e[2], tt = (t) => Math.hypot(t[0], t[1], t[2]), Wt = (t) => {
629
- const e = tt(t) || 1;
1074
+ const dt = (t) => t * 180 / Math.PI, Q = (t, e) => [t[0] - e[0], t[1] - e[1], t[2] - e[2]], It = (t, e) => t[0] * e[0] + t[1] * e[1] + t[2] * e[2], it = (t) => Math.hypot(t[0], t[1], t[2]), Nt = (t) => {
1075
+ const e = it(t) || 1;
630
1076
  return [t[0] / e, t[1] / e, t[2] / e];
631
- }, it = (t) => Math.atan2(Math.sin(t), Math.cos(t));
632
- function Ct(t) {
633
- const [e, n, o] = Wt(t);
1077
+ }, ut = (t) => Math.atan2(Math.sin(t), Math.cos(t));
1078
+ function ie(t) {
1079
+ const [e, n, o] = Nt(t);
634
1080
  return { swing: Math.asin(Math.max(-1, Math.min(1, o))), spread: Math.atan2(e, -n) };
635
1081
  }
636
- function Je(t, e, n, o, r) {
637
- const s = t.chains.find((Y) => Y.id === n);
638
- if (!s) throw new Error(`reach: no chain ${n} in ${t.id}`);
639
- if (s.bones.length < 2 || s.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
1082
+ function Cn(t, e, n, o, s) {
1083
+ const r = t.chains.find((H) => H.id === n);
1084
+ if (!r) throw new Error(`reach: no chain ${n} in ${t.id}`);
1085
+ if (r.bones.length < 2 || r.rest[1] > -0.99) throw new Error(`reach: ${n} is not a hanging limb of two bones or more`);
640
1086
  if (!t.withAngles) throw new Error(`reach: the ${t.id} plan cannot set angles`);
641
- const h = It(t, { ...e, turn: 0, roll: 0, lift: 0 }, { height: r.height, contact: "none" }), i = h.chains[n], l = i.joints3[0], a = tt(j(i.joints3[1], i.joints3[0])), c = tt(j(i.joints3[2], i.joints3[1])), g = s.parent ? h.chains[s.parent].frames[Math.max(0, (s.at ?? h.chains[s.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, y = j(o, l), f = Math.min(a + c - 1e-6, Math.max(Math.abs(a - c) + 1e-6, tt(y))), d = Wt(y), w = s.parent !== null, m = at(s.pole ?? (w ? [0, -0.35, -1] : [0, 0, 1]), g);
642
- let u = j(m, [d[0] * bt(m, d), d[1] * bt(m, d), d[2] * bt(m, d)]);
643
- tt(u) < 1e-6 && (u = et([1, 0, 0], 0)), u = Wt(u);
644
- const k = (a * a + f * f - c * c) / (2 * a * f), E = Math.sqrt(Math.max(0, 1 - k * k)), b = [
645
- l[0] + a * (k * d[0] + E * u[0]),
646
- l[1] + a * (k * d[1] + E * u[1]),
647
- l[2] + a * (k * d[2] + E * u[2])
648
- ], M = [l[0] + d[0] * f, l[1] + d[1] * f, l[2] + d[2] * f], P = s.side ?? 1, S = Ct(j(b, l)), W = Ct(j(M, b)), H = [
649
- { swing: rt(it(S.swing - g.swing)), spread: rt(it(S.spread - g.spread)) * P },
650
- { swing: rt(it(W.swing - S.swing)), spread: rt(it(W.spread - S.spread)) * P }
1087
+ const h = Dt(t, { ...e, turn: 0, roll: 0, lift: 0 }, { height: s.height, contact: "none" }), i = h.chains[n], l = i.joints3[0], a = it(Q(i.joints3[1], i.joints3[0])), f = it(Q(i.joints3[2], i.joints3[1])), g = r.parent ? h.chains[r.parent].frames[Math.max(0, (r.at ?? h.chains[r.parent].joints3.length - 1) - 1)] : { swing: 0, spread: 0 }, m = Q(o, l), c = Math.min(a + f - 1e-6, Math.max(Math.abs(a - f) + 1e-6, it(m))), d = Nt(m), u = r.parent !== null, y = pt(r.pole ?? (u ? [0, -0.35, -1] : [0, 0, 1]), g);
1088
+ let p = Q(y, [d[0] * It(y, d), d[1] * It(y, d), d[2] * It(y, d)]);
1089
+ it(p) < 1e-6 && (p = ht([1, 0, 0], 0)), p = Nt(p);
1090
+ const x = (a * a + c * c - f * f) / (2 * a * c), E = Math.sqrt(Math.max(0, 1 - x * x)), b = [
1091
+ l[0] + a * (x * d[0] + E * p[0]),
1092
+ l[1] + a * (x * d[1] + E * p[1]),
1093
+ l[2] + a * (x * d[2] + E * p[2])
1094
+ ], M = [l[0] + d[0] * c, l[1] + d[1] * c, l[2] + d[2] * c], T = r.side ?? 1, P = ie(Q(b, l)), I = ie(Q(M, b)), O = [
1095
+ { swing: dt(ut(P.swing - g.swing)), spread: dt(ut(P.spread - g.spread)) * T },
1096
+ { swing: dt(ut(I.swing - P.swing)), spread: dt(ut(I.spread - P.spread)) * T }
651
1097
  ];
652
- return t.withAngles(e, s, H);
653
- }
654
- function Xt(t, e, n, o, r, s = 0, h = 1, i = 40) {
655
- const l = Math.cos(r), a = Math.sin(r);
656
- return Array.from({ length: i + 1 }, (c, g) => {
657
- const y = s + Math.PI * 2 * h * g / i, f = Math.cos(y) * n, d = Math.sin(y) * o;
658
- return { x: t + f * l - d * a, y: e + f * a + d * l };
659
- });
660
- }
661
- function ze(t, e) {
662
- return e.look === "pencil" ? Ve(t, e) : Ge(t, e.ink, e.look);
663
- }
664
- function ft(t, e, n = !1) {
665
- t.beginPath(), t.moveTo(e[0].x, e[0].y);
666
- for (const o of e.slice(1)) t.lineTo(o.x, o.y);
667
- n && t.closePath();
1098
+ return t.withAngles(e, r, O);
668
1099
  }
669
- function Ge(t, e, n) {
670
- const o = n === "silhouette", r = o ? 1.25 : 1;
1100
+ const Un = 0.34, G = 0.12, N = -0.4, U = (t, e, n) => t[e] ?? n, Xn = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), Dn = 0.45, qn = 0.35, Kn = 0.7;
1101
+ function Mt(t, e, n) {
1102
+ const o = (c) => Math.sqrt(Math.max(0, 1 - c.x * c.x - c.y * c.y)), s = Oe(t, [n.x, n.y, o(n)]).facing, r = t.axes[2], h = Math.atan2(r[0], r[2]), i = Math.cos(h), l = i >= 0 ? 1 : -1, a = l * Math.max(qn, Math.abs(i)), f = l * Math.max(Kn, Math.abs(i)), g = Math.cos(t.angle), m = Math.sin(t.angle);
671
1103
  return {
672
- look: n,
673
- ink: e,
674
- limb(s, h, i) {
675
- t.fillStyle = e, Jt(t, s, h * r, i * r);
676
- },
677
- line(s, h) {
678
- s.length < 2 || (t.strokeStyle = e, t.lineWidth = h * r, t.lineCap = "round", t.lineJoin = "round", ft(t, s), t.stroke());
679
- },
680
- shape(s, h, i) {
681
- ft(t, s, !0), (h !== null || o) && (t.fillStyle = o ? e : h, t.fill()), !(i <= 0) && (t.strokeStyle = e, t.lineWidth = i * r, t.lineJoin = "round", t.stroke());
682
- },
683
- ellipse(s, h, i, l, a, c, g) {
684
- t.beginPath(), t.ellipse(s, h, i, l, a, 0, Math.PI * 2), (c !== null || o) && (t.fillStyle = o ? e : c, t.fill()), !(g <= 0) && (t.strokeStyle = e, t.lineWidth = g * r, t.stroke());
685
- },
686
- dot(s, h, i) {
687
- t.fillStyle = e, t.beginPath(), t.arc(s, h, i * r, 0, Math.PI * 2), t.fill();
688
- },
689
- guide() {
690
- },
691
- guideEllipse() {
692
- }
693
- };
694
- }
695
- function Ze(t, e) {
696
- const n = [t[0]];
697
- let o = 0;
698
- for (let h = 1; h < t.length; h++) {
699
- const i = t[h - 1], l = t[h], a = Math.hypot(l.x - i.x, l.y - i.y);
700
- let c = e - o;
701
- for (; c < a; ) {
702
- const g = c / a;
703
- n.push({ x: i.x + (l.x - i.x) * g, y: i.y + (l.y - i.y) * g }), c += e;
704
- }
705
- o = a - (c - e);
706
- }
707
- const r = t[t.length - 1], s = n[n.length - 1];
708
- return Math.hypot(r.x - s.x, r.y - s.y) > e * 0.25 ? n.push(r) : n[n.length - 1] = r, n;
709
- }
710
- function Qe(t, e) {
711
- const n = t.length;
712
- return t.map((o, r) => {
713
- const s = t[Math.max(0, r - 1)], h = t[Math.min(n - 1, r + 1)], i = Math.hypot(h.x - s.x, h.y - s.y) || 1, l = e(n === 1 ? 0 : r / (n - 1));
714
- return { x: o.x - (h.y - s.y) / i * l, y: o.y + (h.x - s.x) / i * l };
715
- });
716
- }
717
- function qt(t) {
718
- const e = [0.6, 1.4, 2.9].map((o) => ({
719
- frequency: o * (0.8 + t.next() * 0.4),
720
- phase: t.next() * Math.PI * 2,
721
- amount: 0.5 + t.next() * 0.5
722
- })), n = e.reduce((o, r) => o + r.amount, 0);
723
- return (o) => e.reduce((r, s) => r + s.amount * Math.sin(Math.PI * 2 * s.frequency * o + s.phase), 0) / n;
724
- }
725
- function Ve(t, e) {
726
- const n = e.pencil ?? {}, o = e.ink, r = n.roughness ?? Math.max(1, e.lineWidth * 0.12), s = Math.max(1, Math.round(n.passes ?? 2)), h = Math.min(1, Math.max(0, n.pressure ?? 0.25)), i = Math.min(1, Math.max(0, n.rubbedOut ?? 0.15)), l = ye(e.time, n.boil ?? 8);
727
- let a = 0;
728
- const c = (d, w, m = !1) => me(pe(`${e.seed}:${m ? "paper" : l}:${d}:${w}`)), g = (d, w, m, u, k, E = 0) => {
729
- if (d.length < 2) return;
730
- const b = d.slice(1).reduce((I, x, p) => I + Math.hypot(x.x - d[p].x, x.y - d[p].y), 0);
731
- let M = Ze(d, Math.max(1.5, Math.min(e.lineWidth * 0.8, b / 24)));
732
- if (E > 0 && M.length >= 2) {
733
- const [I, x] = [M[M.length - 2], M[M.length - 1]], p = Math.hypot(x.x - I.x, x.y - I.y) || 1;
734
- M = [...M, { x: x.x + (x.x - I.x) / p * E, y: x.y + (x.y - I.y) / p * E }];
735
- }
736
- const P = qt(m), S = qt(m), W = M.length, H = [], Y = [];
737
- M.forEach((I, x) => {
738
- const p = W === 1 ? 0 : x / (W - 1), T = M[Math.max(0, x - 1)], v = M[Math.min(W - 1, x + 1)], O = Math.hypot(v.x - T.x, v.y - T.y) || 1, A = -(v.y - T.y) / O, Z = (v.x - T.x) / O, nt = P(p) * k, ut = Math.min(1, p / 0.08, (1 - p) / 0.08), gt = (0.55 + 0.45 * Math.sqrt(Math.max(0, ut))) * (1 + h * S(p)), X = Math.max(0.3, w(p) * gt / 2), Q = I.x + A * nt, D = I.y + Z * nt;
739
- H.push({ x: Q + A * X, y: D + Z * X }), Y.push({ x: Q - A * X, y: D - Z * X });
740
- }), t.save(), t.globalAlpha *= u, t.fillStyle = o, ft(t, [...H, ...Y.reverse()], !0), t.fill(), t.restore();
741
- }, y = (d, w) => {
742
- const m = a++, u = c(m, 99, !0);
743
- if (u.next() < i) {
744
- const M = (u.next() * 2 - 1) * e.lineWidth * 1.4, P = (u.next() * 2 - 1) * e.lineWidth * 1.4, S = d.map((W) => ({ x: W.x + M, y: W.y + P }));
745
- g(S, (W) => w(W) * 1.8, c(m, 98, !0), 0.035, r), g(S, (W) => w(W) * 0.45, c(m, 97, !0), 0.12, r * 1.5);
746
- }
747
- const k = d.slice(1).reduce((M, P, S) => M + Math.hypot(P.x - d[S].x, P.y - d[S].y), 0), E = w(0.5) > 4 && k > w(0.5) * 6, b = E ? [-0.3, 0.3, 0] : [0];
748
- for (let M = 0; M < s; M++) {
749
- const P = M === 0;
750
- b.forEach((S, W) => {
751
- const H = c(m, M * 10 + W), Y = S === 0 ? d : Qe(d, (x) => w(x) * S * Math.sqrt(Math.sin(Math.PI * x))), I = !P && S === 0 ? e.lineWidth * (0.3 + H.next() * 0.8) : 0;
752
- g(Y, (x) => w(x) * (E ? 0.5 : 1) * (P ? 1 : 0.6), H, P ? 0.85 : 0.45, r * (P ? 0.6 : 1), I);
753
- });
754
- }
755
- }, f = (d, w, m, u, k, E) => {
756
- const M = c(a, 50).next() * Math.PI * 2;
757
- y(Xt(d, w, m, u, k, M, 1.08, 48), () => E);
758
- };
759
- return {
760
- look: "pencil",
761
- ink: o,
762
- limb(d, w, m) {
763
- y(d, (u) => w + (m - w) * u);
764
- },
765
- line(d, w) {
766
- y(d, () => w);
767
- },
768
- shape(d, w, m) {
769
- w !== null && (t.save(), t.globalAlpha *= 0.88, t.fillStyle = w, ft(t, d, !0), t.fill(), t.restore()), m > 0 && y([...d, d[0]], () => m);
770
- },
771
- ellipse(d, w, m, u, k, E, b) {
772
- E !== null && (t.save(), t.globalAlpha *= 0.9, t.fillStyle = E, t.beginPath(), t.ellipse(d, w, m, u, k, 0, Math.PI * 2), t.fill(), t.restore()), f(d, w, m, u, k, b);
773
- },
774
- dot(d, w, m) {
775
- t.save(), t.globalAlpha *= 0.9, t.fillStyle = o, t.beginPath(), t.arc(d, w, m, 0, Math.PI * 2), t.fill(), t.restore();
776
- },
777
- guide(d) {
778
- if (n.construction === !1 || d.length < 2) return;
779
- const w = a++;
780
- g(d, () => Math.max(0.6, e.lineWidth * 0.18), c(w, 0), 0.28, r * 1.2, e.lineWidth);
781
- },
782
- guideEllipse(d, w, m, u, k) {
783
- if (n.construction === !1) return;
784
- const E = a++, b = c(E, 0), M = Xt(d, w, m, u, k, b.next() * Math.PI * 2, 1.12, 48);
785
- g(M, () => Math.max(0.6, e.lineWidth * 0.18), b, 0.28, r * 1.5);
786
- }
787
- };
788
- }
789
- const tn = 0.34, U = 0.12, L = -0.4, F = (t, e, n) => t[e] ?? n, en = (t, e) => Math.max(0, t) * (1 - Math.min(1, Math.max(0, e))), nn = 0.45, on = 0.35, sn = 0.7;
790
- function dt(t, e, n) {
791
- const o = (f) => Math.sqrt(Math.max(0, 1 - f.x * f.x - f.y * f.y)), r = de(t, [n.x, n.y, o(n)]).facing, s = t.axes[2], h = Math.atan2(s[0], s[2]), i = Math.cos(h), l = i >= 0 ? 1 : -1, a = l * Math.max(on, Math.abs(i)), c = l * Math.max(sn, Math.abs(i)), g = Math.cos(t.angle), y = Math.sin(t.angle);
792
- return {
793
- facing: r,
794
- points: e.map((f) => {
795
- const d = nn * Math.sin(h) + n.x * a + (f.x - n.x) * c, w = f.y + s[1] * o(f), m = d * t.rx, u = w * t.ry;
796
- return { x: t.center.x + m * g + u * y, y: t.center.y + m * y - u * g };
1104
+ facing: s,
1105
+ points: e.map((c) => {
1106
+ const d = Dn * Math.sin(h) + n.x * a + (c.x - n.x) * f, u = c.y + r[1] * o(c), y = d * t.rx, p = u * t.ry;
1107
+ return { x: t.center.x + y * g + p * m, y: t.center.y + y * m - p * g };
797
1108
  })
798
1109
  };
799
1110
  }
800
- const lt = (t, e, n, o = 12) => Array.from({ length: o + 1 }, (r, s) => {
801
- const h = s / o, i = 1 - h;
1111
+ const gt = (t, e, n, o = 12) => Array.from({ length: o + 1 }, (s, r) => {
1112
+ const h = r / o, i = 1 - h;
802
1113
  return { x: i * i * t.x + 2 * i * h * e.x + h * h * n.x, y: i * i * t.y + 2 * i * h * e.y + h * h * n.y };
803
- }), Mt = (t, e, n, o, r = 16) => Array.from({ length: r }, (s, h) => {
804
- const i = Math.PI * 2 * h / r;
1114
+ }), At = (t, e, n, o, s = 16) => Array.from({ length: s }, (r, h) => {
1115
+ const i = Math.PI * 2 * h / s;
805
1116
  return { x: t + Math.cos(i) * n, y: e + Math.sin(i) * o };
806
- }), Ut = 0.05;
807
- function rn(t, e, n, o) {
808
- const r = Math.max(1, Math.min(o * 0.6, 0.14 * e.rx)), s = (u, k) => dt(e, u, k).points, h = (u, k) => dt(e, [], { x: u, y: k }).facing, i = F(n, "smile", 0), l = F(n, "blink", 0), a = F(n, "lookX", 0), c = F(n, "lookY", 0), g = F(n, "browTilt", 0);
809
- for (const u of [1, -1]) {
810
- const k = u === 1 ? "left" : "right", E = tn * u;
811
- if (h(E, U) < Ut) continue;
812
- const b = { x: E, y: U }, M = en(F(n, `eye.${k}`, 1), l);
1117
+ }), le = 0.05;
1118
+ function Gn(t, e, n, o) {
1119
+ const s = Math.max(1, Math.min(o * 0.6, 0.14 * e.rx)), r = (p, x) => Mt(e, p, x).points, h = (p, x) => Mt(e, [], { x: p, y: x }).facing, i = U(n, "smile", 0), l = U(n, "blink", 0), a = U(n, "lookX", 0), f = U(n, "lookY", 0), g = U(n, "browTilt", 0);
1120
+ for (const p of [1, -1]) {
1121
+ const x = p === 1 ? "left" : "right", E = Un * p;
1122
+ if (h(E, G) < le) continue;
1123
+ const b = { x: E, y: G }, M = Xn(U(n, `eye.${x}`, 1), l);
813
1124
  if (M < 0.2) {
814
- const H = i > 0.5 ? 0.12 : -0.06;
815
- t.line(s(lt({ x: E - 0.12, y: U }, { x: E, y: U + H }, { x: E + 0.12, y: U }), b), r);
1125
+ const O = i > 0.5 ? 0.12 : -0.06;
1126
+ t.line(r(gt({ x: E - 0.12, y: G }, { x: E, y: G + O }, { x: E + 0.12, y: G }), b), s);
816
1127
  } else {
817
1128
  if (M > 1.2) {
818
- const x = 0.13 * M;
819
- t.shape(s(Mt(E, U, x * 0.85, x), b), "#ffffff", r);
1129
+ const k = 0.13 * M;
1130
+ t.shape(r(At(E, G, k * 0.85, k), b), "#ffffff", s);
820
1131
  }
821
- const H = M > 1.2 ? 0.075 : 0.1, Y = E + a * 0.08, I = U - c * 0.07;
822
- t.shape(s(Mt(Y, I, H, H * 1.1 * Math.min(M, 1)), b), t.ink, 0);
1132
+ const O = M > 1.2 ? 0.075 : 0.1, H = E + a * 0.08, _ = G - f * 0.07;
1133
+ t.shape(r(At(H, _, O, O * 1.1 * Math.min(M, 1)), b), t.ink, 0);
823
1134
  }
824
- const P = U + 0.3 + F(n, `brow.${k}`, 0) * 0.14 + Math.max(0, M - 1) * 0.12, S = { x: E + u * 0.13, y: P }, W = { x: E - u * 0.13, y: P + g * 0.1 };
825
- t.line(s([S, { x: (S.x + W.x) / 2, y: (S.y + W.y) / 2 }, W], { x: E, y: P }), r);
1135
+ const T = G + 0.3 + U(n, `brow.${x}`, 0) * 0.14 + Math.max(0, M - 1) * 0.12, P = { x: E + p * 0.13, y: T }, I = { x: E - p * 0.13, y: T + g * 0.1 };
1136
+ t.line(r([P, { x: (P.x + I.x) / 2, y: (P.y + I.y) / 2 }, I], { x: E, y: T }), s);
826
1137
  }
827
- const y = { x: 0, y: L };
828
- if (h(0, L) < -Ut) return;
829
- const f = 0.25 * Math.max(0.3, F(n, "mouthWidth", 1)), d = Math.min(1, Math.max(0, F(n, "mouth", 0)));
1138
+ const m = { x: 0, y: N };
1139
+ if (h(0, N) < -le) return;
1140
+ const c = 0.25 * Math.max(0.3, U(n, "mouthWidth", 1)), d = Math.min(1, Math.max(0, U(n, "mouth", 0)));
830
1141
  if (d <= 0.05) {
831
- t.line(s(lt({ x: -f, y: L }, { x: 0, y: L - i * 0.25 }, { x: f, y: L }), y), r);
1142
+ t.line(r(gt({ x: -c, y: N }, { x: 0, y: N - i * 0.25 }, { x: c, y: N }), m), s);
832
1143
  return;
833
1144
  }
834
- const w = 0.3 * d;
835
- let m;
1145
+ const u = 0.3 * d;
1146
+ let y;
836
1147
  if (i > 0.3) {
837
- const u = L + 0.05;
838
- m = [...lt({ x: f, y: u }, { x: 0, y: L - w * 2 }, { x: -f, y: u })];
1148
+ const p = N + 0.05;
1149
+ y = [...gt({ x: c, y: p }, { x: 0, y: N - u * 2 }, { x: -c, y: p })];
839
1150
  } else if (i < -0.3) {
840
- const u = L - w * 0.6;
841
- m = [...lt({ x: f, y: u }, { x: 0, y: L + w * 1.4 }, { x: -f, y: u })];
1151
+ const p = N - u * 0.6;
1152
+ y = [...gt({ x: c, y: p }, { x: 0, y: N + u * 1.4 }, { x: -c, y: p })];
842
1153
  } else
843
- m = Mt(0, L, f * 0.8, w);
844
- t.shape(s(m, y), t.ink, 0);
1154
+ y = At(0, N, c * 0.8, u);
1155
+ t.shape(r(y, m), t.ink, 0);
845
1156
  }
846
- const kt = 0.215, Et = 0.205, ln = 0.065, Kt = 0.035, hn = 0.165, an = 0.155, cn = 12, K = {
1157
+ const Ot = 0.215, _t = 0.205, Jn = 0.065, he = 0.035, zn = 0.165, jn = 0.155, Zn = 12, z = {
847
1158
  turn: 0,
848
1159
  lean: 0,
849
1160
  side: 0,
@@ -881,24 +1192,24 @@ const kt = 0.215, Et = 0.205, ln = 0.065, Kt = 0.035, hn = 0.165, an = 0.155, cn
881
1192
  lookX: 0,
882
1193
  lookY: 0
883
1194
  };
884
- function R(t = {}) {
885
- return { ...K, ...t };
1195
+ function F(t = {}) {
1196
+ return { ...z, ...t };
886
1197
  }
887
- function $(t, e) {
1198
+ function Y(t, e) {
888
1199
  const n = {};
889
- for (const o of ["left", "right"]) for (const [r, s] of Object.entries(e)) n[`${t}.${o}.${r}`] = s;
1200
+ for (const o of ["left", "right"]) for (const [s, r] of Object.entries(e)) n[`${t}.${o}.${s}`] = r;
890
1201
  return n;
891
1202
  }
892
- const fn = {
893
- rest: K,
894
- wave: R({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
895
- cheer: R({ ...$("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
896
- point: R({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
897
- handsOnHips: R({ ...$("arm", { spread: 50, bend: -105, elbow: 0 }), ...$("leg", { spread: 9 }), smile: 0.8 }),
898
- think: R({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
899
- shrug: R({ ...$("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
900
- sit: R({ ...$("leg", { swing: 90, knee: 90, spread: 4 }), ...$("arm", { swing: 25, elbow: 45, spread: 8 }) }),
901
- kneel: R({
1203
+ const Qn = {
1204
+ rest: z,
1205
+ wave: F({ "arm.right.spread": 115, "arm.right.bend": 55, "arm.right.elbow": 0, "head.tilt": -6, smile: 0.9 }),
1206
+ cheer: F({ ...Y("arm", { spread: 140, bend: 20, elbow: 0 }), mouth: 0.6, smile: 1, "eye.left": 0, "eye.right": 0 }),
1207
+ point: F({ "arm.right.spread": 88, "arm.right.elbow": 0, "arm.right.bend": 0, "head.turn": -20, smile: 0.4 }),
1208
+ handsOnHips: F({ ...Y("arm", { spread: 50, bend: -105, elbow: 0 }), ...Y("leg", { spread: 9 }), smile: 0.8 }),
1209
+ think: F({ "arm.right.spread": 22, "arm.right.bend": -150, "arm.right.elbow": 0, "head.tilt": 10, lookX: -0.5, lookY: -0.8, smile: 0 }),
1210
+ shrug: F({ ...Y("arm", { spread: 35, bend: 75, elbow: 0 }), "head.tilt": -10, smile: -0.2 }),
1211
+ sit: F({ ...Y("leg", { swing: 90, knee: 90, spread: 4 }), ...Y("arm", { swing: 25, elbow: 45, spread: 8 }) }),
1212
+ kneel: F({
902
1213
  "leg.left.swing": 90,
903
1214
  "leg.left.knee": 90,
904
1215
  // The back thigh leans back a little so its knee meets the ground beside the
@@ -906,24 +1217,24 @@ const fn = {
906
1217
  "leg.right.swing": -18,
907
1218
  "leg.right.knee": 108,
908
1219
  "leg.right.ankle": 16,
909
- ...$("arm", { swing: 20, elbow: 30 })
1220
+ ...Y("arm", { swing: 20, elbow: 30 })
910
1221
  }),
911
- crouch: R({ ...$("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...$("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
1222
+ crouch: F({ ...Y("leg", { swing: 75, knee: 140, spread: 6 }), lean: 25, ...Y("arm", { swing: 50, elbow: 40 }), "head.nod": -15 }),
912
1223
  // On hands and knees: the back nearly level, arms straight down, the toes
913
1224
  // pointed back along the ground.
914
- crawl: R({ lean: 82, "head.nod": -35, ...$("arm", { swing: 80, elbow: 0, spread: 4 }), ...$("leg", { knee: 92, ankle: -88 }) }),
915
- lieDown: R({ roll: 90, ...$("arm", { spread: 8 }), "head.nod": 0 })
1225
+ crawl: F({ lean: 82, "head.nod": -35, ...Y("arm", { swing: 80, elbow: 0, spread: 4 }), ...Y("leg", { knee: 92, ankle: -88 }) }),
1226
+ lieDown: F({ roll: 90, ...Y("arm", { spread: 8 }), "head.nod": 0 })
916
1227
  };
917
- function dn(t = {}) {
918
- const e = t.headSize ?? 0.3, n = t.shoulderWidth ?? 0.06, o = t.hipWidth ?? 0.022, r = Math.max(0.12, 1 - e - Kt - (kt + Et)), s = (l) => ({
1228
+ function Vn(t = {}) {
1229
+ const e = t.headSize ?? 0.3, n = t.shoulderWidth ?? 0.06, o = t.hipWidth ?? 0.022, s = Math.max(0.12, 1 - e - he - (Ot + _t)), r = (l) => ({
919
1230
  id: `arm.${l}`,
920
1231
  parent: "spine",
921
1232
  offset: [(l === "left" ? 1 : -1) * n, -0.035, 0],
922
1233
  rest: [0, -1, 0],
923
1234
  side: l === "left" ? 1 : -1,
924
1235
  bones: [
925
- { length: hn, width: [1.25, 0.9] },
926
- { length: an, width: [0.9, 0.75] }
1236
+ { length: zn, width: [1.25, 0.9] },
1237
+ { length: jn, width: [0.9, 0.75] }
927
1238
  ]
928
1239
  }), h = (l) => ({
929
1240
  id: `leg.${l}`,
@@ -932,14 +1243,14 @@ function dn(t = {}) {
932
1243
  rest: [0, -1, 0],
933
1244
  side: l === "left" ? 1 : -1,
934
1245
  bones: [
935
- { length: kt, width: [1.45, 1.05] },
936
- { length: Et, width: [1.05, 0.85] },
937
- { length: ln, width: [0.95, 0.7] }
1246
+ { length: Ot, width: [1.45, 1.05] },
1247
+ { length: _t, width: [1.05, 0.85] },
1248
+ { length: Jn, width: [0.95, 0.7] }
938
1249
  ]
939
- }), i = (l, a) => l[a] ?? K[a] ?? 0;
1250
+ }), i = (l, a) => l[a] ?? z[a] ?? 0;
940
1251
  return {
941
1252
  id: "human",
942
- hipHeight: kt + Et,
1253
+ hipHeight: Ot + _t,
943
1254
  // Tie order: legs, then the body, then the arms (in front of the chest unless turned away), then the head.
944
1255
  chains: [
945
1256
  h("left"),
@@ -949,13 +1260,13 @@ function dn(t = {}) {
949
1260
  parent: null,
950
1261
  rest: [0, 1, 0],
951
1262
  bones: [
952
- { length: r / 2, width: [1.7, 1.4] },
953
- { length: r / 2, width: [1.4, 1.1] }
1263
+ { length: s / 2, width: [1.7, 1.4] },
1264
+ { length: s / 2, width: [1.4, 1.1] }
954
1265
  ]
955
1266
  },
956
- { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: Kt, width: [1, 0.9] }] },
957
- s("left"),
958
- s("right")
1267
+ { id: "neck", parent: "spine", rest: [0, 1, 0], bones: [{ length: he, width: [1, 0.9] }] },
1268
+ r("left"),
1269
+ r("right")
959
1270
  ],
960
1271
  head: { on: "neck", size: e },
961
1272
  contacts: [
@@ -973,37 +1284,37 @@ function dn(t = {}) {
973
1284
  ],
974
1285
  angles(l, a) {
975
1286
  if (a.id === "spine") {
976
- const f = -i(l, "lean") / 2, d = i(l, "side") / 2;
1287
+ const c = -i(l, "lean") / 2, d = i(l, "side") / 2;
977
1288
  return [
978
- { swing: f, spread: d },
979
- { swing: f, spread: d }
1289
+ { swing: c, spread: d },
1290
+ { swing: c, spread: d }
980
1291
  ];
981
1292
  }
982
1293
  if (a.id === "neck") return [{ swing: 0, spread: 0 }];
983
- const [c, g] = a.id.split("."), y = (f) => i(l, `${c}.${g}.${f}`);
984
- return c === "arm" ? [
985
- { swing: y("swing"), spread: y("spread") },
986
- { swing: y("elbow"), spread: y("bend") }
1294
+ const [f, g] = a.id.split("."), m = (c) => i(l, `${f}.${g}.${c}`);
1295
+ return f === "arm" ? [
1296
+ { swing: m("swing"), spread: m("spread") },
1297
+ { swing: m("elbow"), spread: m("bend") }
987
1298
  ] : [
988
- { swing: y("swing"), spread: y("spread") },
989
- { swing: -y("knee"), spread: 0 },
1299
+ { swing: m("swing"), spread: m("spread") },
1300
+ { swing: -m("knee"), spread: 0 },
990
1301
  // The foot points forward, square to the shin, turned out a little.
991
- { swing: 90 + y("ankle"), spread: 0, yaw: cn * (a.side ?? 1) }
1302
+ { swing: 90 + m("ankle"), spread: 0, yaw: Zn * (a.side ?? 1) }
992
1303
  ];
993
1304
  },
994
- withAngles(l, a, c) {
995
- const [g, y] = a.id.split("."), f = (d) => `${g}.${y}.${d}`;
1305
+ withAngles(l, a, f) {
1306
+ const [g, m] = a.id.split("."), c = (d) => `${g}.${m}.${d}`;
996
1307
  return g === "arm" ? {
997
1308
  ...l,
998
- [f("swing")]: c[0].swing,
999
- [f("spread")]: c[0].spread,
1000
- [f("elbow")]: c[1].swing,
1001
- [f("bend")]: c[1].spread
1002
- } : g === "leg" ? { ...l, [f("swing")]: c[0].swing, [f("spread")]: c[0].spread, [f("knee")]: -c[1].swing } : l;
1309
+ [c("swing")]: f[0].swing,
1310
+ [c("spread")]: f[0].spread,
1311
+ [c("elbow")]: f[1].swing,
1312
+ [c("bend")]: f[1].spread
1313
+ } : g === "leg" ? { ...l, [c("swing")]: f[0].swing, [c("spread")]: f[0].spread, [c("knee")]: -f[1].swing } : l;
1003
1314
  },
1004
1315
  boneScale(l, a) {
1005
- const c = Math.min(3, Math.max(0.3, i(l, "stretch")));
1006
- return a?.id.startsWith("arm.") ? Math.sqrt(c) : c;
1316
+ const f = Math.min(3, Math.max(0.3, i(l, "stretch")));
1317
+ return a?.id.startsWith("arm.") ? Math.sqrt(f) : f;
1007
1318
  },
1008
1319
  headPose(l) {
1009
1320
  const a = Math.min(3, Math.max(0.3, i(l, "stretch")));
@@ -1035,18 +1346,18 @@ function dn(t = {}) {
1035
1346
  }
1036
1347
  };
1037
1348
  }
1038
- function $n(t) {
1349
+ function vo(t) {
1039
1350
  const e = t.split(".");
1040
1351
  if (e.length === 3) {
1041
- const [o, r, s] = e;
1042
- return `${`${r === "left" ? "Left" : "Right"} ${o}`} · ${{
1352
+ const [o, s, r] = e;
1353
+ return `${`${s === "left" ? "Left" : "Right"} ${o}`} · ${{
1043
1354
  swing: "forward / back",
1044
1355
  spread: "out / in",
1045
1356
  elbow: "elbow bend",
1046
1357
  bend: "forearm out / in",
1047
1358
  knee: "knee bend",
1048
1359
  ankle: "foot tilt"
1049
- }[s] ?? s}`;
1360
+ }[r] ?? r}`;
1050
1361
  }
1051
1362
  return {
1052
1363
  turn: "View (front → side → back)",
@@ -1071,126 +1382,150 @@ function $n(t) {
1071
1382
  lookY: "Look up / down"
1072
1383
  }[t] ?? t;
1073
1384
  }
1074
- const un = {
1385
+ const to = {
1075
1386
  leftEye: "eye.left",
1076
1387
  rightEye: "eye.right",
1077
1388
  leftBrow: "brow.left",
1078
1389
  rightBrow: "brow.right"
1079
- }, Bn = Object.fromEntries(
1080
- Object.entries(N).map(([t, e]) => [
1390
+ }, Io = Object.fromEntries(
1391
+ Object.entries(X).map(([t, e]) => [
1081
1392
  t,
1082
- Object.fromEntries(Object.entries(e).map(([n, o]) => [un[n] ?? n, o]))
1393
+ Object.fromEntries(Object.entries(e).map(([n, o]) => [to[n] ?? n, o]))
1083
1394
  ])
1084
1395
  );
1085
- function Rn(t = {}) {
1086
- const e = (t.proportions ?? "bold") === "bold", n = t.figure ?? "fluid", o = t.look ?? "clean", r = t.height ?? 300, s = n === "stick";
1396
+ function Ao(t = {}) {
1397
+ const e = (t.proportions ?? "bold") === "bold", n = t.figure ?? "fluid", o = t.look ?? "clean", s = t.height ?? 300, r = n === "stick";
1087
1398
  return {
1088
- plan: t.plan ?? dn({
1399
+ plan: t.plan ?? Vn({
1089
1400
  headSize: t.headSize ?? (e ? 0.3 : 0.24),
1090
- shoulderWidth: s ? 0 : t.shoulderWidth ?? 0.06,
1091
- hipWidth: s ? 0 : t.hipWidth ?? 0.022
1401
+ shoulderWidth: r ? 0 : t.shoulderWidth ?? 0.06,
1402
+ hipWidth: r ? 0 : t.hipWidth ?? 0.022
1092
1403
  }),
1093
1404
  figure: n,
1094
1405
  look: o,
1095
- height: r,
1096
- lineWidth: t.lineWidth ?? r * (e ? 0.045 : 0.022),
1406
+ height: s,
1407
+ lineWidth: t.lineWidth ?? s * (e ? 0.045 : 0.022),
1097
1408
  ink: t.ink ?? (o === "pencil" ? "#2f2f33" : "#1e293b"),
1098
1409
  skin: t.skin ?? (o === "pencil" ? "none" : "#ffffff"),
1099
1410
  seed: t.seed ?? 1,
1100
1411
  pencil: t.pencil ?? {},
1101
1412
  layers: t.layers ?? {},
1102
- contact: t.contact ?? "ground"
1413
+ contact: t.contact ?? "ground",
1414
+ hands: t.hands ?? "dot",
1415
+ handSize: t.handSize ?? 0.17
1103
1416
  };
1104
1417
  }
1105
- function Ln(t, e, n, o) {
1106
- const { point: r, facing: s } = de(t, [e, n, o]);
1107
- return { point: r, facing: s };
1108
- }
1109
- const Ot = (t) => t.rest[1] < -0.5, gn = 0.3;
1110
- function yn(t, e, n) {
1111
- return t.figure === "stick" ? Ot(e) ? n.slice(0, 3) : n : Ot(e) && n.length >= 3 ? z(n[0], n[1], n[2], gn) : n.length === 3 ? z(n[0], n[1], n[2], 1) : n;
1112
- }
1113
- function At(t, e) {
1114
- const n = t.plan.id === "human" ? { ...K, ...e } : e, o = It(t.plan, n, { height: t.height, contact: t.contact }), r = {}, s = {}, h = {}, i = 0.01 * t.height;
1115
- t.plan.chains.forEach((f) => {
1116
- const d = o.chains[f.id];
1117
- r[f.id] = d.points;
1118
- const w = d.depths.reduce((E, b) => E + b, 0) / d.depths.length, m = f.parent ? o.chains[f.parent] : void 0, u = m ? m.depths[f.at ?? m.depths.length - 1] : 0, k = w - u;
1119
- h[f.id] = Math.abs(k) < i ? 0 : k, s[f.id] = { points: yn(t, f, d.points), depth: w };
1120
- }), s.head = { points: [o.head.center], depth: o.head.depth }, h.head = 0;
1121
- const l = [...t.plan.chains.map((f) => f.id), "head"], a = [...l].sort((f, d) => h[f] - h[d] || l.indexOf(f) - l.indexOf(d)), c = { hip: o.hip };
1122
- for (const [f, [d, w]] of Object.entries(t.plan.landmarks ?? {})) {
1123
- const m = o.chains[d]?.points;
1124
- m && (c[f] = m[Math.min(w, m.length - 1)]);
1418
+ function Oo(t, e, n, o) {
1419
+ const { point: s, facing: r } = Oe(t, [e, n, o]);
1420
+ return { point: s, facing: r };
1421
+ }
1422
+ const Ct = (t) => t.rest[1] < -0.5, eo = 0.3;
1423
+ function no(t, e, n) {
1424
+ return t.figure === "stick" ? Ct(e) ? n.slice(0, 3) : n : Ct(e) && n.length >= 3 ? tt(n[0], n[1], n[2], eo) : n.length === 3 ? tt(n[0], n[1], n[2], 1) : n;
1425
+ }
1426
+ function qt(t, e) {
1427
+ const n = t.plan.id === "human" ? { ...z, ...e } : e, o = Dt(t.plan, n, { height: t.height, contact: t.contact }), s = {}, r = {}, h = {}, i = 0.01 * t.height;
1428
+ t.plan.chains.forEach((c) => {
1429
+ const d = o.chains[c.id];
1430
+ s[c.id] = d.points;
1431
+ const u = d.depths.reduce((E, b) => E + b, 0) / d.depths.length, y = c.parent ? o.chains[c.parent] : void 0, p = y ? y.depths[c.at ?? y.depths.length - 1] : 0, x = u - p;
1432
+ h[c.id] = Math.abs(x) < i ? 0 : x, r[c.id] = { points: no(t, c, d.points), depth: u };
1433
+ }), r.head = { points: [o.head.center], depth: o.head.depth }, h.head = 0;
1434
+ const l = [...t.plan.chains.map((c) => c.id), "head"], a = [...l].sort((c, d) => h[c] - h[d] || l.indexOf(c) - l.indexOf(d)), f = { hip: o.hip };
1435
+ for (const [c, [d, u]] of Object.entries(t.plan.landmarks ?? {})) {
1436
+ const y = o.chains[d]?.points;
1437
+ y && (f[c] = y[Math.min(u, y.length - 1)]);
1125
1438
  }
1126
1439
  const g = {};
1127
- for (const [f, d] of Object.entries(c)) g[f] = d.y >= o.groundY - 0.01 * t.height;
1128
- const y = {
1440
+ for (const [c, d] of Object.entries(f)) g[c] = d.y >= o.groundY - 0.01 * t.height;
1441
+ const m = {
1129
1442
  height: t.height,
1130
1443
  lineWidth: t.lineWidth,
1131
1444
  turn: n.turn ?? 0,
1132
- points: c,
1133
- chains: r,
1134
- parts: s,
1445
+ points: f,
1446
+ chains: s,
1447
+ parts: r,
1135
1448
  head: o.head,
1136
1449
  groundY: o.groundY,
1137
1450
  grounded: g
1138
1451
  };
1139
- return { skeleton: o, joints: y, order: a };
1452
+ return { skeleton: o, joints: m, order: a };
1140
1453
  }
1141
- function mn(t, e) {
1142
- return At(t, e).joints;
1454
+ function oo(t, e) {
1455
+ return qt(t, e).joints;
1143
1456
  }
1144
- function pn(t, e, n) {
1457
+ function so(t, e, n) {
1145
1458
  const { head: o } = n;
1146
1459
  t.guideEllipse(o.center.x, o.center.y, o.rx * 1.03, o.ry * 1.03, o.angle);
1147
- const r = Array.from({ length: 13 }, (l, a) => ({ x: 0, y: -0.95 + 1.9 * a / 12 })), s = Array.from({ length: 13 }, (l, a) => ({ x: -0.95 + 1.9 * a / 12, y: 0.12 })), h = dt(o, r, { x: 0, y: 0 });
1148
- h.facing > 0 && t.guide(h.points), t.guide(dt(o, s, { x: 0, y: 0.12 }).points), t.guide(n.chains.spine ?? []);
1460
+ const s = Array.from({ length: 13 }, (l, a) => ({ x: 0, y: -0.95 + 1.9 * a / 12 })), r = Array.from({ length: 13 }, (l, a) => ({ x: -0.95 + 1.9 * a / 12, y: 0.12 })), h = Mt(o, s, { x: 0, y: 0 });
1461
+ h.facing > 0 && t.guide(h.points), t.guide(Mt(o, r, { x: 0, y: 0.12 }).points), t.guide(n.chains.spine ?? []);
1149
1462
  const i = e.lineWidth * 0.9;
1150
1463
  for (const l of ["shoulder.left", "shoulder.right", "elbow.left", "elbow.right", "hip.left", "hip.right", "knee.left", "knee.right"]) {
1151
1464
  const a = n.points[l];
1152
1465
  a && t.guideEllipse(a.x, a.y, i, i, 0);
1153
1466
  }
1154
1467
  }
1155
- function wn(t, e, n, o, r) {
1156
- const s = e.lineWidth;
1157
- if (o === "head") {
1158
- const { head: y } = n, f = e.skin === "none" ? null : e.skin;
1159
- t.ellipse(y.center.x, y.center.y, y.rx, y.ry, y.angle, f, s), t.look !== "silhouette" && rn(t, y, r, s);
1468
+ function ro(t, e, n, o, s, r) {
1469
+ const h = n.lineWidth;
1470
+ if (s === "head") {
1471
+ const { head: c } = o, d = n.skin === "none" ? null : n.skin;
1472
+ e.ellipse(c.center.x, c.center.y, c.rx, c.ry, c.angle, d, h), e.look !== "silhouette" && Gn(e, c, r, h);
1160
1473
  return;
1161
1474
  }
1162
- const h = e.plan.chains.find((y) => y.id === o), i = n.chains[o], l = n.parts[o].points;
1163
- if (e.figure === "stick") {
1164
- if (o === "neck") return;
1165
- const y = o === "spine" ? [...i, ...n.chains.neck?.slice(1) ?? []] : l;
1166
- t.line(y, s);
1475
+ const i = n.plan.chains.find((c) => c.id === s), l = o.chains[s], a = o.parts[s].points;
1476
+ if (n.figure === "stick") {
1477
+ if (s === "neck") return;
1478
+ const c = s === "spine" ? [...l, ...o.chains.neck?.slice(1) ?? []] : a;
1479
+ e.line(c, h);
1167
1480
  return;
1168
1481
  }
1169
- const a = (y, f) => [h.bones[y].width[0] * s, h.bones[f].width[1] * s];
1170
- if (Ot(h)) {
1171
- const [y, f] = a(0, 1);
1172
- if (t.limb(l, y, f), h.bones.length >= 3)
1173
- t.limb([i[2], i[3]], h.bones[2].width[0] * s, h.bones[2].width[1] * s);
1482
+ const f = (c, d) => [i.bones[c].width[0] * h, i.bones[d].width[1] * h];
1483
+ if (Ct(i)) {
1484
+ const [c, d] = f(0, 1);
1485
+ if (e.limb(a, c, d), i.bones.length >= 3)
1486
+ e.limb([l[2], l[3]], i.bones[2].width[0] * h, i.bones[2].width[1] * h);
1487
+ else if (n.hands === "cartoon" && s.startsWith("arm."))
1488
+ lo(t, e, n, l, s.endsWith(".left") ? "left" : "right", r);
1174
1489
  else {
1175
- const d = i[i.length - 1];
1176
- t.dot(d.x, d.y, s * 0.62);
1490
+ const u = l[l.length - 1];
1491
+ e.dot(u.x, u.y, h * 0.62);
1177
1492
  }
1178
1493
  return;
1179
1494
  }
1180
- if (o === "spine") {
1181
- const y = n.points["hip.left"], f = n.points["hip.right"];
1182
- y && f && Math.hypot(y.x - f.x, y.y - f.y) > 0.5 && t.limb([y, f], s * 1.3, s * 1.3);
1183
- const [d, w] = a(0, h.bones.length - 1);
1184
- t.limb(l, d, w);
1185
- const m = n.points["shoulder.left"], u = n.points["shoulder.right"];
1186
- m && u && Math.hypot(m.x - u.x, m.y - u.y) > 0.5 && t.limb(z(m, i[i.length - 1], u, 1, 10), s * 1.15, s * 1.15);
1495
+ if (s === "spine") {
1496
+ const c = o.points["hip.left"], d = o.points["hip.right"];
1497
+ c && d && Math.hypot(c.x - d.x, c.y - d.y) > 0.5 && e.limb([c, d], h * 1.3, h * 1.3);
1498
+ const [u, y] = f(0, i.bones.length - 1);
1499
+ e.limb(a, u, y);
1500
+ const p = o.points["shoulder.left"], x = o.points["shoulder.right"];
1501
+ p && x && Math.hypot(p.x - x.x, p.y - x.y) > 0.5 && e.limb(tt(p, l[l.length - 1], x, 1, 10), h * 1.15, h * 1.15);
1187
1502
  return;
1188
1503
  }
1189
- const [c, g] = a(0, h.bones.length - 1);
1190
- t.limb(l, c, g);
1504
+ const [g, m] = f(0, i.bones.length - 1);
1505
+ e.limb(a, g, m);
1506
+ }
1507
+ function io(t, e) {
1508
+ const n = `hand.${e}.`, o = {};
1509
+ for (const [h, i] of Object.entries(t)) h.startsWith(n) && (o[h.slice(n.length)] = i);
1510
+ const s = t.turn ?? 0, r = e === "right" ? 1 - s : 1 + s;
1511
+ return { ...kt, ...o, turn: r + (o.turn ?? 0) };
1512
+ }
1513
+ function lo(t, e, n, o, s, r) {
1514
+ const h = o[o.length - 1], i = o[o.length - 2], l = Math.atan2(h.x - i.x, -(h.y - i.y)) * 180 / Math.PI;
1515
+ xe(t, h, io(r, s), {
1516
+ size: n.handSize * n.height,
1517
+ side: s,
1518
+ angle: l,
1519
+ pen: e,
1520
+ skin: n.skin === "none" ? "#ffffff" : n.skin,
1521
+ // A cartoon glove: three fingers and a thumb, plump enough to match the limbs.
1522
+ fingers: 4,
1523
+ plump: 1.6,
1524
+ lineWidth: n.lineWidth * 0.3
1525
+ });
1191
1526
  }
1192
- function bn(t, e, n, o = 0) {
1193
- const r = e.plan.id === "human" ? { ...K, ...n } : n, { joints: s, order: h } = At(e, r), i = ze(t, {
1527
+ function ho(t, e, n, o = 0) {
1528
+ const s = e.plan.id === "human" ? { ...z, ...n } : n, { joints: r, order: h } = qt(e, s), i = ke(t, {
1194
1529
  look: e.look,
1195
1530
  ink: e.ink,
1196
1531
  lineWidth: e.lineWidth,
@@ -1198,163 +1533,174 @@ function bn(t, e, n, o = 0) {
1198
1533
  time: o,
1199
1534
  pencil: e.pencil
1200
1535
  }), l = (a) => {
1201
- a && (t.save(), a(t, s, i, o), t.restore());
1536
+ a && (t.save(), a(t, r, i, o), t.restore());
1202
1537
  };
1203
- t.save(), t.lineCap = "round", t.lineJoin = "round", e.look === "pencil" && e.pencil.construction !== !1 && pn(i, e, s), l(e.layers.behind);
1538
+ t.save(), t.lineCap = "round", t.lineJoin = "round", e.look === "pencil" && e.pencil.construction !== !1 && so(i, e, r), l(e.layers.behind);
1204
1539
  for (const a of h) {
1205
- const c = e.layers.parts?.[a];
1206
- l(c?.under), wn(i, e, s, a, r), l(c?.over);
1540
+ const f = e.layers.parts?.[a];
1541
+ l(f?.under), ro(t, i, e, r, a, s), l(f?.over);
1207
1542
  }
1208
1543
  l(e.layers.front), t.restore();
1209
1544
  }
1210
- function Fn(t, e, n) {
1545
+ function _o(t, e, n) {
1211
1546
  const o = { ...t };
1212
- for (const [r, s] of Object.entries(e)) {
1213
- const h = t[r] ?? s;
1214
- o[r] = h + (s - h) * n;
1547
+ for (const [s, r] of Object.entries(e)) {
1548
+ const h = t[s] ?? r;
1549
+ o[s] = h + (r - h) * n;
1215
1550
  }
1216
1551
  return o;
1217
1552
  }
1218
- function Nn(t, e, n, o) {
1219
- const r = t.plan.id === "human" ? { ...K, ...e } : e;
1220
- let s;
1553
+ function Ho(t, e, n, o) {
1554
+ const s = t.plan.id === "human" ? { ...z, ...e } : e;
1555
+ let r;
1221
1556
  if (Array.isArray(o))
1222
- s = o;
1557
+ r = o;
1223
1558
  else {
1224
- const { skeleton: h } = At(t, r), i = It(t.plan, { ...r, roll: 0 }, { height: t.height, contact: "none" }), l = (r.roll ?? 0) * Math.PI / 180, a = o.x - h.hip.x, c = o.y - h.hip.y, g = i.hip.x + a * Math.cos(-l) - c * Math.sin(-l), y = i.hip.y + a * Math.sin(-l) + c * Math.cos(-l), f = Math.PI / 2 * (r.turn ?? 0), d = o.depth ?? h.chains[n].depths[h.chains[n].depths.length - 1], w = Math.cos(f), m = Math.sin(f);
1225
- s = [g * w - d * m, -y, g * m + d * w];
1559
+ const { skeleton: h } = qt(t, s), i = Dt(t.plan, { ...s, roll: 0 }, { height: t.height, contact: "none" }), l = (s.roll ?? 0) * Math.PI / 180, a = o.x - h.hip.x, f = o.y - h.hip.y, g = i.hip.x + a * Math.cos(-l) - f * Math.sin(-l), m = i.hip.y + a * Math.sin(-l) + f * Math.cos(-l), c = Math.PI / 2 * (s.turn ?? 0), d = o.depth ?? h.chains[n].depths[h.chains[n].depths.length - 1], u = Math.cos(c), y = Math.sin(c);
1560
+ r = [g * u - d * y, -m, g * y + d * u];
1226
1561
  }
1227
- return Je(t.plan, r, n, s, { height: t.height });
1562
+ return Cn(t.plan, s, n, r, { height: t.height });
1228
1563
  }
1229
- function Cn(t) {
1230
- const { character: e } = t, n = e.height * 0.8, o = e.height, r = e.plan.id === "human" ? K : {};
1564
+ function Wo(t) {
1565
+ const { character: e } = t, n = e.height * 0.8, o = e.height, s = e.plan.id === "human" ? z : {};
1231
1566
  return {
1232
1567
  type: "custom",
1233
1568
  x: t.x - n / 2,
1234
1569
  y: t.y - o,
1235
1570
  width: n,
1236
1571
  height: o,
1237
- props: { ...r, ...t.pose },
1572
+ props: { ...s, ...t.pose },
1238
1573
  character: e,
1239
- draw(s, h, i) {
1240
- s.translate(n / 2, o), bn(s, e, h.props, i);
1574
+ draw(r, h, i) {
1575
+ r.translate(n / 2, o), ho(r, e, h.props, i);
1241
1576
  }
1242
1577
  };
1243
1578
  }
1244
- function Mn(t, e, n) {
1245
- const o = (s) => ({ x: s.x + e, y: s.y + n }), r = (s) => Object.fromEntries(Object.entries(s).map(([h, i]) => [h, i.map(o)]));
1579
+ function ao(t, e, n) {
1580
+ const o = (r) => ({ x: r.x + e, y: r.y + n }), s = (r) => Object.fromEntries(Object.entries(r).map(([h, i]) => [h, i.map(o)]));
1246
1581
  return {
1247
1582
  ...t,
1248
- points: Object.fromEntries(Object.entries(t.points).map(([s, h]) => [s, o(h)])),
1249
- chains: r(t.chains),
1250
- parts: Object.fromEntries(Object.entries(t.parts).map(([s, h]) => [s, { ...h, points: h.points.map(o) }])),
1583
+ points: Object.fromEntries(Object.entries(t.points).map(([r, h]) => [r, o(h)])),
1584
+ chains: s(t.chains),
1585
+ parts: Object.fromEntries(Object.entries(t.parts).map(([r, h]) => [r, { ...h, points: h.points.map(o) }])),
1251
1586
  head: { ...t.head, center: o(t.head.center) },
1252
1587
  groundY: t.groundY + n
1253
1588
  };
1254
1589
  }
1255
- function Xn(t, e, n) {
1590
+ function $o(t, e, n) {
1256
1591
  const o = t.character;
1257
1592
  if (!o) throw new Error("characterAt: the target was not made by characterTarget");
1258
- const r = { ...t.props };
1259
- let s = 0, h = 0;
1593
+ const s = { ...t.props };
1594
+ let r = 0, h = 0;
1260
1595
  for (const [l, a] of e.state?.values.get(n) ?? [])
1261
- typeof a == "number" && (l === "x" || l === "motionPathX" ? s = a : l === "y" || l === "motionPathY" ? h = a : l in r && (r[l] = a));
1262
- const i = mn(o, r);
1263
- return { pose: r, joints: Mn(i, t.x + s + t.width / 2, t.y + h + t.height) };
1596
+ typeof a == "number" && (l === "x" || l === "motionPathX" ? r = a : l === "y" || l === "motionPathY" ? h = a : l in s && (s[l] = a));
1597
+ const i = oo(o, s);
1598
+ return { pose: s, joints: ao(i, t.x + r + t.width / 2, t.y + h + t.height) };
1264
1599
  }
1265
- function qn(t, e, n = K) {
1600
+ function Ro(t, e, n = z) {
1266
1601
  const o = [];
1267
- return e.forEach((s, h) => {
1268
- const i = h === 0 ? n : o[h - 1], l = typeof s.pose == "string" ? fn[s.pose] : void 0;
1269
- o.push(l ? { ...l, turn: i.turn ?? 0 } : { ...i, ...s.pose });
1270
- }), Object.keys(n).filter((s) => o.some((h) => (h[s] ?? n[s]) !== n[s])).map((s) => ({
1271
- id: `${t}-${s}`,
1602
+ return e.forEach((r, h) => {
1603
+ const i = h === 0 ? n : o[h - 1], l = typeof r.pose == "string" ? Qn[r.pose] : void 0;
1604
+ o.push(l ? { ...l, turn: i.turn ?? 0 } : { ...i, ...r.pose });
1605
+ }), Object.keys(n).filter((r) => o.some((h) => (h[r] ?? n[r]) !== n[r])).map((r) => ({
1606
+ id: `${t}-${r}`,
1272
1607
  target: t,
1273
- property: s,
1608
+ property: r,
1274
1609
  keyframes: e.map((h, i) => ({
1275
1610
  time: h.time,
1276
- value: o[i][s] ?? n[s],
1611
+ value: o[i][r] ?? n[r],
1277
1612
  ...h.easing ? { easing: h.easing } : {}
1278
1613
  }))
1279
1614
  }));
1280
1615
  }
1281
- const kn = (t, e, n) => t.slice(Math.floor((t.length - 1) * e), Math.ceil((t.length - 1) * n) + 1);
1282
- function Un(t = {}) {
1283
- const e = t.shirt ?? "#e2493b", n = t.trousers ?? "#24476b", o = (i) => i.lineWidth * 0.45, r = (i, l, a) => {
1284
- const c = i.parts[`leg.${a}`].points;
1285
- l.shape(ht(c, i.height * 0.08, i.height * 0.05), n, o(i));
1286
- }, s = (i, l) => {
1287
- const a = i.chains.spine, c = a[0], g = a[a.length - 1], y = { x: c.x - (g.x - c.x) * 0.25, y: c.y - (g.y - c.y) * 0.25 };
1288
- l.shape(ht([y, ...i.parts.spine.points], i.height * 0.15, i.height * 0.14), e, o(i));
1616
+ const co = (t, e, n) => t.slice(Math.floor((t.length - 1) * e), Math.ceil((t.length - 1) * n) + 1);
1617
+ function Bo(t = {}) {
1618
+ const e = t.shirt ?? "#e2493b", n = t.trousers ?? "#24476b", o = (i) => i.lineWidth * 0.45, s = (i, l, a) => {
1619
+ const f = i.parts[`leg.${a}`].points;
1620
+ l.shape(yt(f, i.height * 0.08, i.height * 0.05), n, o(i));
1621
+ }, r = (i, l) => {
1622
+ const a = i.chains.spine, f = a[0], g = a[a.length - 1], m = { x: f.x - (g.x - f.x) * 0.25, y: f.y - (g.y - f.y) * 0.25 };
1623
+ l.shape(yt([m, ...i.parts.spine.points], i.height * 0.15, i.height * 0.14), e, o(i));
1289
1624
  }, h = (i, l, a) => {
1290
- const c = i.parts[`arm.${a}`].points, g = c[0], y = i.chains.spine[i.chains.spine.length - 1], d = [{ x: g.x + (y.x - g.x) * 0.45, y: g.y + (y.y - g.y) * 0.45 }, ...kn(c, 0, 0.45)], w = ht(d, i.height * 0.085, i.height * 0.06), m = d.length, u = w.slice(0, m), k = w.slice(m).reverse();
1291
- l.shape(w, e, 0);
1292
- const E = (P) => Math.hypot(P[1].x - y.x, P[1].y - y.y), [b, M] = E(u) > E(k) ? [u, k] : [k, u];
1293
- l.line(b.slice(1), o(i)), l.line(M.slice(Math.ceil(m * 0.45)), o(i)), l.line([u[m - 1], k[m - 1]], o(i));
1625
+ const f = i.parts[`arm.${a}`].points, g = f[0], m = i.chains.spine[i.chains.spine.length - 1], d = [{ x: g.x + (m.x - g.x) * 0.45, y: g.y + (m.y - g.y) * 0.45 }, ...co(f, 0, 0.45)], u = yt(d, i.height * 0.085, i.height * 0.06), y = d.length, p = u.slice(0, y), x = u.slice(y).reverse();
1626
+ l.shape(u, e, 0);
1627
+ const E = (T) => Math.hypot(T[1].x - m.x, T[1].y - m.y), [b, M] = E(p) > E(x) ? [p, x] : [x, p];
1628
+ l.line(b.slice(1), o(i)), l.line(M.slice(Math.ceil(y * 0.45)), o(i)), l.line([p[y - 1], x[y - 1]], o(i));
1294
1629
  };
1295
1630
  return {
1296
1631
  parts: {
1297
- "leg.left": { over: (i, l, a) => r(l, a, "left") },
1298
- "leg.right": { over: (i, l, a) => r(l, a, "right") },
1299
- spine: { over: (i, l, a) => s(l, a) },
1632
+ "leg.left": { over: (i, l, a) => s(l, a, "left") },
1633
+ "leg.right": { over: (i, l, a) => s(l, a, "right") },
1634
+ spine: { over: (i, l, a) => r(l, a) },
1300
1635
  "arm.left": { over: (i, l, a) => h(l, a, "left") },
1301
1636
  "arm.right": { over: (i, l, a) => h(l, a, "right") }
1302
1637
  }
1303
1638
  };
1304
1639
  }
1305
1640
  export {
1306
- N as EXPRESSIONS,
1307
- Bn as HUMAN_EXPRESSIONS,
1308
- fn as HUMAN_POSES,
1309
- K as HUMAN_REST,
1310
- be as POSES,
1311
- G as REST_POSE,
1312
- Un as basicOutfit,
1313
- Me as blendPose,
1314
- ye as boilFrame,
1315
- Rn as character,
1316
- Xn as characterAt,
1317
- mn as characterJoints,
1318
- qn as characterPoseTracks,
1319
- Cn as characterTarget,
1320
- In as circlePath,
1321
- ae as clipErased,
1322
- ze as createPen,
1323
- bn as drawCharacter,
1324
- ie as drawEraser,
1325
- le as drawHand,
1326
- je as drawPencil,
1327
- De as drawStickFigure,
1328
- An as drawnPathTarget,
1329
- Xt as ellipsePoints,
1330
- Yn as erasable,
1331
- Tn as headPoint,
1332
- $n as humanFieldLabel,
1333
- dn as humanPlan,
1334
- R as humanPose,
1335
- Mn as jointsInScene,
1336
- Ke as jointsToScene,
1337
- Fn as mixPoses,
1338
- Dt as partialPath,
1339
- jn as pathLength,
1340
- jt as pointAlong,
1341
- Ln as pointOnHead,
1342
- B as pose,
1343
- On as poseTracks,
1344
- Nn as reachCharacter,
1345
- re as resolveStickPose,
1346
- z as rubberLimb,
1347
- Hn as scrubPath,
1348
- Pn as seatHeight,
1349
- xt as sketchPen,
1350
- Wn as stickFigureAt,
1351
- Ue as stickFigureJoints,
1352
- vn as stickFigureTarget,
1353
- Sn as strideLength,
1354
- xe as talkingMouth,
1355
- Jt as taperedLine,
1356
- ht as taperedOutline,
1357
- Ee as walkPose,
1358
- _n as withErased,
1359
- we as withExpression
1641
+ X as EXPRESSIONS,
1642
+ dn as FINGERS,
1643
+ kt as HAND_REST,
1644
+ un as HAND_SHAPES,
1645
+ Io as HUMAN_EXPRESSIONS,
1646
+ Qn as HUMAN_POSES,
1647
+ z as HUMAN_REST,
1648
+ Ye as POSES,
1649
+ et as REST_POSE,
1650
+ Bo as basicOutfit,
1651
+ Le as blendPose,
1652
+ We as boilFrame,
1653
+ Ao as character,
1654
+ $o as characterAt,
1655
+ io as characterHandPose,
1656
+ oo as characterJoints,
1657
+ Ro as characterPoseTracks,
1658
+ Wo as characterTarget,
1659
+ xo as circlePath,
1660
+ ve as clipErased,
1661
+ ke as createPen,
1662
+ xe as drawCartoonHand,
1663
+ ho as drawCharacter,
1664
+ Ee as drawEraser,
1665
+ Pe as drawHand,
1666
+ Yn as drawPencil,
1667
+ fn as drawStickFigure,
1668
+ Eo as drawnPathTarget,
1669
+ ne as ellipsePoints,
1670
+ To as erasable,
1671
+ ko as handAt,
1672
+ Ft as handJoints,
1673
+ Pn as handJointsAt,
1674
+ R as handPose,
1675
+ mo as headPoint,
1676
+ vo as humanFieldLabel,
1677
+ Vn as humanPlan,
1678
+ F as humanPose,
1679
+ ao as jointsInScene,
1680
+ cn as jointsToScene,
1681
+ Mo as mixHandPoses,
1682
+ _o as mixPoses,
1683
+ ae as partialPath,
1684
+ Fo as pathLength,
1685
+ Ut as pointAlong,
1686
+ Oo as pointOnHead,
1687
+ L as pose,
1688
+ bo as poseTracks,
1689
+ Ho as reachCharacter,
1690
+ Me as resolveStickPose,
1691
+ j as rotateAbout,
1692
+ tt as rubberLimb,
1693
+ So as scrubPath,
1694
+ yo as seatHeight,
1695
+ Ht as sketchPen,
1696
+ wo as stickFigureAt,
1697
+ an as stickFigureJoints,
1698
+ po as stickFigureTarget,
1699
+ go as strideLength,
1700
+ Ce as talkingMouth,
1701
+ Xt as taperedLine,
1702
+ yt as taperedOutline,
1703
+ Ne as walkPose,
1704
+ Po as withErased,
1705
+ Be as withExpression
1360
1706
  };