@usenavii/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parts.cjs ADDED
@@ -0,0 +1,594 @@
1
+ 'use strict';
2
+
3
+ // src/parts/palette.ts
4
+ var PALETTES = [
5
+ { id: "indigo", bodyFrom: "#818CF8", bodyTo: "#6366F1", accent: "#FFFFFF", ink: "#1E1B4B", blush: "#F9A8D4" },
6
+ { id: "mint", bodyFrom: "#6EE7B7", bodyTo: "#34D399", accent: "#ECFDF5", ink: "#064E3B", blush: "#FBCFE8" },
7
+ { id: "amber", bodyFrom: "#FCD34D", bodyTo: "#F59E0B", accent: "#FFF7ED", ink: "#78350F", blush: "#FB7185" },
8
+ { id: "sky", bodyFrom: "#93C5FD", bodyTo: "#3B82F6", accent: "#FFFFFF", ink: "#1E3A8A", blush: "#F9A8D4" },
9
+ { id: "violet", bodyFrom: "#C084FC", bodyTo: "#A855F7", accent: "#FAE8FF", ink: "#4C1D95", blush: "#F472B6" },
10
+ { id: "cyan", bodyFrom: "#67E8F9", bodyTo: "#06B6D4", accent: "#ECFEFF", ink: "#164E63", blush: "#F9A8D4" },
11
+ { id: "rose", bodyFrom: "#FDA4AF", bodyTo: "#F43F5E", accent: "#FFE4E6", ink: "#881337", blush: "#FECDD3" },
12
+ { id: "lime", bodyFrom: "#BEF264", bodyTo: "#84CC16", accent: "#F7FEE7", ink: "#365314", blush: "#FCA5A5" },
13
+ { id: "peach", bodyFrom: "#FDBA74", bodyTo: "#F97316", accent: "#FFF7ED", ink: "#7C2D12", blush: "#FECACA" },
14
+ { id: "teal", bodyFrom: "#5EEAD4", bodyTo: "#14B8A6", accent: "#F0FDFA", ink: "#134E4A", blush: "#FBCFE8" },
15
+ { id: "sand", bodyFrom: "#FDE68A", bodyTo: "#EAB308", accent: "#FEFCE8", ink: "#713F12", blush: "#FCA5A5" },
16
+ { id: "plum", bodyFrom: "#D8B4FE", bodyTo: "#9333EA", accent: "#F5F3FF", ink: "#3B0764", blush: "#F0ABFC" },
17
+ { id: "coral", bodyFrom: "#FCA5A5", bodyTo: "#EF4444", accent: "#FEF2F2", ink: "#7F1D1D", blush: "#FECACA" },
18
+ { id: "forest", bodyFrom: "#86EFAC", bodyTo: "#16A34A", accent: "#F0FDF4", ink: "#14532D", blush: "#FBCFE8" },
19
+ { id: "slate", bodyFrom: "#CBD5E1", bodyTo: "#64748B", accent: "#F8FAFC", ink: "#0F172A", blush: "#FBCFE8" },
20
+ { id: "fuchsia", bodyFrom: "#F0ABFC", bodyTo: "#D946EF", accent: "#FDF4FF", ink: "#701A75", blush: "#FBCFE8" },
21
+ // v0.4 additions — broader brand fit
22
+ { id: "terracotta", bodyFrom: "#FBBF9C", bodyTo: "#C2410C", accent: "#FFF7ED", ink: "#7C2D12", blush: "#FECACA" },
23
+ { id: "navy", bodyFrom: "#93C5FD", bodyTo: "#1E3A8A", accent: "#EFF6FF", ink: "#172554", blush: "#FBCFE8" },
24
+ { id: "lavender", bodyFrom: "#DDD6FE", bodyTo: "#7C3AED", accent: "#F5F3FF", ink: "#3B0764", blush: "#F5D0FE" },
25
+ { id: "charcoal", bodyFrom: "#9CA3AF", bodyTo: "#374151", accent: "#F9FAFB", ink: "#030712", blush: "#FBCFE8" },
26
+ { id: "butter", bodyFrom: "#FEF9C3", bodyTo: "#FACC15", accent: "#FEFCE8", ink: "#713F12", blush: "#FCA5A5" },
27
+ { id: "aqua", bodyFrom: "#A5F3FC", bodyTo: "#0891B2", accent: "#ECFEFF", ink: "#083344", blush: "#FBCFE8" }
28
+ ];
29
+ var PALETTE_BY_ID = Object.fromEntries(
30
+ PALETTES.map((p) => [p.id, p])
31
+ );
32
+
33
+ // src/parts/anchor.ts
34
+ var ANCHORS = {
35
+ orb: {
36
+ cx: 50,
37
+ eyeY: 52,
38
+ eyeOffset: 10,
39
+ eyeScale: 1,
40
+ mouthY: 62,
41
+ mouthSpan: 7,
42
+ topperX: 50,
43
+ topperY: 22,
44
+ groundY: 86,
45
+ cheekY: 58,
46
+ cheekOffset: 18
47
+ },
48
+ tall: {
49
+ cx: 50,
50
+ eyeY: 49,
51
+ eyeOffset: 8,
52
+ eyeScale: 1.05,
53
+ mouthY: 60,
54
+ mouthSpan: 6,
55
+ topperX: 50,
56
+ topperY: 18,
57
+ groundY: 91,
58
+ cheekY: 55,
59
+ cheekOffset: 14
60
+ },
61
+ squat: {
62
+ cx: 50,
63
+ eyeY: 56,
64
+ eyeOffset: 11,
65
+ eyeScale: 0.95,
66
+ mouthY: 66,
67
+ mouthSpan: 8,
68
+ topperX: 50,
69
+ topperY: 30,
70
+ groundY: 86,
71
+ cheekY: 62,
72
+ cheekOffset: 20
73
+ },
74
+ pear: {
75
+ cx: 50,
76
+ eyeY: 51,
77
+ eyeOffset: 9,
78
+ eyeScale: 1,
79
+ mouthY: 60,
80
+ mouthSpan: 6.5,
81
+ topperX: 50,
82
+ topperY: 24,
83
+ groundY: 90,
84
+ cheekY: 57,
85
+ cheekOffset: 15
86
+ },
87
+ pebble: {
88
+ cx: 50,
89
+ eyeY: 54,
90
+ eyeOffset: 10.5,
91
+ eyeScale: 1,
92
+ mouthY: 63,
93
+ mouthSpan: 7.5,
94
+ topperX: 53,
95
+ topperY: 23,
96
+ groundY: 85,
97
+ cheekY: 59,
98
+ cheekOffset: 19
99
+ },
100
+ dumpling: {
101
+ cx: 50,
102
+ eyeY: 58,
103
+ eyeOffset: 11,
104
+ eyeScale: 0.98,
105
+ mouthY: 68,
106
+ mouthSpan: 8,
107
+ topperX: 50,
108
+ topperY: 32,
109
+ groundY: 88,
110
+ cheekY: 64,
111
+ cheekOffset: 21
112
+ },
113
+ taro: {
114
+ cx: 50,
115
+ eyeY: 50,
116
+ eyeOffset: 9,
117
+ eyeScale: 1.02,
118
+ mouthY: 60,
119
+ mouthSpan: 6.5,
120
+ topperX: 50,
121
+ topperY: 14,
122
+ groundY: 91,
123
+ cheekY: 55,
124
+ cheekOffset: 14
125
+ },
126
+ wisp: {
127
+ cx: 50,
128
+ eyeY: 47,
129
+ eyeOffset: 7.5,
130
+ eyeScale: 1.08,
131
+ mouthY: 58,
132
+ mouthSpan: 5.5,
133
+ topperX: 50,
134
+ topperY: 12,
135
+ groundY: 94,
136
+ cheekY: 53,
137
+ cheekOffset: 12
138
+ }
139
+ };
140
+
141
+ // src/parts/body.ts
142
+ var BODY_PATHS = {
143
+ // Orb — true round, slight under-bulge for grounded feel
144
+ orb: "M50 20 C72 20 84 36 84 54 C84 73 70 86 50 86 C30 86 16 73 16 54 C16 36 28 20 50 20 Z",
145
+ // Tall — egg pointing up, narrow shoulders, fuller bottom
146
+ tall: "M50 15 C66 15 74 30 74 48 C74 70 66 91 50 91 C34 91 26 70 26 48 C26 30 34 15 50 15 Z",
147
+ // Squat — wide mushroom cap, low waist
148
+ squat: "M50 28 C74 28 88 42 88 60 C88 78 74 86 50 86 C26 86 12 78 12 60 C12 42 26 28 50 28 Z",
149
+ // Pear — narrow top, broad rounded bottom
150
+ pear: "M50 18 C62 18 70 32 70 46 C70 56 80 66 80 76 C80 86 68 90 50 90 C32 90 20 86 20 76 C20 66 30 56 30 46 C30 32 38 18 50 18 Z",
151
+ // Pebble — asymmetric river stone, slight tilt right
152
+ pebble: "M52 19 C72 21 86 36 84 56 C82 73 68 85 50 85 C30 85 16 72 16 54 C16 35 32 17 52 19 Z",
153
+ // Dumpling — round bottom-heavy, narrow shoulders, sits low
154
+ dumpling: "M50 30 C62 30 70 38 70 48 C70 56 78 64 80 72 C82 82 70 88 50 88 C30 88 18 82 20 72 C22 64 30 56 30 48 C30 38 38 30 50 30 Z",
155
+ // Taro — gourd shape: small head bulge, fuller bottom
156
+ taro: "M50 14 C58 14 64 22 64 30 C64 36 60 40 60 46 C60 54 76 60 78 76 C80 88 66 91 50 91 C34 91 20 88 22 76 C24 60 40 54 40 46 C40 40 36 36 36 30 C36 22 42 14 50 14 Z",
157
+ // Wisp — tall narrow body, slight bottom flare, ghost-like
158
+ wisp: "M50 12 C60 12 66 24 66 40 C66 60 74 78 70 90 C64 96 36 96 30 90 C26 78 34 60 34 40 C34 24 40 12 50 12 Z"
159
+ };
160
+ function bodyAnchor(id) {
161
+ return ANCHORS[id];
162
+ }
163
+ function renderBodyDefs(_id, _palette, gradId) {
164
+ return `
165
+ <radialGradient id="${gradId}" cx="42%" cy="32%" r="68%">
166
+ <stop offset="0%" stop-color="${_palette.bodyFrom}" />
167
+ <stop offset="100%" stop-color="${_palette.bodyTo}" />
168
+ </radialGradient>`.trim();
169
+ }
170
+ function renderBody(id, palette, gradId) {
171
+ const d = BODY_PATHS[id];
172
+ const a = ANCHORS[id];
173
+ const outlineColor = withAlpha(palette.ink, 0.18);
174
+ return [
175
+ // Ground shadow — soft ellipse just below body, grounds the figure
176
+ `<ellipse cx="${a.cx}" cy="${a.groundY + 4}" rx="22" ry="2.6" fill="${palette.ink}" opacity="0.16" />`,
177
+ // Body fill
178
+ `<path d="${d}" fill="url(#${gradId})" stroke="${outlineColor}" stroke-width="0.7" />`,
179
+ // Sheen — small light spot upper-left, scaled to body
180
+ `<ellipse cx="${a.cx - 12}" cy="${a.eyeY - 14}" rx="11" ry="7" fill="#FFFFFF" opacity="0.22" transform="rotate(-18 ${a.cx - 12} ${a.eyeY - 14})" />`
181
+ ].join("");
182
+ }
183
+ function withAlpha(hex, alpha) {
184
+ const h = hex.replace("#", "");
185
+ const v = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
186
+ const part = v.slice(0, 6);
187
+ const r = parseInt(part.slice(0, 2), 16);
188
+ const g = parseInt(part.slice(2, 4), 16);
189
+ const b = parseInt(part.slice(4, 6), 16);
190
+ return `rgba(${r},${g},${b},${alpha})`;
191
+ }
192
+
193
+ // src/parts/eyes.ts
194
+ function renderEyes(id, palette, anchor) {
195
+ const lx = anchor.cx - anchor.eyeOffset;
196
+ const rx = anchor.cx + anchor.eyeOffset;
197
+ const y = anchor.eyeY;
198
+ const s = anchor.eyeScale;
199
+ const ink = palette.ink;
200
+ switch (id) {
201
+ case "round":
202
+ return [
203
+ sclera(lx, y, 4 * s, 4.5 * s),
204
+ sclera(rx, y, 4 * s, 4.5 * s),
205
+ pupil(lx, y, 2.2 * s, ink),
206
+ pupil(rx, y, 2.2 * s, ink),
207
+ glint(lx + 1, y - 1),
208
+ glint(rx + 1, y - 1)
209
+ ].join("");
210
+ case "wide":
211
+ return [
212
+ sclera(lx, y, 5 * s, 5.5 * s),
213
+ sclera(rx, y, 5 * s, 5.5 * s),
214
+ pupil(lx, y + 0.5, 3 * s, ink),
215
+ pupil(rx, y + 0.5, 3 * s, ink),
216
+ glint(lx + 1.2, y - 0.5),
217
+ glint(rx + 1.2, y - 0.5)
218
+ ].join("");
219
+ case "squint":
220
+ return [
221
+ arc(lx - 4.5, y, lx, y - 3.5, lx + 4.5, y, ink, 1.8),
222
+ arc(rx - 4.5, y, rx, y - 3.5, rx + 4.5, y, ink, 1.8)
223
+ ].join("");
224
+ case "wink":
225
+ return [
226
+ sclera(lx, y, 4 * s, 4.5 * s),
227
+ pupil(lx, y, 2.2 * s, ink),
228
+ glint(lx + 1, y - 1),
229
+ arc(rx - 4, y, rx, y - 3.5, rx + 4, y, ink, 1.8)
230
+ ].join("");
231
+ case "sleepy":
232
+ return [
233
+ // Heavier upper lid — half-closed
234
+ `<path d="M${lx - 4} ${y - 0.5} Q${lx} ${y + 2} ${lx + 4} ${y - 0.5}" stroke="${ink}" stroke-width="1.7" stroke-linecap="round" fill="none" />`,
235
+ `<path d="M${rx - 4} ${y - 0.5} Q${rx} ${y + 2} ${rx + 4} ${y - 0.5}" stroke="${ink}" stroke-width="1.7" stroke-linecap="round" fill="none" />`,
236
+ // tiny visible pupils
237
+ `<circle cx="${lx}" cy="${y + 0.5}" r="0.9" fill="${ink}" />`,
238
+ `<circle cx="${rx}" cy="${y + 0.5}" r="0.9" fill="${ink}" />`
239
+ ].join("");
240
+ case "star":
241
+ return [starEye(lx, y, ink), starEye(rx, y, ink)].join("");
242
+ case "heart":
243
+ return [heartEye(lx, y, ink), heartEye(rx, y, ink)].join("");
244
+ case "oval":
245
+ return [
246
+ sclera(lx, y, 4.5 * s, 5 * s),
247
+ sclera(rx, y, 4.5 * s, 5 * s),
248
+ `<ellipse cx="${lx}" cy="${y}" rx="${1.6 * s}" ry="${3 * s}" fill="${ink}" />`,
249
+ `<ellipse cx="${rx}" cy="${y}" rx="${1.6 * s}" ry="${3 * s}" fill="${ink}" />`,
250
+ glint(lx + 0.8, y - 1.5),
251
+ glint(rx + 0.8, y - 1.5)
252
+ ].join("");
253
+ case "dot":
254
+ return [
255
+ `<circle cx="${lx}" cy="${y}" r="${1.4 * s}" fill="${ink}" />`,
256
+ `<circle cx="${rx}" cy="${y}" r="${1.4 * s}" fill="${ink}" />`
257
+ ].join("");
258
+ case "cross":
259
+ return [crossEye(lx, y, ink), crossEye(rx, y, ink)].join("");
260
+ }
261
+ }
262
+ function heartEye(cx, cy, color) {
263
+ const s = 2;
264
+ return `<path d="M${cx} ${cy + s * 1.4} L${cx - s * 1.8} ${cy - s * 0.2} A${s} ${s} 0 0 1 ${cx} ${cy - s * 0.6} A${s} ${s} 0 0 1 ${cx + s * 1.8} ${cy - s * 0.2} Z" fill="${color}" />`;
265
+ }
266
+ function crossEye(cx, cy, color) {
267
+ const s = 2.4;
268
+ return `<g stroke="${color}" stroke-width="1.6" stroke-linecap="round"><line x1="${cx - s}" y1="${cy - s}" x2="${cx + s}" y2="${cy + s}" /><line x1="${cx - s}" y1="${cy + s}" x2="${cx + s}" y2="${cy - s}" /></g>`;
269
+ }
270
+ function sclera(cx, cy, rx, ry) {
271
+ return `<ellipse cx="${cx}" cy="${cy}" rx="${rx}" ry="${ry}" fill="#FFFFFF" />`;
272
+ }
273
+ function pupil(cx, cy, r, color) {
274
+ return `<circle cx="${cx}" cy="${cy}" r="${r}" fill="${color}" />`;
275
+ }
276
+ function glint(cx, cy) {
277
+ return `<circle cx="${cx}" cy="${cy}" r="0.8" fill="#FFFFFF" />`;
278
+ }
279
+ function arc(x1, y1, cx, cy, x2, y2, stroke, width) {
280
+ return `<path d="M${x1} ${y1} Q${cx} ${cy} ${x2} ${y2}" stroke="${stroke}" stroke-width="${width}" stroke-linecap="round" fill="none" />`;
281
+ }
282
+ function starEye(cx, cy, color) {
283
+ const s = 3;
284
+ return `<path d="M${cx} ${cy - s} L${cx + s * 0.35} ${cy - s * 0.35} L${cx + s} ${cy} L${cx + s * 0.35} ${cy + s * 0.35} L${cx} ${cy + s} L${cx - s * 0.35} ${cy + s * 0.35} L${cx - s} ${cy} L${cx - s * 0.35} ${cy - s * 0.35} Z" fill="${color}" />`;
285
+ }
286
+
287
+ // src/parts/mouth.ts
288
+ function renderMouth(id, palette, anchor, curveScale = 1) {
289
+ const cx = anchor.cx;
290
+ const y = anchor.mouthY;
291
+ const w = anchor.mouthSpan * curveScale;
292
+ const ink = palette.ink;
293
+ switch (id) {
294
+ case "smile":
295
+ return `<path d="M${cx - w} ${y} Q${cx} ${y + 5} ${cx + w} ${y}" stroke="${ink}" stroke-width="1.8" stroke-linecap="round" fill="none" />`;
296
+ case "grin":
297
+ return `<path d="M${cx - w - 1} ${y - 2} Q${cx} ${y + 7} ${cx + w + 1} ${y - 2}" stroke="${ink}" stroke-width="1.8" stroke-linecap="round" fill="none" />`;
298
+ case "open":
299
+ return [
300
+ `<path d="M${cx - w - 1} ${y - 2} Q${cx} ${y + 9} ${cx + w + 1} ${y - 2}" stroke="${ink}" stroke-width="1.8" stroke-linecap="round" fill="${ink}" fill-opacity="0.55" />`,
301
+ `<ellipse cx="${cx}" cy="${y + 3}" rx="${w * 0.55}" ry="1.8" fill="#F472B6" opacity="0.75" />`
302
+ ].join("");
303
+ case "flat":
304
+ return `<path d="M${cx - w + 1} ${y} L${cx + w - 1} ${y}" stroke="${ink}" stroke-width="1.8" stroke-linecap="round" fill="none" />`;
305
+ case "smirk":
306
+ return `<path d="M${cx - w} ${y} Q${cx} ${y + 3} ${cx + w + 1} ${y - 2}" stroke="${ink}" stroke-width="1.8" stroke-linecap="round" fill="none" />`;
307
+ case "awe":
308
+ return `<ellipse cx="${cx}" cy="${y + 1}" rx="${w * 0.45}" ry="3.2" fill="${ink}" opacity="0.85" />`;
309
+ case "tongue":
310
+ return [
311
+ `<path d="M${cx - w} ${y} Q${cx} ${y + 6} ${cx + w} ${y}" stroke="${ink}" stroke-width="1.8" stroke-linecap="round" fill="none" />`,
312
+ `<path d="M${cx - 2} ${y + 4} Q${cx} ${y + 9} ${cx + 2} ${y + 4} Z" fill="#F472B6" stroke="${ink}" stroke-width="0.6" />`
313
+ ].join("");
314
+ case "tooth":
315
+ return [
316
+ `<path d="M${cx - w} ${y} Q${cx} ${y + 5} ${cx + w} ${y}" stroke="${ink}" stroke-width="1.8" stroke-linecap="round" fill="none" />`,
317
+ `<rect x="${cx - 1.2}" y="${y + 0.4}" width="2.4" height="2.6" rx="0.4" fill="#FFFFFF" stroke="${ink}" stroke-width="0.4" />`
318
+ ].join("");
319
+ case "wave":
320
+ return `<path d="M${cx - w} ${y + 1} Q${cx - w / 2} ${y - 1.5} ${cx} ${y + 1} Q${cx + w / 2} ${y + 3.5} ${cx + w} ${y + 1}" stroke="${ink}" stroke-width="1.8" stroke-linecap="round" fill="none" />`;
321
+ case "dot":
322
+ return `<circle cx="${cx}" cy="${y + 1}" r="1.2" fill="${ink}" />`;
323
+ }
324
+ }
325
+
326
+ // src/parts/antenna.ts
327
+ function renderAntenna(id, anchor, palette) {
328
+ if (id === "none") return "";
329
+ const cx = anchor.topperX;
330
+ const topY = anchor.topperY;
331
+ const color = palette.accent;
332
+ const ink = palette.ink;
333
+ switch (id) {
334
+ case "classic":
335
+ return [
336
+ `<path d="M${cx} ${topY} Q${cx + 1} ${topY - 5} ${cx + 2.5} ${topY - 9}" stroke="${ink}" stroke-width="1.2" stroke-linecap="round" fill="none" opacity="0.55" />`,
337
+ `<circle class="spark" cx="${cx + 2.5}" cy="${topY - 10}" r="2.6" fill="${color}" stroke="${ink}" stroke-width="0.6" opacity="0.95" />`
338
+ ].join("");
339
+ case "curl":
340
+ return [
341
+ `<path d="M${cx} ${topY} Q${cx + 6} ${topY - 4} ${cx + 1} ${topY - 8} Q${cx - 4} ${topY - 11} ${cx + 1} ${topY - 14}" stroke="${ink}" stroke-width="1.2" stroke-linecap="round" fill="none" opacity="0.55" />`,
342
+ `<circle class="spark" cx="${cx + 1}" cy="${topY - 14}" r="2.2" fill="${color}" stroke="${ink}" stroke-width="0.6" opacity="0.95" />`
343
+ ].join("");
344
+ case "double":
345
+ return [
346
+ `<path d="M${cx - 4} ${topY} Q${cx - 5} ${topY - 4} ${cx - 5.5} ${topY - 8}" stroke="${ink}" stroke-width="1.1" stroke-linecap="round" fill="none" opacity="0.55" />`,
347
+ `<path d="M${cx + 4} ${topY} Q${cx + 5} ${topY - 4} ${cx + 5.5} ${topY - 8}" stroke="${ink}" stroke-width="1.1" stroke-linecap="round" fill="none" opacity="0.55" />`,
348
+ `<circle class="spark" cx="${cx - 5.5}" cy="${topY - 9}" r="2.1" fill="${color}" stroke="${ink}" stroke-width="0.5" opacity="0.95" />`,
349
+ `<circle class="spark" cx="${cx + 5.5}" cy="${topY - 9}" r="2.1" fill="${color}" stroke="${ink}" stroke-width="0.5" opacity="0.95" />`
350
+ ].join("");
351
+ case "spike":
352
+ return [
353
+ `<path class="spark" d="M${cx - 2.5} ${topY - 1} L${cx + 1} ${topY - 11} L${cx + 4.5} ${topY - 1} Z" fill="${color}" stroke="${ink}" stroke-width="0.6" opacity="0.95" />`
354
+ ].join("");
355
+ }
356
+ }
357
+
358
+ // src/parts/accessory.ts
359
+ function renderAccessory(id, palette, anchor) {
360
+ switch (id) {
361
+ case "none":
362
+ return "";
363
+ case "blush": {
364
+ const lx = anchor.cx - anchor.cheekOffset;
365
+ const rx = anchor.cx + anchor.cheekOffset;
366
+ const y = anchor.cheekY;
367
+ return [
368
+ `<ellipse cx="${lx}" cy="${y}" rx="3.6" ry="2.2" fill="${palette.blush}" opacity="0.5" />`,
369
+ `<ellipse cx="${rx}" cy="${y}" rx="3.6" ry="2.2" fill="${palette.blush}" opacity="0.5" />`
370
+ ].join("");
371
+ }
372
+ case "freckles": {
373
+ const lx = anchor.cx - 8;
374
+ const rx = anchor.cx + 8;
375
+ const y = anchor.cheekY;
376
+ return [
377
+ dot(lx, y, palette.ink),
378
+ dot(lx + 3, y + 1.5, palette.ink),
379
+ dot(rx, y, palette.ink),
380
+ dot(rx - 3, y + 1.5, palette.ink)
381
+ ].join("");
382
+ }
383
+ case "sparkle":
384
+ return [
385
+ sparkle(76, anchor.eyeY - 18, 3, palette),
386
+ sparkle(24, anchor.eyeY - 16, 2.5, palette),
387
+ sparkle(82, anchor.cheekY + 2, 2, palette)
388
+ ].join("");
389
+ case "glasses": {
390
+ const lx = anchor.cx - anchor.eyeOffset;
391
+ const rx = anchor.cx + anchor.eyeOffset;
392
+ const y = anchor.eyeY;
393
+ const r = 6;
394
+ return [
395
+ `<circle cx="${lx}" cy="${y}" r="${r}" fill="none" stroke="${palette.ink}" stroke-width="1.2" />`,
396
+ `<circle cx="${rx}" cy="${y}" r="${r}" fill="none" stroke="${palette.ink}" stroke-width="1.2" />`,
397
+ `<line x1="${lx + r}" y1="${y}" x2="${rx - r}" y2="${y}" stroke="${palette.ink}" stroke-width="1.2" />`,
398
+ // subtle lens fill
399
+ `<circle cx="${lx}" cy="${y}" r="${r - 1}" fill="#FFFFFF" opacity="0.18" />`,
400
+ `<circle cx="${rx}" cy="${y}" r="${r - 1}" fill="#FFFFFF" opacity="0.18" />`
401
+ ].join("");
402
+ }
403
+ case "eyepatch": {
404
+ const rx = anchor.cx + anchor.eyeOffset;
405
+ const y = anchor.eyeY;
406
+ return [
407
+ `<ellipse cx="${rx}" cy="${y}" rx="6" ry="5.2" fill="${palette.ink}" />`,
408
+ `<path d="M${rx - 6} ${y - 4} L${anchor.cx - 18} ${anchor.eyeY - 8}" stroke="${palette.ink}" stroke-width="0.9" />`,
409
+ `<path d="M${rx + 6} ${y - 3} L${anchor.cx + 22} ${anchor.eyeY - 6}" stroke="${palette.ink}" stroke-width="0.9" />`
410
+ ].join("");
411
+ }
412
+ case "mole": {
413
+ return `<circle cx="${anchor.cx - anchor.cheekOffset * 0.6}" cy="${anchor.cheekY + 2}" r="0.9" fill="${palette.ink}" />`;
414
+ }
415
+ }
416
+ function dot(cx, cy, color) {
417
+ return `<circle cx="${cx}" cy="${cy}" r="0.85" fill="${color}" opacity="0.55" />`;
418
+ }
419
+ function sparkle(cx, cy, s, p) {
420
+ return `<path d="M${cx} ${cy - s} L${cx + s * 0.3} ${cy - s * 0.3} L${cx + s} ${cy} L${cx + s * 0.3} ${cy + s * 0.3} L${cx} ${cy + s} L${cx - s * 0.3} ${cy + s * 0.3} L${cx - s} ${cy} L${cx - s * 0.3} ${cy - s * 0.3} Z" fill="${p.accent}" stroke="${p.ink}" stroke-width="0.3" opacity="0.9" />`;
421
+ }
422
+ }
423
+
424
+ // src/parts/background.ts
425
+ function renderBackground(id, palette, override) {
426
+ const color = override ?? palette.bodyFrom;
427
+ switch (id) {
428
+ case "none":
429
+ return "";
430
+ case "solid":
431
+ return `<rect x="0" y="0" width="100" height="100" fill="${color}" opacity="0.18" />`;
432
+ case "ring":
433
+ return [
434
+ `<circle cx="50" cy="50" r="48" fill="${color}" opacity="0.14" />`,
435
+ `<circle cx="50" cy="50" r="46" fill="none" stroke="${palette.accent}" stroke-width="0.6" opacity="0.4" />`
436
+ ].join("");
437
+ }
438
+ }
439
+
440
+ // src/parts/topper.ts
441
+ function renderTopper(id, anchor, palette) {
442
+ if (id === "none") return "";
443
+ const cx = anchor.topperX;
444
+ const topY = anchor.topperY;
445
+ const ink = palette.ink;
446
+ switch (id) {
447
+ case "ears":
448
+ return [
449
+ `<path d="M${cx - 16} ${topY + 6} L${cx - 11} ${topY - 5} L${cx - 6} ${topY + 8} Z" fill="${palette.bodyTo}" stroke="${ink}" stroke-width="0.6" opacity="0.95" />`,
450
+ `<path d="M${cx + 6} ${topY + 8} L${cx + 11} ${topY - 5} L${cx + 16} ${topY + 6} Z" fill="${palette.bodyTo}" stroke="${ink}" stroke-width="0.6" opacity="0.95" />`,
451
+ // inner ear blush
452
+ `<path d="M${cx - 14} ${topY + 4} L${cx - 11} ${topY - 1} L${cx - 8} ${topY + 5} Z" fill="${palette.blush}" opacity="0.65" />`,
453
+ `<path d="M${cx + 8} ${topY + 5} L${cx + 11} ${topY - 1} L${cx + 14} ${topY + 4} Z" fill="${palette.blush}" opacity="0.65" />`
454
+ ].join("");
455
+ case "roundEars":
456
+ return [
457
+ `<circle cx="${cx - 13}" cy="${topY + 2}" r="6" fill="${palette.bodyTo}" stroke="${ink}" stroke-width="0.6" />`,
458
+ `<circle cx="${cx + 13}" cy="${topY + 2}" r="6" fill="${palette.bodyTo}" stroke="${ink}" stroke-width="0.6" />`,
459
+ `<circle cx="${cx - 13}" cy="${topY + 2}" r="3" fill="${palette.blush}" opacity="0.6" />`,
460
+ `<circle cx="${cx + 13}" cy="${topY + 2}" r="3" fill="${palette.blush}" opacity="0.6" />`
461
+ ].join("");
462
+ case "horn":
463
+ return [
464
+ `<path d="M${cx - 1} ${topY + 2} Q${cx} ${topY - 6} ${cx + 4} ${topY - 10} Q${cx + 6} ${topY - 4} ${cx + 3} ${topY + 2} Z" fill="${palette.accent}" stroke="${ink}" stroke-width="0.6" />`
465
+ ].join("");
466
+ case "horns":
467
+ return [
468
+ `<path d="M${cx - 7} ${topY + 4} Q${cx - 8} ${topY - 4} ${cx - 4} ${topY - 7} Q${cx - 2} ${topY - 1} ${cx - 3} ${topY + 4} Z" fill="${palette.accent}" stroke="${ink}" stroke-width="0.6" />`,
469
+ `<path d="M${cx + 3} ${topY + 4} Q${cx + 2} ${topY - 1} ${cx + 4} ${topY - 7} Q${cx + 8} ${topY - 4} ${cx + 7} ${topY + 4} Z" fill="${palette.accent}" stroke="${ink}" stroke-width="0.6" />`
470
+ ].join("");
471
+ case "tuft":
472
+ return [
473
+ `<path d="M${cx} ${topY + 2} Q${cx - 2} ${topY - 4} ${cx + 1} ${topY - 8} Q${cx + 6} ${topY - 5} ${cx + 4} ${topY + 1} Z" fill="${ink}" opacity="0.85" />`
474
+ ].join("");
475
+ case "cap":
476
+ return [
477
+ `<path d="M${cx - 16} ${topY + 6} Q${cx - 16} ${topY - 8} ${cx} ${topY - 8} Q${cx + 16} ${topY - 8} ${cx + 16} ${topY + 6} Z" fill="${palette.ink}" opacity="0.92" />`,
478
+ `<rect x="${cx - 16}" y="${topY + 5}" width="32" height="2.5" rx="1" fill="${palette.accent}" opacity="0.85" />`,
479
+ `<circle cx="${cx}" cy="${topY - 9}" r="2.2" fill="${palette.accent}" stroke="${ink}" stroke-width="0.5" />`
480
+ ].join("");
481
+ case "leaf":
482
+ return [
483
+ `<path d="M${cx - 1} ${topY + 2} Q${cx - 6} ${topY - 4} ${cx - 1} ${topY - 8} Q${cx + 3} ${topY - 4} ${cx - 1} ${topY + 2} Z" fill="#22C55E" stroke="${ink}" stroke-width="0.4" opacity="0.95" />`,
484
+ `<path d="M${cx + 1} ${topY + 2} Q${cx + 5} ${topY - 2} ${cx + 6} ${topY - 6}" stroke="#16A34A" stroke-width="1" fill="none" stroke-linecap="round" />`
485
+ ].join("");
486
+ case "headband":
487
+ return [
488
+ `<path d="M${cx - 18} ${topY + 8} Q${cx} ${topY + 2} ${cx + 18} ${topY + 8} L${cx + 18} ${topY + 12} Q${cx} ${topY + 6} ${cx - 18} ${topY + 12} Z" fill="${palette.bodyTo}" stroke="${ink}" stroke-width="0.6" />`,
489
+ `<rect x="${cx - 2}" y="${topY + 4}" width="4" height="4" rx="1" fill="${palette.accent}" stroke="${ink}" stroke-width="0.4" />`
490
+ ].join("");
491
+ case "halo":
492
+ return [
493
+ `<ellipse cx="${cx}" cy="${topY - 6}" rx="11" ry="2.5" fill="none" stroke="#FACC15" stroke-width="2" opacity="0.95" />`,
494
+ `<ellipse cx="${cx}" cy="${topY - 6}" rx="8.5" ry="1.6" fill="none" stroke="#FDE68A" stroke-width="0.6" opacity="0.7" />`
495
+ ].join("");
496
+ case "crown":
497
+ return [
498
+ `<path d="M${cx - 11} ${topY + 4} L${cx - 11} ${topY - 4} L${cx - 6} ${topY + 1} L${cx} ${topY - 7} L${cx + 6} ${topY + 1} L${cx + 11} ${topY - 4} L${cx + 11} ${topY + 4} Z" fill="#FACC15" stroke="${ink}" stroke-width="0.7" />`,
499
+ `<circle cx="${cx - 11}" cy="${topY - 4}" r="1.4" fill="#EF4444" stroke="${ink}" stroke-width="0.3" />`,
500
+ `<circle cx="${cx}" cy="${topY - 7}" r="1.6" fill="#EF4444" stroke="${ink}" stroke-width="0.3" />`,
501
+ `<circle cx="${cx + 11}" cy="${topY - 4}" r="1.4" fill="#EF4444" stroke="${ink}" stroke-width="0.3" />`
502
+ ].join("");
503
+ case "antlers":
504
+ return [
505
+ `<path d="M${cx - 5} ${topY + 4} L${cx - 6} ${topY - 4} M${cx - 6} ${topY - 4} L${cx - 10} ${topY - 6} M${cx - 6} ${topY - 4} L${cx - 6} ${topY - 9} M${cx - 6} ${topY - 9} L${cx - 8} ${topY - 11} M${cx - 6} ${topY - 9} L${cx - 3} ${topY - 11}" stroke="${ink}" stroke-width="1.3" stroke-linecap="round" fill="none" />`,
506
+ `<path d="M${cx + 5} ${topY + 4} L${cx + 6} ${topY - 4} M${cx + 6} ${topY - 4} L${cx + 10} ${topY - 6} M${cx + 6} ${topY - 4} L${cx + 6} ${topY - 9} M${cx + 6} ${topY - 9} L${cx + 8} ${topY - 11} M${cx + 6} ${topY - 9} L${cx + 3} ${topY - 11}" stroke="${ink}" stroke-width="1.3" stroke-linecap="round" fill="none" />`
507
+ ].join("");
508
+ }
509
+ }
510
+
511
+ // src/parts/index.ts
512
+ var BODY_IDS = [
513
+ "orb",
514
+ "tall",
515
+ "squat",
516
+ "pear",
517
+ "pebble",
518
+ "dumpling",
519
+ "taro",
520
+ "wisp"
521
+ ];
522
+ var EYE_IDS = [
523
+ "round",
524
+ "wide",
525
+ "squint",
526
+ "wink",
527
+ "sleepy",
528
+ "star",
529
+ "heart",
530
+ "oval",
531
+ "dot",
532
+ "cross"
533
+ ];
534
+ var MOUTH_IDS = [
535
+ "smile",
536
+ "grin",
537
+ "open",
538
+ "flat",
539
+ "smirk",
540
+ "awe",
541
+ "tongue",
542
+ "tooth",
543
+ "wave",
544
+ "dot"
545
+ ];
546
+ var ANTENNA_IDS = ["none", "classic", "curl", "double", "spike"];
547
+ var ACCESSORY_IDS = [
548
+ "none",
549
+ "blush",
550
+ "freckles",
551
+ "sparkle",
552
+ "glasses",
553
+ "eyepatch",
554
+ "mole"
555
+ ];
556
+ var BACKGROUND_IDS = ["none", "solid", "ring"];
557
+ var TOPPER_IDS = [
558
+ // 'none' weighted ~2× so plain-headed avatars stay common
559
+ "none",
560
+ "none",
561
+ "ears",
562
+ "roundEars",
563
+ "horn",
564
+ "horns",
565
+ "tuft",
566
+ "cap",
567
+ "leaf",
568
+ "headband",
569
+ "halo",
570
+ "crown",
571
+ "antlers"
572
+ ];
573
+
574
+ exports.ACCESSORY_IDS = ACCESSORY_IDS;
575
+ exports.ANCHORS = ANCHORS;
576
+ exports.ANTENNA_IDS = ANTENNA_IDS;
577
+ exports.BACKGROUND_IDS = BACKGROUND_IDS;
578
+ exports.BODY_IDS = BODY_IDS;
579
+ exports.EYE_IDS = EYE_IDS;
580
+ exports.MOUTH_IDS = MOUTH_IDS;
581
+ exports.PALETTES = PALETTES;
582
+ exports.PALETTE_BY_ID = PALETTE_BY_ID;
583
+ exports.TOPPER_IDS = TOPPER_IDS;
584
+ exports.bodyAnchor = bodyAnchor;
585
+ exports.renderAccessory = renderAccessory;
586
+ exports.renderAntenna = renderAntenna;
587
+ exports.renderBackground = renderBackground;
588
+ exports.renderBody = renderBody;
589
+ exports.renderBodyDefs = renderBodyDefs;
590
+ exports.renderEyes = renderEyes;
591
+ exports.renderMouth = renderMouth;
592
+ exports.renderTopper = renderTopper;
593
+ //# sourceMappingURL=parts.cjs.map
594
+ //# sourceMappingURL=parts.cjs.map