@plupin/character 0.3.0 → 0.5.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.
@@ -0,0 +1,448 @@
1
+ // src/anime-face.ts
2
+ var ANIME_FACE_SIZE = { width: 512, height: 256 };
3
+ var ANIME_FACE_UV = { u0: 0.1, u1: 0.4, v0: 0.27, v1: 0.61 };
4
+ var PARTS = {
5
+ idle: { eyes: "open", mouth: "smile", brows: "calm", blush: 0.55 },
6
+ blink: { eyes: "closed", mouth: "smile", brows: "calm", blush: 0.55 },
7
+ happy: { eyes: "happy", mouth: "open", brows: "up", blush: 0.85 },
8
+ surprised: { eyes: "wide", mouth: "o", brows: "up", blush: 0.4 },
9
+ sad: { eyes: "sad", mouth: "frown", brows: "sad", blush: 0.3 },
10
+ wee: { eyes: "happy", mouth: "o", brows: "up", blush: 0.9 },
11
+ sparkle: { eyes: "stars", mouth: "open", brows: "up", blush: 0.9 },
12
+ shock: { eyes: "wide", mouth: "o", brows: "up", blush: 0.2 },
13
+ yell: { eyes: "angry", mouth: "yell", brows: "angry", blush: 0.3 },
14
+ pain: { eyes: "closed", mouth: "frown", brows: "sad", blush: 0.2 },
15
+ dead: { eyes: "dead", mouth: "flat", brows: "none", blush: 0 },
16
+ rage: { eyes: "angry", mouth: "grin", brows: "angry", blush: 0.2 },
17
+ speechless: { eyes: "half", mouth: "flat", brows: "calm", blush: 0.2 },
18
+ idea: { eyes: "wide", mouth: "smile", brows: "up", blush: 0.5 },
19
+ smug: { eyes: "half", mouth: "cat", brows: "calm", blush: 0.6 },
20
+ cry: { eyes: "cry", mouth: "frown", brows: "sad", blush: 0.5, tears: true },
21
+ smirk: { eyes: "wink", mouth: "smirk", brows: "calm", blush: 0.55 },
22
+ tongue: { eyes: "wink", mouth: "tongue", brows: "up", blush: 0.7 },
23
+ cool: { eyes: "half", mouth: "smirk", brows: "calm", blush: 0.15 },
24
+ serious: { eyes: "angry", mouth: "flat", brows: "angry", blush: 0 },
25
+ stars: { eyes: "stars", mouth: "grin", brows: "up", blush: 0.9 },
26
+ licik: { eyes: "half", mouth: "grin", brows: "angry", blush: 0.3 },
27
+ tidur: { eyes: "closed", mouth: "o", brows: "calm", blush: 0.5 },
28
+ teriak: { eyes: "angry", mouth: "yell", brows: "angry", blush: 0.3 },
29
+ ngomel: { eyes: "angry", mouth: "frown", brows: "angry", blush: 0.3 }
30
+ };
31
+ var INK = "#221633";
32
+ var LASH = "#1c1229";
33
+ function animeFaceParts(face) {
34
+ return PARTS[face] ?? PARTS.idle ?? { eyes: "open", mouth: "smile", brows: "calm", blush: 0.5 };
35
+ }
36
+ var W = ANIME_FACE_SIZE.width;
37
+ var H = ANIME_FACE_SIZE.height;
38
+ var EYE_Y = 122;
39
+ var EYE_X = 82;
40
+ var EYE_W = 84;
41
+ var EYE_H = 92;
42
+ var MOUTH_Y = 198;
43
+ var ANIME_EYE_LINE = EYE_Y / H;
44
+ var mix = (a, b, t) => {
45
+ const ch = (hex, i) => Number.parseInt(hex.slice(1 + i * 2, 3 + i * 2), 16);
46
+ return `#${[0, 1, 2].map((i) => Math.max(0, Math.min(255, Math.round(ch(a, i) + (ch(b, i) - ch(a, i)) * t))).toString(16).padStart(2, "0")).join("")}`;
47
+ };
48
+ function ellipse(ctx, x, y, rx, ry, rot = 0) {
49
+ ctx.beginPath();
50
+ ctx.ellipse(x, y, Math.max(0.5, rx), Math.max(0.5, ry), rot, 0, Math.PI * 2);
51
+ }
52
+ function eyeShape(ctx, x, y, side, style) {
53
+ const isIkemen = style === "ikemen";
54
+ const w = (isIkemen ? EYE_W * 1.04 : EYE_W) / 2;
55
+ const h = (isIkemen ? EYE_H * 0.66 : EYE_H) / 2;
56
+ const outer = side;
57
+ ctx.beginPath();
58
+ if (isIkemen) {
59
+ ctx.moveTo(x - outer * w * 1.02, y + h * 0.08);
60
+ ctx.bezierCurveTo(x - outer * w * 0.55, y - h * 1.06, x + outer * w * 0.62, y - h * 1.15, x + outer * w * 1.08, y - h * 0.36);
61
+ ctx.bezierCurveTo(x + outer * w * 0.85, y + h * 0.72, x + outer * w * 0.25, y + h * 1.02, x - outer * w * 0.28, y + h * 0.88);
62
+ ctx.bezierCurveTo(x - outer * w * 0.72, y + h * 0.72, x - outer * w * 0.96, y + h * 0.36, x - outer * w * 1.02, y + h * 0.08);
63
+ } else {
64
+ ctx.moveTo(x - outer * w * 0.98, y - h * 0.05);
65
+ ctx.bezierCurveTo(x - outer * w * 0.82, y - h * 1.08, x + outer * w * 0.78, y - h * 1.12, x + outer * w * 1.04, y - h * 0.22);
66
+ ctx.bezierCurveTo(x + outer * w * 1.02, y + h * 0.76, x + outer * w * 0.45, y + h * 1.02, x, y + h * 1);
67
+ ctx.bezierCurveTo(x - outer * w * 0.52, y + h * 0.98, x - outer * w * 0.98, y + h * 0.68, x - outer * w * 0.98, y - h * 0.05);
68
+ }
69
+ ctx.closePath();
70
+ }
71
+ function lashes(ctx, x, y, side, style, lift = 0) {
72
+ const isIkemen = style === "ikemen";
73
+ const w = (isIkemen ? EYE_W * 1.04 : EYE_W) / 2;
74
+ const h = (isIkemen ? EYE_H * 0.66 : EYE_H) / 2;
75
+ const outer = side;
76
+ ctx.fillStyle = LASH;
77
+ ctx.beginPath();
78
+ if (isIkemen) {
79
+ ctx.moveTo(x - outer * w * 1.06, y + h * 0.08 + lift);
80
+ ctx.bezierCurveTo(x - outer * w * 0.55, y - h * 1.18 + lift, x + outer * w * 0.65, y - h * 1.32 + lift, x + outer * w * 1.18, y - h * 0.52 + lift);
81
+ ctx.lineTo(x + outer * w * 1.06, y - h * 0.22 + lift);
82
+ ctx.bezierCurveTo(x + outer * w * 0.58, y - h * 0.88 + lift, x - outer * w * 0.52, y - h * 0.78 + lift, x - outer * w * 1.06, y + h * 0.08 + lift);
83
+ } else {
84
+ ctx.moveTo(x - outer * w * 1.02, y - h * 0.04 + lift);
85
+ ctx.bezierCurveTo(x - outer * w * 0.84, y - h * 1.16 + lift, x + outer * w * 0.75, y - h * 1.24 + lift, x + outer * w * 1.16, y - h * 0.42 + lift);
86
+ ctx.quadraticCurveTo(x + outer * w * 1.32, y - h * 0.62 + lift, x + outer * w * 1.38, y - h * 0.78 + lift);
87
+ ctx.quadraticCurveTo(x + outer * w * 1.24, y - h * 0.38 + lift, x + outer * w * 1.05, y - h * 0.14 + lift);
88
+ ctx.bezierCurveTo(x + outer * w * 0.72, y - h * 0.86 + lift, x - outer * w * 0.74, y - h * 0.82 + lift, x - outer * w * 1.02, y - h * 0.04 + lift);
89
+ }
90
+ ctx.closePath();
91
+ ctx.fill();
92
+ if (!isIkemen) {
93
+ ctx.strokeStyle = LASH;
94
+ ctx.lineWidth = 2.6;
95
+ ctx.lineCap = "round";
96
+ ctx.beginPath();
97
+ ctx.moveTo(x + outer * w * 0.96, y - h * 0.3 + lift);
98
+ ctx.quadraticCurveTo(x + outer * w * 1.18, y - h * 0.34 + lift, x + outer * w * 1.3, y - h * 0.48 + lift);
99
+ ctx.moveTo(x + outer * w * 0.78, y - h * 0.7 + lift);
100
+ ctx.quadraticCurveTo(x + outer * w * 0.98, y - h * 0.92 + lift, x + outer * w * 1.12, y - h * 1.06 + lift);
101
+ ctx.stroke();
102
+ }
103
+ ctx.strokeStyle = isIkemen ? "rgba(45, 30, 62, 0.5)" : "rgba(75, 42, 78, 0.45)";
104
+ ctx.lineWidth = isIkemen ? 2.2 : 2;
105
+ ctx.lineCap = "round";
106
+ ctx.beginPath();
107
+ ctx.moveTo(x - outer * w * 0.65, y - h * (isIkemen ? 1.18 : 1.06) + lift);
108
+ ctx.quadraticCurveTo(x + outer * w * 0.1, y - h * (isIkemen ? 1.48 : 1.38) + lift, x + outer * w * 0.85, y - h * (isIkemen ? 1.24 : 1.06) + lift);
109
+ ctx.stroke();
110
+ }
111
+ function lowerLash(ctx, x, y, side, style) {
112
+ const isIkemen = style === "ikemen";
113
+ const w = (isIkemen ? EYE_W * 1.04 : EYE_W) / 2;
114
+ const h = (isIkemen ? EYE_H * 0.66 : EYE_H) / 2;
115
+ ctx.strokeStyle = isIkemen ? "rgba(28, 18, 41, 0.75)" : "rgba(44, 24, 58, 0.65)";
116
+ ctx.lineWidth = isIkemen ? 2.4 : 2.2;
117
+ ctx.lineCap = "round";
118
+ ctx.beginPath();
119
+ ctx.moveTo(x + side * w * 0.92, y + h * 0.36);
120
+ ctx.quadraticCurveTo(x + side * w * 0.52, y + h * 0.96, x - side * w * 0.1, y + h * 0.98);
121
+ ctx.stroke();
122
+ if (!isIkemen) {
123
+ ctx.strokeStyle = "rgba(235, 130, 165, 0.32)";
124
+ ctx.lineWidth = 3;
125
+ ctx.beginPath();
126
+ ctx.moveTo(x - side * w * 0.4, y + h * 1.18);
127
+ ctx.quadraticCurveTo(x + side * w * 0.1, y + h * 1.32, x + side * w * 0.65, y + h * 1.12);
128
+ ctx.stroke();
129
+ }
130
+ }
131
+ function openEye(ctx, x, y, side, iris, style, { pupil = 1, wet = false, catchlights = 3, squint = 0 } = {}) {
132
+ const isIkemen = style === "ikemen";
133
+ const h = (isIkemen ? EYE_H * 0.66 : EYE_H) / 2;
134
+ ctx.save();
135
+ eyeShape(ctx, x, y, side, style);
136
+ const sclera = ctx.createLinearGradient(0, y - h, 0, y + h);
137
+ sclera.addColorStop(0, "#e2dced");
138
+ sclera.addColorStop(0.32, "#fffdff");
139
+ sclera.addColorStop(1, "#fff8fb");
140
+ ctx.fillStyle = sclera;
141
+ ctx.fill();
142
+ ctx.clip();
143
+ const ix = x + side * 2;
144
+ const iy = y + (isIkemen ? 1 : 4);
145
+ const irx = isIkemen ? EYE_W * 0.34 : EYE_W * 0.38;
146
+ const iry = isIkemen ? EYE_H * 0.32 : EYE_H * 0.44;
147
+ const gradient = ctx.createLinearGradient(0, iy - iry, 0, iy + iry);
148
+ gradient.addColorStop(0, mix(iris, "#0e061a", 0.68));
149
+ gradient.addColorStop(0.38, mix(iris, "#1c0e30", 0.25));
150
+ gradient.addColorStop(0.68, iris);
151
+ gradient.addColorStop(1, mix(iris, "#fff5ff", 0.62));
152
+ ellipse(ctx, ix, iy, irx, iry);
153
+ ctx.fillStyle = gradient;
154
+ ctx.fill();
155
+ ctx.lineWidth = isIkemen ? 2.6 : 3;
156
+ ctx.strokeStyle = mix(iris, "#0c0516", 0.72);
157
+ ctx.stroke();
158
+ ctx.save();
159
+ ellipse(ctx, ix, iy + iry * 0.42, irx * 0.68, iry * 0.34);
160
+ ctx.fillStyle = `${mix(iris, "#ffffff", 0.75)}aa`;
161
+ ctx.fill();
162
+ ellipse(ctx, ix, iy + iry * 0.5, irx * 0.46, iry * 0.2);
163
+ ctx.fillStyle = `${mix(iris, "#fff8ff", 0.88)}cc`;
164
+ ctx.fill();
165
+ ctx.restore();
166
+ ellipse(ctx, ix, iy + 1, irx * (isIkemen ? 0.36 : 0.4) * pupil, iry * 0.42 * pupil);
167
+ ctx.fillStyle = mix(iris, "#080312", 0.85);
168
+ ctx.fill();
169
+ if (pupil > 0.7 && !isIkemen) {
170
+ ellipse(ctx, ix, iy + iry * 0.14, irx * 0.16, iry * 0.12);
171
+ ctx.fillStyle = `${mix(iris, "#ffffff", 0.5)}88`;
172
+ ctx.fill();
173
+ }
174
+ const shadowGrad = ctx.createLinearGradient(0, y - h, 0, y - h * 0.05 + squint);
175
+ shadowGrad.addColorStop(0, "rgba(28, 14, 52, 0.52)");
176
+ shadowGrad.addColorStop(0.7, "rgba(38, 18, 68, 0.24)");
177
+ shadowGrad.addColorStop(1, "rgba(38, 18, 68, 0)");
178
+ ctx.fillStyle = shadowGrad;
179
+ ctx.fillRect(x - EYE_W, y - EYE_H, EYE_W * 2, EYE_H * 0.65 + squint);
180
+ ctx.restore();
181
+ ctx.fillStyle = "#ffffff";
182
+ if (catchlights > 0) {
183
+ ellipse(ctx, ix - side * irx * 0.38, iy - iry * 0.36, irx * (isIkemen ? 0.25 : 0.32), iry * (isIkemen ? 0.22 : 0.24), -side * 0.35);
184
+ ctx.fill();
185
+ }
186
+ if (catchlights > 1) {
187
+ ellipse(ctx, ix + side * irx * 0.38, iy + iry * 0.36, irx * 0.14, iry * 0.12);
188
+ ctx.fill();
189
+ }
190
+ if (catchlights > 2 && !isIkemen) {
191
+ ellipse(ctx, ix + side * irx * 0.28, iy - iry * 0.44, irx * 0.09, iry * 0.09);
192
+ ctx.fill();
193
+ }
194
+ if (wet) {
195
+ ctx.globalAlpha = 0.85;
196
+ ellipse(ctx, ix, iy + iry * 0.62, irx * 0.72, iry * 0.13);
197
+ ctx.fill();
198
+ ctx.globalAlpha = 1;
199
+ }
200
+ lashes(ctx, x, y, side, style, squint * 0.8);
201
+ lowerLash(ctx, x, y, side, style);
202
+ }
203
+ function closedEye(ctx, x, y, side, happy, style) {
204
+ const w = EYE_W / 2;
205
+ ctx.strokeStyle = LASH;
206
+ ctx.lineWidth = style === "ikemen" ? 5.5 : 6.5;
207
+ ctx.lineCap = "round";
208
+ ctx.beginPath();
209
+ if (happy) {
210
+ ctx.moveTo(x - w * 0.9, y + 8);
211
+ ctx.quadraticCurveTo(x, y - (style === "ikemen" ? 16 : 24), x + w * 0.9, y + 8);
212
+ } else {
213
+ ctx.moveTo(x - w * 0.9, y + 2);
214
+ ctx.quadraticCurveTo(x, y + 18, x + w * 0.9, y + 2);
215
+ if (style === "anime") {
216
+ ctx.moveTo(x + side * w * 0.85, y + 3);
217
+ ctx.lineTo(x + side * w * 1.18, y - 5);
218
+ }
219
+ }
220
+ ctx.stroke();
221
+ }
222
+ function star(ctx, x, y, r, color) {
223
+ ctx.beginPath();
224
+ for (let i = 0;i < 8; i += 1) {
225
+ const a = i / 8 * Math.PI * 2 - Math.PI / 2;
226
+ const k = i % 2 ? r * 0.36 : r;
227
+ ctx.lineTo(x + Math.cos(a) * k, y + Math.sin(a) * k);
228
+ }
229
+ ctx.closePath();
230
+ ctx.fillStyle = color;
231
+ ctx.fill();
232
+ }
233
+ function eye(ctx, side, parts, iris, style) {
234
+ const x = W / 2 + side * EYE_X;
235
+ const y = EYE_Y;
236
+ switch (parts.eyes) {
237
+ case "closed":
238
+ return closedEye(ctx, x, y, side, false, style);
239
+ case "happy":
240
+ return closedEye(ctx, x, y, side, true, style);
241
+ case "wink":
242
+ return side > 0 ? closedEye(ctx, x, y, side, true, style) : openEye(ctx, x, y, side, iris, style);
243
+ case "wide":
244
+ return openEye(ctx, x, y, side, iris, style, { pupil: 0.45, catchlights: 1 });
245
+ case "sad":
246
+ case "cry":
247
+ return openEye(ctx, x, y, side, iris, style, { wet: true, pupil: 1.08 });
248
+ case "half":
249
+ openEye(ctx, x, y, side, iris, style, { squint: style === "ikemen" ? 14 : 20 });
250
+ return;
251
+ case "angry":
252
+ openEye(ctx, x, y, side, iris, style, { catchlights: 1, squint: 12, pupil: 0.72 });
253
+ return;
254
+ case "stars":
255
+ openEye(ctx, x, y, side, iris, style, { catchlights: 1 });
256
+ star(ctx, x + side * 2, y + 4, 19, "#fff6b0");
257
+ return;
258
+ case "dead": {
259
+ ctx.strokeStyle = LASH;
260
+ ctx.lineWidth = 6;
261
+ ctx.lineCap = "round";
262
+ ctx.beginPath();
263
+ ctx.moveTo(x - 18, y - 18);
264
+ ctx.lineTo(x + 18, y + 18);
265
+ ctx.moveTo(x + 18, y - 18);
266
+ ctx.lineTo(x - 18, y + 18);
267
+ ctx.stroke();
268
+ return;
269
+ }
270
+ default:
271
+ openEye(ctx, x, y, side, iris, style);
272
+ }
273
+ }
274
+ function brow(ctx, side, brows, style) {
275
+ if (brows === "none")
276
+ return;
277
+ const isIkemen = style === "ikemen";
278
+ const x = W / 2 + side * EYE_X;
279
+ const y = EYE_Y - EYE_H * (isIkemen ? 0.56 : 0.72);
280
+ const tilt = brows === "angry" ? 14 : brows === "sad" ? -11 : isIkemen ? 4 : 0;
281
+ const lift = brows === "up" ? -7 : 0;
282
+ ctx.strokeStyle = isIkemen ? LASH : mix(LASH, "#6b4a62", 0.3);
283
+ ctx.lineWidth = isIkemen ? 5.2 : 3.2;
284
+ ctx.lineCap = "round";
285
+ ctx.beginPath();
286
+ if (isIkemen) {
287
+ ctx.moveTo(x - side * 28, y + lift + tilt);
288
+ ctx.quadraticCurveTo(x + side * 4, y + lift - 7, x + side * 30, y + lift - tilt * 0.25);
289
+ } else {
290
+ ctx.moveTo(x - side * 22, y + lift + tilt);
291
+ ctx.quadraticCurveTo(x, y + lift - 6, x + side * 22, y + lift - tilt * 0.2);
292
+ }
293
+ ctx.stroke();
294
+ }
295
+ function nose(ctx, style) {
296
+ const x = W / 2;
297
+ const y = EYE_Y + 34;
298
+ if (style === "ikemen") {
299
+ ctx.strokeStyle = "rgba(80, 52, 74, 0.36)";
300
+ ctx.lineWidth = 2.4;
301
+ ctx.lineCap = "round";
302
+ ctx.beginPath();
303
+ ctx.moveTo(x - 2, y - 12);
304
+ ctx.lineTo(x - 4, y + 4);
305
+ ctx.lineTo(x + 2, y + 6);
306
+ ctx.stroke();
307
+ } else {
308
+ ctx.fillStyle = "rgba(150, 82, 98, 0.42)";
309
+ ellipse(ctx, x, y, 3.2, 2.2);
310
+ ctx.fill();
311
+ ctx.fillStyle = "rgba(255, 255, 255, 0.55)";
312
+ ellipse(ctx, x - 2, y - 3, 2, 1.4);
313
+ ctx.fill();
314
+ }
315
+ }
316
+ function mouth(ctx, shape, style) {
317
+ const x = W / 2;
318
+ const y = MOUTH_Y;
319
+ const isIkemen = style === "ikemen";
320
+ ctx.strokeStyle = INK;
321
+ ctx.lineWidth = isIkemen ? 3.4 : 3.2;
322
+ ctx.lineCap = "round";
323
+ ctx.lineJoin = "round";
324
+ const fillOpen = (w, h, round = false) => {
325
+ ctx.beginPath();
326
+ if (round)
327
+ ctx.ellipse(x, y + h / 2, w, h / 2 + 2, 0, 0, Math.PI * 2);
328
+ else {
329
+ ctx.moveTo(x - w, y);
330
+ ctx.quadraticCurveTo(x, y + h * 1.9, x + w, y);
331
+ ctx.closePath();
332
+ }
333
+ ctx.fillStyle = "#8a2a42";
334
+ ctx.fill();
335
+ ctx.stroke();
336
+ ctx.save();
337
+ ctx.clip();
338
+ ellipse(ctx, x, y + h * 1, w * 0.62, h * 0.5);
339
+ ctx.fillStyle = "#f27e9c";
340
+ ctx.fill();
341
+ ctx.restore();
342
+ };
343
+ ctx.beginPath();
344
+ switch (shape) {
345
+ case "smile":
346
+ if (isIkemen) {
347
+ ctx.moveTo(x - 13, y + 2);
348
+ ctx.quadraticCurveTo(x + 2, y + 6, x + 15, y - 2);
349
+ ctx.stroke();
350
+ } else {
351
+ ctx.fillStyle = "rgba(245, 130, 160, 0.35)";
352
+ ellipse(ctx, x, y + 6, 9, 3.2);
353
+ ctx.fill();
354
+ ctx.beginPath();
355
+ ctx.moveTo(x - 10, y);
356
+ ctx.quadraticCurveTo(x, y + 7, x + 10, y);
357
+ ctx.stroke();
358
+ }
359
+ return;
360
+ case "cat":
361
+ ctx.moveTo(x - 13, y - 2);
362
+ ctx.quadraticCurveTo(x - 6, y + 8, x, y);
363
+ ctx.quadraticCurveTo(x + 6, y + 8, x + 13, y - 2);
364
+ ctx.stroke();
365
+ return;
366
+ case "open":
367
+ return fillOpen(12, 10);
368
+ case "grin":
369
+ return fillOpen(16, 11);
370
+ case "yell":
371
+ return fillOpen(15, 20, true);
372
+ case "o":
373
+ return fillOpen(7, 12, true);
374
+ case "frown":
375
+ ctx.moveTo(x - 10, y + 6);
376
+ ctx.quadraticCurveTo(x, y - 3, x + 10, y + 6);
377
+ ctx.stroke();
378
+ return;
379
+ case "smirk":
380
+ ctx.moveTo(x - 10, y + 3);
381
+ ctx.quadraticCurveTo(x + 6, y + 5, x + 16, y - 5);
382
+ ctx.stroke();
383
+ return;
384
+ case "tongue":
385
+ ctx.moveTo(x - 12, y);
386
+ ctx.quadraticCurveTo(x, y + 8, x + 12, y);
387
+ ctx.stroke();
388
+ ellipse(ctx, x + 4, y + 7, 6.5, 7.5);
389
+ ctx.fillStyle = "#f27e9c";
390
+ ctx.fill();
391
+ ctx.stroke();
392
+ return;
393
+ default:
394
+ ctx.moveTo(x - 10, y + 2);
395
+ ctx.lineTo(x + 10, y + 2);
396
+ ctx.stroke();
397
+ }
398
+ }
399
+ function blush(ctx, amount, style) {
400
+ const eff = style === "ikemen" ? amount * 0.25 : amount;
401
+ if (eff <= 0.05)
402
+ return;
403
+ for (const side of [-1, 1]) {
404
+ const x = W / 2 + side * (EYE_X + 10);
405
+ const y = EYE_Y + EYE_H * 0.62;
406
+ const glow = ctx.createRadialGradient(x, y, 2, x, y, 36);
407
+ glow.addColorStop(0, `rgba(255, 115, 148, ${0.52 * eff})`);
408
+ glow.addColorStop(0.6, `rgba(255, 140, 168, ${0.22 * eff})`);
409
+ glow.addColorStop(1, "rgba(255, 140, 168, 0)");
410
+ ctx.fillStyle = glow;
411
+ ctx.fillRect(x - 42, y - 28, 84, 56);
412
+ if (style === "anime" && eff > 0.35) {
413
+ ctx.fillStyle = `rgba(255, 255, 255, ${0.55 * eff})`;
414
+ ellipse(ctx, x + side * 6, y - 4, 4.2, 2.6, -side * 0.25);
415
+ ctx.fill();
416
+ ellipse(ctx, x + side * 14, y - 1, 2.2, 1.5);
417
+ ctx.fill();
418
+ }
419
+ }
420
+ }
421
+ function tears(ctx) {
422
+ for (const side of [-1, 1]) {
423
+ const x = W / 2 + side * (EYE_X - 8);
424
+ const y = EYE_Y + EYE_H * 0.45;
425
+ ctx.fillStyle = "rgba(140, 220, 255, 0.85)";
426
+ ctx.beginPath();
427
+ ctx.moveTo(x, y);
428
+ ctx.quadraticCurveTo(x + side * 9, y + 26, x, y + 40);
429
+ ctx.quadraticCurveTo(x - side * 7, y + 26, x, y);
430
+ ctx.fill();
431
+ }
432
+ }
433
+ function drawAnimeFace(ctx, face, iris, style = "anime") {
434
+ const eyeTint = iris ?? (style === "ikemen" ? "#3b6ef0" : "#7c52ff");
435
+ ctx.clearRect(0, 0, W, H);
436
+ const parts = animeFaceParts(face);
437
+ blush(ctx, parts.blush, style);
438
+ for (const side of [-1, 1]) {
439
+ eye(ctx, side, parts, eyeTint, style);
440
+ brow(ctx, side, parts.brows, style);
441
+ }
442
+ nose(ctx, style);
443
+ if (parts.tears)
444
+ tears(ctx);
445
+ mouth(ctx, parts.mouth, style);
446
+ }
447
+
448
+ export { ANIME_FACE_SIZE, ANIME_FACE_UV, animeFaceParts, ANIME_EYE_LINE, drawAnimeFace };
@@ -1,13 +1,61 @@
1
1
  // src/wearables.ts
2
2
  var WEARABLES = {
3
+ "wolf-cut": {
4
+ slot: "hair",
5
+ name: "Wolf Cut",
6
+ rarity: "epic",
7
+ sigmaPrice: 120,
8
+ volume: 0.09,
9
+ view: -0.35
10
+ },
11
+ "curtain-ikemen": {
12
+ slot: "hair",
13
+ name: "Curtain Flow",
14
+ rarity: "rare",
15
+ sigmaPrice: 85,
16
+ volume: 0.08,
17
+ view: -0.25
18
+ },
19
+ "messy-fluff": {
20
+ slot: "hair",
21
+ name: "Messy Fluff",
22
+ rarity: "rare",
23
+ sigmaPrice: 80,
24
+ volume: 0.1,
25
+ view: -0.3
26
+ },
27
+ "silky-layers": {
28
+ slot: "hair",
29
+ name: "Silky Layers",
30
+ rarity: "epic",
31
+ sigmaPrice: 130,
32
+ volume: 0.07,
33
+ view: -0.45
34
+ },
35
+ "ojou-curls": {
36
+ slot: "hair",
37
+ name: "Ribbon Curls",
38
+ rarity: "epic",
39
+ sigmaPrice: 125,
40
+ volume: 0.08,
41
+ view: -0.35
42
+ },
43
+ "side-braid": {
44
+ slot: "hair",
45
+ name: "Side Braid",
46
+ rarity: "rare",
47
+ sigmaPrice: 90,
48
+ volume: 0.07,
49
+ view: -0.4
50
+ },
3
51
  "fluffy-bob": {
4
52
  slot: "hair",
5
53
  name: "Fluffy Bob",
6
54
  rarity: "common",
7
55
  sigmaPrice: 40,
8
- volume: 0.06
56
+ volume: 0.07
9
57
  },
10
- "twin-tails": { slot: "hair", name: "Twin Tails", rarity: "rare", sigmaPrice: 70, volume: 0.05 },
58
+ "twin-tails": { slot: "hair", name: "Twin Tails", rarity: "rare", sigmaPrice: 70, volume: 0.06 },
11
59
  "spiky-hero": { slot: "hair", name: "Spiky Hero", rarity: "rare", sigmaPrice: 65, volume: 0.12 },
12
60
  afro: { slot: "hair", name: "Afro", rarity: "rare", sigmaPrice: 60, volume: 0.2 },
13
61
  "swoosh-quiff": {
@@ -22,16 +70,16 @@ var WEARABLES = {
22
70
  name: "Long Waves",
23
71
  rarity: "epic",
24
72
  sigmaPrice: 110,
25
- volume: 0.05,
26
- view: -0.9
73
+ volume: 0.06,
74
+ view: -0.8
27
75
  },
28
76
  ponytail: {
29
77
  slot: "hair",
30
78
  name: "Ponytail",
31
79
  rarity: "common",
32
80
  sigmaPrice: 45,
33
- volume: 0.05,
34
- view: -1.2
81
+ volume: 0.06,
82
+ view: -1.1
35
83
  },
36
84
  mohawk: {
37
85
  slot: "hair",
@@ -41,14 +89,14 @@ var WEARABLES = {
41
89
  volume: 0.14,
42
90
  view: -0.8
43
91
  },
44
- "space-buns": { slot: "hair", name: "Space Buns", rarity: "rare", sigmaPrice: 60, volume: 0.06 },
92
+ "space-buns": { slot: "hair", name: "Space Buns", rarity: "rare", sigmaPrice: 60, volume: 0.07 },
45
93
  "hime-cut": {
46
94
  slot: "hair",
47
95
  name: "Hime Cut",
48
96
  rarity: "epic",
49
97
  sigmaPrice: 120,
50
- volume: 0.06,
51
- view: -0.6
98
+ volume: 0.07,
99
+ view: -0.5
52
100
  },
53
101
  "bunny-ears": { slot: "hat", name: "Bunny Ears", rarity: "rare", sigmaPrice: 60 },
54
102
  "cat-ears": { slot: "hat", name: "Cat Ears", rarity: "common", sigmaPrice: 45 },
@@ -57,6 +105,62 @@ var WEARABLES = {
57
105
  "party-hat": { slot: "hat", name: "Party Hat", rarity: "common", sigmaPrice: 35 },
58
106
  halo: { slot: "hat", name: "Halo", rarity: "epic", sigmaPrice: 120 },
59
107
  bow: { slot: "hat", name: "Bow", rarity: "common", sigmaPrice: 30 },
108
+ "ribbon-dress": {
109
+ slot: "accessory",
110
+ name: "Ribbon Dress",
111
+ rarity: "epic",
112
+ sigmaPrice: 135,
113
+ view: -0.35
114
+ },
115
+ "crop-hoodie": {
116
+ slot: "accessory",
117
+ name: "Cropped Hoodie",
118
+ rarity: "rare",
119
+ sigmaPrice: 85,
120
+ view: -0.3
121
+ },
122
+ "idol-set": {
123
+ slot: "accessory",
124
+ name: "Star Idol",
125
+ rarity: "epic",
126
+ sigmaPrice: 145,
127
+ view: -0.3
128
+ },
129
+ "street-jacket": {
130
+ slot: "accessory",
131
+ name: "Street Jacket",
132
+ rarity: "epic",
133
+ sigmaPrice: 130,
134
+ view: -0.35
135
+ },
136
+ "blazer-coat": {
137
+ slot: "accessory",
138
+ name: "Academy Blazer",
139
+ rarity: "rare",
140
+ sigmaPrice: 95,
141
+ view: -0.3
142
+ },
143
+ "brawler-vest": {
144
+ slot: "accessory",
145
+ name: "Brawler Tank",
146
+ rarity: "rare",
147
+ sigmaPrice: 75,
148
+ view: -0.3
149
+ },
150
+ "martial-gi": {
151
+ slot: "accessory",
152
+ name: "Fighter Gi",
153
+ rarity: "rare",
154
+ sigmaPrice: 90,
155
+ view: -0.35
156
+ },
157
+ "chibi-overalls": {
158
+ slot: "accessory",
159
+ name: "Chibi Overalls",
160
+ rarity: "rare",
161
+ sigmaPrice: 70,
162
+ view: -0.25
163
+ },
60
164
  "pleated-skirt": { slot: "accessory", name: "Pleated Skirt", rarity: "common", sigmaPrice: 50 },
61
165
  tuxedo: { slot: "accessory", name: "Tuxedo", rarity: "epic", sigmaPrice: 140 },
62
166
  "hero-cape": { slot: "accessory", name: "Hero Cape", rarity: "rare", sigmaPrice: 90, view: 2.6 },
@@ -8,7 +8,8 @@ var BODY_WIDTH = 48;
8
8
  var BODY_HEIGHT = 24;
9
9
  var FACE_COLUMN = 20;
10
10
  var FACE_ROW = 9;
11
- var FACE_TYPES = ["dot", "sparkle", "sleepy", "derp", "anime"];
11
+ var FACE_TYPES = ["dot", "sparkle", "sleepy", "derp", "anime", "ikemen"];
12
+ var isHighResFace = (faceType) => faceType === "anime" || faceType === "ikemen";
12
13
  var EXPRESSIONS = [
13
14
  "idle",
14
15
  "blink",
@@ -77,6 +78,11 @@ var FACES = {
77
78
  eyes: { ...SHARED_EYES, open: [".we..we.", ".ee..ee."] },
78
79
  mouth: { ...SHARED_MOUTHS, idle: ["..m..m..", "...mm..."] },
79
80
  blush: true
81
+ },
82
+ ikemen: {
83
+ eyes: { ...SHARED_EYES, open: [".we..we.", ".ee..ee."] },
84
+ mouth: { ...SHARED_MOUTHS, idle: ["...mm...", "........"] },
85
+ blush: false
80
86
  }
81
87
  };
82
88
  var EXPRESSION_PARTS = {
@@ -412,4 +418,4 @@ function tintForName(name) {
412
418
  return BUDDY_TINTS[[...name].reduce((h, c) => h * 31 + c.charCodeAt(0) >>> 0, 7) % BUDDY_TINTS.length];
413
419
  }
414
420
 
415
- export { BODY_WIDTH, BODY_HEIGHT, FACE_COLUMN, FACE_ROW, FACE_TYPES, EXPRESSIONS, isNamedExpression, SKIN_PALETTE, PAINT_KEYS, FACE_PALETTE, FACES, faceStamp, bodyPalette, composeSkin, blankBody, BUDDY_TINTS, DEFAULT_BUDDY_SKIN, sanitizeSkin, randomSkin, SKIN_DETAIL, faceKeys, paintSkinDetailed, paintEyesSmooth, BODY_SHAPES, tintForName };
421
+ export { BODY_WIDTH, BODY_HEIGHT, FACE_COLUMN, FACE_ROW, FACE_TYPES, isHighResFace, EXPRESSIONS, isNamedExpression, SKIN_PALETTE, PAINT_KEYS, FACE_PALETTE, FACES, faceStamp, bodyPalette, composeSkin, blankBody, BUDDY_TINTS, DEFAULT_BUDDY_SKIN, sanitizeSkin, randomSkin, SKIN_DETAIL, faceKeys, paintSkinDetailed, paintEyesSmooth, BODY_SHAPES, tintForName };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RIGS
3
- } from "./chunk-g1c0wdcj.js";
3
+ } from "./chunk-wryfx2sg.js";
4
4
 
5
5
  // src/skin.ts
6
6
  var rect = (x, y, w, h) => ({ x, y, w, h });
@@ -180,22 +180,30 @@ var BODY_SCALE_LIMITS = {
180
180
  head: { min: 0.9, max: 1.25 }
181
181
  };
182
182
  var PLUP_BODY_LIMITS = {
183
- shoulders: { min: 0.7, max: 1.45 },
184
- waist: { min: 0.62, max: 1.2 },
185
- hips: { min: 0.75, max: 1.4 },
186
- legLength: { min: 1, max: 3 },
187
- armLength: { min: 0.8, max: 1.8 },
188
- muscle: { min: 0.7, max: 1.9 },
189
- shoulderHeight: { min: 0.2, max: 0.55 }
183
+ shoulders: { min: 0.65, max: 1.6 },
184
+ waist: { min: 0.48, max: 1.25 },
185
+ hips: { min: 0.75, max: 1.55 },
186
+ bust: { min: 0, max: 1.4 },
187
+ legLength: { min: 0.65, max: 3 },
188
+ armLength: { min: 0.55, max: 1.8 },
189
+ muscle: { min: 0.7, max: 2.2 },
190
+ shoulderHeight: { min: 0.2, max: 0.55 },
191
+ headSize: { min: 0.55, max: 1.45 },
192
+ torsoHeight: { min: 0.45, max: 1.15 },
193
+ figure: { min: 0, max: 1 }
190
194
  };
191
195
  var CANONICAL_PLUP_BODY = {
192
196
  shoulders: 1,
193
197
  waist: 1,
194
198
  hips: 1,
199
+ bust: 0,
195
200
  legLength: 1,
196
201
  armLength: 1,
197
202
  muscle: 1,
198
- shoulderHeight: 0.34
203
+ shoulderHeight: 0.34,
204
+ headSize: 1,
205
+ torsoHeight: 1,
206
+ figure: 0
199
207
  };
200
208
  function clampPlupBody(body) {
201
209
  const out = { ...CANONICAL_PLUP_BODY };