pixelpeeps 1.0.3 → 1.0.4

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/index.d.mts CHANGED
@@ -23,6 +23,7 @@ type AvatarProps = {
23
23
  mirrored?: boolean;
24
24
  bg?: [string, string] | string | "random";
25
25
  headShape?: HeadShape;
26
+ square?: boolean;
26
27
  alignX?: AlignX;
27
28
  alignY?: AlignY;
28
29
  padding?: number;
@@ -36,6 +37,6 @@ type AvatarProps = {
36
37
  style?: React.CSSProperties;
37
38
  title?: string;
38
39
  };
39
- declare function Avatar({ name, size, bg, colors }: AvatarProps): react_jsx_runtime.JSX.Element;
40
+ declare function Avatar({ name, size, pixelSize, mirrored, bg, colors, headShape, square, alignX, alignY, padding, variant, className, style, title, eyeShape, mouthShape, pupilColor, eyeShine, }: AvatarProps): react_jsx_runtime.JSX.Element;
40
41
 
41
42
  export { Avatar, Avatar as default };
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ type AvatarProps = {
23
23
  mirrored?: boolean;
24
24
  bg?: [string, string] | string | "random";
25
25
  headShape?: HeadShape;
26
+ square?: boolean;
26
27
  alignX?: AlignX;
27
28
  alignY?: AlignY;
28
29
  padding?: number;
@@ -36,6 +37,6 @@ type AvatarProps = {
36
37
  style?: React.CSSProperties;
37
38
  title?: string;
38
39
  };
39
- declare function Avatar({ name, size, bg, colors }: AvatarProps): react_jsx_runtime.JSX.Element;
40
+ declare function Avatar({ name, size, pixelSize, mirrored, bg, colors, headShape, square, alignX, alignY, padding, variant, className, style, title, eyeShape, mouthShape, pupilColor, eyeShine, }: AvatarProps): react_jsx_runtime.JSX.Element;
40
41
 
41
42
  export { Avatar, Avatar as default };
package/dist/index.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  module.exports = __toCommonJS(index_exports);
36
36
 
37
37
  // src/Avatar.tsx
38
+ var React = __toESM(require("react"));
38
39
  var import_nice_color_palettes = __toESM(require("nice-color-palettes"));
39
40
  var import_jsx_runtime = require("react/jsx-runtime");
40
41
  function cyrb128(str) {
@@ -98,6 +99,9 @@ function yiq(hex) {
98
99
  const { r, g, b } = hexToRgb(hex);
99
100
  return (r * 299 + g * 587 + b * 114) / 1e3;
100
101
  }
102
+ function bestFeatureColor(base) {
103
+ return yiq(base) > 150 ? "#111827" : "#ffffff";
104
+ }
101
105
  var NICE_PALETTES = import_nice_color_palettes.default && Array.isArray(import_nice_color_palettes.default) ? import_nice_color_palettes.default : [["#73a9ff", "#fef3c7", "#ffd6a5", "#d4b4ff", "#a7f3d0"]];
102
106
  function resolveBg(rand, bg) {
103
107
  if (!bg || bg === "random") {
@@ -140,75 +144,291 @@ function Face({
140
144
  const eyeShape = decide(eyeShapeProp ?? "random", ["circle", "ellipse", "line", "wink", "sleepy", "surprised"]);
141
145
  const mouthShape = decide(mouthShapeProp ?? "random", ["smile", "frown", "flat", "zigzag"]);
142
146
  const eyeShine = decide(eyeShineProp ?? "random", [true, false]);
143
- const eyeOffsetX = r * 0.36;
144
- const eyeOffsetY = r * 0.22;
145
- const eyeR = Math.max(2, r * 0.08);
146
- const pupilR = eyeR * 0.5;
147
- const mouthWidth = r * 0.7;
148
- const mouthLift = r * 0.2;
147
+ const eyeOffsetX = r * (0.34 + rand() * 0.06);
148
+ const eyeOffsetY = r * (0.2 + rand() * 0.06);
149
+ const eyeR = Math.max(2, Math.round(r * (0.08 + rand() * 0.02)));
150
+ const pupilR = Math.max(1, Math.round(eyeR * (0.45 + rand() * 0.25)));
151
+ const mouthWidth = r * (0.7 + rand() * 0.3);
152
+ const mouthLift = r * (0.18 + rand() * 0.16);
149
153
  const mouthStroke = Math.max(1, Math.round(r * 0.06));
150
- const finalPupilColor = pupilColor && pupilColor !== "auto" ? pupilColor : yiq(color) > 150 ? "#111827" : "#ffffff";
154
+ let finalPupilColor = "#111827";
155
+ if (pupilColor && pupilColor !== "auto") finalPupilColor = pupilColor;
156
+ else finalPupilColor = yiq(color) > 150 ? "#111827" : "#ffffff";
151
157
  const x0 = cx - mouthWidth / 2;
152
158
  const x1 = cx + mouthWidth / 2;
153
159
  const my = cy + mouthLift;
154
- const mouthPaths = {
155
- smile: `M ${x0} ${my} Q ${cx} ${my - r * 0.2} ${x1} ${my}`,
156
- frown: `M ${x0} ${my} Q ${cx} ${my + r * 0.2} ${x1} ${my}`,
157
- flat: `M ${x0} ${my} L ${x1} ${my}`,
158
- zigzag: (() => {
159
- const segs = 6;
160
- const step = mouthWidth / (segs - 1);
161
- let d = `M ${x0} ${my}`;
162
- for (let i = 1; i < segs; i++) {
163
- const px = x0 + step * i;
164
- const py = my + (i % 2 === 0 ? -r * 0.08 : r * 0.08);
165
- d += ` L ${px} ${py}`;
160
+ const mouthPathSmile = (() => {
161
+ const mouthCurve = (rand() - 0.5) * 0.8;
162
+ const cxQ = cx;
163
+ const cyQ = my + r * (-0.25 * mouthCurve - 0.1);
164
+ return `M ${x0} ${my} Q ${cxQ} ${cyQ} ${x1} ${my}`;
165
+ })();
166
+ const mouthPathFrown = (() => {
167
+ const mouthCurve = (rand() - 0.5) * 0.8;
168
+ const cxQ = cx;
169
+ const cyQ = my + r * (0.25 * mouthCurve + 0.08);
170
+ return `M ${x0} ${my} Q ${cxQ} ${cyQ} ${x1} ${my}`;
171
+ })();
172
+ const mouthPathZigzag = (() => {
173
+ const segs = 6;
174
+ const step = mouthWidth / (segs - 1);
175
+ let d = `M ${x0} ${my}`;
176
+ for (let i = 1; i < segs; i++) {
177
+ const px = x0 + step * i;
178
+ const py = my + (i % 2 === 0 ? -r * 0.08 : r * 0.08);
179
+ d += ` L ${px} ${py}`;
180
+ }
181
+ return d;
182
+ })();
183
+ const eyes = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
184
+ (() => {
185
+ const ex = cx - eyeOffsetX;
186
+ const ey = cy - eyeOffsetY;
187
+ switch (eyeShape) {
188
+ case "ellipse":
189
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.1, ry: eyeR * 0.7, fill: color }, "le");
190
+ case "line":
191
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: Math.max(1, Math.round(eyeR * 0.4)), strokeLinecap: "round" }, "ll");
192
+ case "wink":
193
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: Math.max(1, Math.round(eyeR * 0.4)), strokeLinecap: "round" }, "lw");
194
+ case "sleepy":
195
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.05, ry: eyeR * 0.45, fill: color }, "ls") });
196
+ case "surprised":
197
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: eyeR * 1.1, fill: color }, "lsp");
198
+ default:
199
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: eyeR, fill: color }, "lc");
200
+ }
201
+ })(),
202
+ (() => {
203
+ const ex = cx - eyeOffsetX;
204
+ const ey = cy - eyeOffsetY;
205
+ if (eyeShape === "line" || eyeShape === "wink") return null;
206
+ if (eyeShape === "sleepy") {
207
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: Math.max(1, pupilR * 0.6), fill: finalPupilColor }, "lps");
208
+ }
209
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
210
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: pupilR, fill: finalPupilColor }, "lp"),
211
+ eyeShine ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex - pupilR * 0.4, cy: ey - pupilR * 0.6, r: Math.max(0.6, pupilR * 0.35), fill: "#ffffff", opacity: 0.8 }, "lshine") : null
212
+ ] });
213
+ })(),
214
+ (() => {
215
+ const ex = cx + eyeOffsetX;
216
+ const ey = cy - eyeOffsetY;
217
+ switch (eyeShape) {
218
+ case "ellipse":
219
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.1, ry: eyeR * 0.7, fill: color }, "re");
220
+ case "line":
221
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: Math.max(1, Math.round(eyeR * 0.4)), strokeLinecap: "round" }, "rl");
222
+ case "wink":
223
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: eyeR, fill: color }, "rw");
224
+ case "sleepy":
225
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.05, ry: eyeR * 0.45, fill: color }, "rs");
226
+ case "surprised":
227
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: eyeR * 1.1, fill: color }, "rsp");
228
+ default:
229
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: eyeR, fill: color }, "rc");
230
+ }
231
+ })(),
232
+ (() => {
233
+ const ex = cx + eyeOffsetX;
234
+ const ey = cy - eyeOffsetY;
235
+ if (eyeShape === "line" || eyeShape === "wink" && rand() > 0.2) {
236
+ if (eyeShape === "line") return null;
237
+ }
238
+ if (eyeShape === "sleepy") {
239
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: Math.max(1, pupilR * 0.6), fill: finalPupilColor }, "rps");
240
+ }
241
+ if (eyeShape === "wink") {
242
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
243
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: pupilR, fill: finalPupilColor }, "rp"),
244
+ eyeShine ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex - pupilR * 0.4, cy: ey - pupilR * 0.6, r: Math.max(0.6, pupilR * 0.35), fill: "#ffffff", opacity: 0.8 }, "rshine") : null
245
+ ] });
166
246
  }
167
- return d;
247
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
248
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: pupilR, fill: finalPupilColor }, "rp"),
249
+ eyeShine ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex - pupilR * 0.4, cy: ey - pupilR * 0.6, r: Math.max(0.6, pupilR * 0.35), fill: "#ffffff", opacity: 0.8 }, "rshine2") : null
250
+ ] });
168
251
  })()
169
- };
170
- const drawEye = (ex, ey, key) => {
171
- switch (eyeShape) {
172
- case "ellipse":
173
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.1, ry: eyeR * 0.7, fill: color }, key);
174
- case "line":
175
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: eyeR * 0.5, strokeLinecap: "round" }, key);
176
- case "wink":
177
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: eyeR * 0.5, strokeLinecap: "round" }, key);
178
- case "sleepy":
179
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.05, ry: eyeR * 0.45, fill: color }, key);
180
- case "surprised":
181
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: eyeR * 1.1, fill: color }, key);
252
+ ] });
253
+ const mouth = (() => {
254
+ switch (mouthShape) {
255
+ case "frown":
256
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: mouthPathFrown, stroke: color, strokeWidth: mouthStroke, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" });
257
+ case "flat":
258
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: x0, y1: my, x2: x1, y2: my, stroke: color, strokeWidth: Math.max(1, Math.round(mouthStroke * 0.9)), strokeLinecap: "round" });
259
+ case "zigzag":
260
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: mouthPathZigzag, stroke: color, strokeWidth: Math.max(1, Math.round(mouthStroke * 0.9)), fill: "none", strokeLinecap: "round", strokeLinejoin: "round" });
182
261
  default:
183
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: ex, cy: ey, r: eyeR, fill: color }, key);
262
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: mouthPathSmile, stroke: color, strokeWidth: mouthStroke, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" });
184
263
  }
185
- };
186
- const leftEye = drawEye(cx - eyeOffsetX, cy - eyeOffsetY, "le");
187
- const rightEye = drawEye(cx + eyeOffsetX, cy - eyeOffsetY, "re");
188
- const pupils = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
189
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: cx - eyeOffsetX, cy: cy - eyeOffsetY, r: pupilR, fill: finalPupilColor }),
190
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: cx + eyeOffsetX, cy: cy - eyeOffsetY, r: pupilR, fill: finalPupilColor })
191
- ] });
192
- const shine = eyeShine ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
193
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: cx - eyeOffsetX - pupilR * 0.4, cy: cy - eyeOffsetY - pupilR * 0.6, r: pupilR * 0.3, fill: "#fff", opacity: 0.8 }),
194
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: cx + eyeOffsetX - pupilR * 0.4, cy: cy - eyeOffsetY - pupilR * 0.6, r: pupilR * 0.3, fill: "#fff", opacity: 0.8 })
195
- ] }) : null;
196
- const mouth = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: mouthPaths[mouthShape], stroke: color, strokeWidth: mouthStroke, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" });
197
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
198
- leftEye,
199
- rightEye,
200
- pupils,
201
- shine,
202
- mouth
264
+ })();
265
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { children: [
266
+ eyes,
267
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { children: mouth })
203
268
  ] });
204
269
  }
205
- function Avatar({ name, size = 120, bg = "random", colors = "random" }) {
206
- const rand = rngFromSeed(name);
207
- const [bg1, bg2] = resolveBg(rand, bg);
208
- const [base] = resolveCharColors(rand, colors);
209
- const cx = size / 2;
210
- const cy = size / 2;
211
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, style: { borderRadius: "50%", background: `linear-gradient(135deg, ${bg1}, ${bg2})` }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Face, { cx, cy, r: size / 3, color: base, rand }) });
270
+ function Overlays({
271
+ cx,
272
+ cy,
273
+ r,
274
+ a1,
275
+ a2,
276
+ variant,
277
+ shape,
278
+ rand
279
+ }) {
280
+ const x0 = cx - r, y0 = cy - r, x1 = cx + r, y1 = cy + r;
281
+ const left = rand() > 0.5;
282
+ const tlbr = rand() > 0.5;
283
+ const horiz = rand() > 0.5;
284
+ const cornerTL = rand() > 0.5;
285
+ switch (variant) {
286
+ case "plain":
287
+ return null;
288
+ case "split":
289
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: left ? x0 : cx, y: y0, width: r, height: 2 * r, fill: a1 });
290
+ case "diagonal":
291
+ return tlbr ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", { points: `${x0},${y0} ${x1},${y0} ${x1},${y1}`, fill: a1 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", { points: `${x0},${y0} ${x0},${y1} ${x1},${y1}`, fill: a1 });
292
+ case "cap":
293
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: `M ${x0} ${y0 + r * 0.25} L ${x1} ${y0} L ${x1} ${y0 + r * 0.6} Q ${cx} ${y0 + r * 0.85} ${x0} ${y0 + r * 0.6} Z`, fill: a1 });
294
+ case "swoop":
295
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: `M ${x0} ${cy - r * 0.55} Q ${cx} ${cy - r * 1.1} ${x1} ${cy - r * 0.35} L ${x1} ${y1} Q ${cx} ${cy + r * 0.95} ${x0} ${y1} Z`, fill: a1 });
296
+ case "crescent":
297
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
298
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: left ? cx - r * 0.55 : cx + r * 0.55, cy, r: r * 0.95, fill: a2 }),
299
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: left ? cx - r * 0.52 : cx + r * 0.52, cy, r: r * 0.75, fill: "transparent", stroke: shade(a2, -0.25), strokeWidth: r * 0.08 })
300
+ ] });
301
+ case "band":
302
+ return horiz ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: x0, y: cy - r * 0.35, width: 2 * r, height: r * 0.5, fill: a1 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: cx - r * 0.35, y: y0, width: r * 0.5, height: 2 * r, fill: a1 });
303
+ case "corner":
304
+ return cornerTL ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", { points: `${x0},${y0} ${x0 + r * 0.9},${y0} ${x0},${y0 + r * 0.9}`, fill: a1 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", { points: `${x1},${y0} ${x1 - r * 0.9},${y0} ${x1},${y0 + r * 0.9}`, fill: a1 });
305
+ case "ring":
306
+ return shape === "circle" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx, cy, r: r * 0.86, fill: "none", stroke: a1, strokeWidth: r * 0.18 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: cx - r * 0.86, y: cy - r * 0.86, width: 2 * r * 0.86, height: 2 * r * 0.86, rx: r * 0.18, fill: "none", stroke: a1, strokeWidth: r * 0.18 });
307
+ case "arc":
308
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: `M ${x0} ${cy - r * 0.2} A ${r} ${r} 0 0 1 ${x1} ${cy - r * 0.2} L ${x1} ${cy + r * 0.15} A ${r} ${r} 0 0 0 ${x0} ${cy + r * 0.15} Z`, fill: a1 });
309
+ case "wave":
310
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: `M ${x0} ${cy - r * 0.3} C ${cx - r * 0.6} ${cy - r * 0.8}, ${cx - r * 0.2} ${cy + r * 0.1}, ${cx} ${cy} S ${cx + r * 0.6} ${cy + r * 0.8}, ${x1} ${cy + r * 0.3} L ${x1} ${y1} L ${x0} ${y1} Z`, fill: a1 });
311
+ case "half": {
312
+ const diag = rand() > 0.4;
313
+ if (diag) {
314
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polygon", { points: `${x0},${y0} ${x1},${y0} ${x1},${cy + (left ? r * 0.1 : -r * 0.1)}`, fill: a1 });
315
+ } else {
316
+ const offset = left ? -r * 0.18 : r * 0.18;
317
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: cx + offset, cy, r: r * 0.95, fill: a1 });
318
+ }
319
+ }
320
+ default:
321
+ return null;
322
+ }
323
+ }
324
+ function Avatar({
325
+ name,
326
+ size = 128,
327
+ pixelSize = 12,
328
+ mirrored = true,
329
+ bg,
330
+ colors,
331
+ headShape,
332
+ square,
333
+ alignX = "center",
334
+ alignY = "center",
335
+ padding,
336
+ variant = "auto",
337
+ className,
338
+ style,
339
+ title,
340
+ // simplified feature props
341
+ eyeShape,
342
+ mouthShape,
343
+ pupilColor,
344
+ eyeShine
345
+ }) {
346
+ const shape = headShape ?? (square ? "square" : "circle");
347
+ const rand = React.useMemo(() => rngFromSeed(String(name)), [name]);
348
+ const [bg1, bg2] = React.useMemo(() => resolveBg(rand, bg), [rand, bg]);
349
+ const [base, a1, a2] = React.useMemo(() => resolveCharColors(rand, colors), [rand, colors]);
350
+ const faceColor = bestFeatureColor(base);
351
+ const grid = Math.max(6, Math.floor(size / pixelSize));
352
+ const tile = Math.ceil(size / grid);
353
+ const autoPad = Math.max(4, Math.round(size * (0.06 + rand() * 0.02)));
354
+ const pad = padding ?? autoPad;
355
+ const baseR = Math.floor(size * (0.36 + rand() * 0.04));
356
+ const maxR = Math.floor(size / 2 - pad);
357
+ const r = Math.max(8, Math.min(baseR, maxR));
358
+ let cx = size / 2;
359
+ let cy = size / 2;
360
+ if (alignX === "left") cx = r + pad;
361
+ if (alignX === "right") cx = size - (r + pad);
362
+ if (alignY === "top") cy = r + pad;
363
+ if (alignY === "bottom") cy = size - (r + pad);
364
+ const cells = [];
365
+ const cols = mirrored ? Math.ceil(grid / 2) : grid;
366
+ for (let y = 0; y < grid; y++) {
367
+ for (let x = 0; x < cols; x++) {
368
+ const use = rand() > 0.5;
369
+ const fill = use ? bg1 : bg2;
370
+ const px = x * tile;
371
+ const py = y * tile;
372
+ cells.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: px, y: py, width: tile, height: tile, fill }, `L${x},${y}`));
373
+ if (mirrored) {
374
+ const mx = grid - x - 1;
375
+ const mpx = mx * tile;
376
+ cells.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: mpx, y: py, width: tile, height: tile, fill }, `R${mx},${y}`));
377
+ }
378
+ }
379
+ }
380
+ const variants = ["split", "swoop", "diagonal", "cap", "crescent", "band", "corner", "ring", "arc", "wave", "plain", "half"];
381
+ const chosenVariant = variant === "auto" ? pick(rand, variants) : variant;
382
+ const clipId = React.useMemo(() => {
383
+ const [a, b, c, d] = cyrb128(`pp-shape-${name}-${shape}-${r}`);
384
+ return `pps-${a.toString(16)}${b.toString(16)}${c.toString(16)}${d.toString(16)}`;
385
+ }, [name, shape, r]);
386
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
387
+ "svg",
388
+ {
389
+ width: size,
390
+ height: size,
391
+ viewBox: `0 0 ${size} ${size}`,
392
+ xmlns: "http://www.w3.org/2000/svg",
393
+ role: "img",
394
+ "aria-label": title ?? `Avatar ${name}`,
395
+ className,
396
+ style: { display: "inline-block", borderRadius: 12, ...style },
397
+ children: [
398
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { width: size, height: size, fill: bg1 }),
399
+ cells,
400
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("clipPath", { id: clipId, children: shape === "square" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: cx - r, y: cy - r, width: 2 * r, height: 2 * r, rx: Math.max(4, r * 0.12) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx, cy, r }) }) }),
401
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { clipPath: `url(#${clipId})`, children: [
402
+ shape === "square" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
403
+ "rect",
404
+ {
405
+ x: cx - r,
406
+ y: cy - r,
407
+ width: 2 * r,
408
+ height: 2 * r,
409
+ rx: Math.max(4, r * 0.12),
410
+ fill: base
411
+ }
412
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx, cy, r, fill: base }),
413
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Overlays, { cx, cy, r, a1, a2, variant: chosenVariant, shape, rand })
414
+ ] }),
415
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
416
+ Face,
417
+ {
418
+ cx,
419
+ cy,
420
+ r,
421
+ color: faceColor,
422
+ eyeShape,
423
+ mouthShape,
424
+ pupilColor: pupilColor ?? "auto",
425
+ eyeShine,
426
+ rand
427
+ }
428
+ )
429
+ ]
430
+ }
431
+ );
212
432
  }
213
433
  // Annotate the CommonJS export names for ESM import in node:
214
434
  0 && (module.exports = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/Avatar.tsx"],"sourcesContent":["export { default as Avatar } from \"./Avatar\";\r\nexport { default } from \"./Avatar\";\r\n","import * as React from \"react\";\r\nimport palettes100 from \"nice-color-palettes\";\r\n\r\nexport type HeadShape = \"circle\" | \"square\";\r\nexport type Variant =\r\n | \"auto\"\r\n | \"plain\"\r\n | \"split\"\r\n | \"swoop\"\r\n | \"diagonal\"\r\n | \"cap\"\r\n | \"crescent\"\r\n | \"band\"\r\n | \"corner\"\r\n | \"ring\"\r\n | \"arc\"\r\n | \"wave\"\r\n | \"half\";\r\nexport type AlignX = \"left\" | \"center\" | \"right\";\r\nexport type AlignY = \"top\" | \"center\" | \"bottom\";\r\n\r\nexport type FaceProps = {\r\n cx: number;\r\n cy: number;\r\n r: number;\r\n color: string;\r\n eyeShape?: \"circle\" | \"ellipse\" | \"line\" | \"wink\" | \"sleepy\" | \"surprised\" | \"random\";\r\n mouthShape?: \"smile\" | \"frown\" | \"flat\" | \"zigzag\" | \"random\";\r\n pupilColor?: string | \"auto\";\r\n eyeShine?: boolean | \"random\";\r\n rand: () => number;\r\n};\r\n\r\nexport type AvatarProps = {\r\n name: string;\r\n size?: number;\r\n pixelSize?: number;\r\n mirrored?: boolean;\r\n bg?: [string, string] | string | \"random\";\r\n headShape?: HeadShape;\r\n alignX?: AlignX;\r\n alignY?: AlignY;\r\n padding?: number;\r\n colors?: string | [string, string] | [string, string, string] | \"random\";\r\n variant?: Variant;\r\n eyeShape?: FaceProps[\"eyeShape\"];\r\n mouthShape?: FaceProps[\"mouthShape\"];\r\n pupilColor?: string | \"auto\";\r\n eyeShine?: boolean;\r\n className?: string;\r\n style?: React.CSSProperties;\r\n title?: string;\r\n};\r\n\r\nfunction cyrb128(str: string) {\r\n let h1 = 1779033703,\r\n h2 = 3144134277,\r\n h3 = 1013904242,\r\n h4 = 2773480762;\r\n for (let i = 0, k; i < str.length; i++) {\r\n k = str.charCodeAt(i);\r\n h1 = h2 ^ Math.imul(h1 ^ k, 597399067);\r\n h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);\r\n h3 = h4 ^ Math.imul(h3 ^ k, 951274213);\r\n h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);\r\n }\r\n h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);\r\n h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);\r\n h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);\r\n h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);\r\n return [(h1 ^ h2 ^ h3 ^ h4) >>> 0, (h2 ^ h1) >>> 0, (h3 ^ h1) >>> 0, (h4 ^ h1) >>> 0];\r\n}\r\nfunction sfc32(a: number, b: number, c: number, d: number) {\r\n return function () {\r\n a >>>= 0;\r\n b >>>= 0;\r\n c >>>= 0;\r\n d >>>= 0;\r\n let t = (a + b) | 0;\r\n a = b ^ (b >>> 9);\r\n b = (c + (c << 3)) | 0;\r\n c = (c << 21) | (c >>> 11);\r\n d = (d + 1) | 0;\r\n t = (t + d) | 0;\r\n c = (c + t) | 0;\r\n return (t >>> 0) / 4294967296;\r\n };\r\n}\r\nfunction rngFromSeed(seed: string) {\r\n const [a, b, c, d] = cyrb128(seed || \"pixelpeeps\");\r\n return sfc32(a, b, c, d);\r\n}\r\nfunction pick<T>(rand: () => number, arr: T[]) {\r\n return arr[Math.floor(rand() * arr.length)];\r\n}\r\n\r\nfunction hexToRgb(hex: string) {\r\n const h = hex.replace(\"#\", \"\");\r\n const full = h.length === 3 ? h.split(\"\").map((c) => c + c).join(\"\") : h;\r\n const n = parseInt(full, 16);\r\n return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };\r\n}\r\nfunction rgbToHex(r: number, g: number, b: number) {\r\n return \"#\" + [r, g, b].map((v) => v.toString(16).padStart(2, \"0\")).join(\"\");\r\n}\r\nfunction shade(hex: string, percent: number) {\r\n const { r, g, b } = hexToRgb(hex);\r\n const t = percent < 0 ? 0 : 255;\r\n const p = Math.abs(percent);\r\n return rgbToHex(\r\n Math.round((t - r) * p) + r,\r\n Math.round((t - g) * p) + g,\r\n Math.round((t - b) * p) + b\r\n );\r\n}\r\nfunction yiq(hex: string) {\r\n const { r, g, b } = hexToRgb(hex);\r\n return (r * 299 + g * 587 + b * 114) / 1000;\r\n}\r\n\r\nconst NICE_PALETTES: string[][] =\r\n palettes100 && Array.isArray(palettes100)\r\n ? (palettes100 as string[][])\r\n : [[\"#73a9ff\", \"#fef3c7\", \"#ffd6a5\", \"#d4b4ff\", \"#a7f3d0\"]];\r\n\r\nfunction resolveBg(rand: () => number, bg?: AvatarProps[\"bg\"]): [string, string] {\r\n if (!bg || bg === \"random\") {\r\n return pick(rand, NICE_PALETTES).slice(0, 2) as [string, string];\r\n }\r\n if (Array.isArray(bg)) return [bg[0], bg[1] ?? bg[0]];\r\n return [shade(bg, 0.12), shade(bg, -0.06)];\r\n}\r\nfunction resolveCharColors(rand: () => number, colors?: AvatarProps[\"colors\"]): [string, string, string] {\r\n if (!colors || colors === \"random\") {\r\n const pal = pick(rand, NICE_PALETTES);\r\n const base = pal[0];\r\n const a1 = pal[1] ?? shade(base, 0.25);\r\n const a2 = pal[2] ?? shade(base, -0.2);\r\n return [base, a1, a2];\r\n }\r\n if (typeof colors === \"string\") {\r\n return [colors, shade(colors, 0.25), shade(colors, -0.2)];\r\n }\r\n const base = (colors as string[])[0];\r\n const a1 = (colors as string[])[1] ?? shade(base, 0.25);\r\n const a2 = (colors as string[])[2] ?? shade(base, -0.2);\r\n return [base, a1, a2];\r\n}\r\n\r\nfunction Face({\r\n cx,\r\n cy,\r\n r,\r\n color,\r\n eyeShape: eyeShapeProp,\r\n mouthShape: mouthShapeProp,\r\n pupilColor,\r\n eyeShine: eyeShineProp,\r\n rand,\r\n}: FaceProps) {\r\n const decide = <T,>(prop: T | \"random\" | undefined, opts: T[]) => {\r\n if (prop === undefined || prop === \"random\") return pick(rand, opts);\r\n return prop;\r\n };\r\n\r\n const eyeShape = decide(eyeShapeProp ?? \"random\", [\"circle\", \"ellipse\", \"line\", \"wink\", \"sleepy\", \"surprised\"]);\r\n const mouthShape = decide(mouthShapeProp ?? \"random\", [\"smile\", \"frown\", \"flat\", \"zigzag\"]);\r\n const eyeShine = decide(eyeShineProp ?? \"random\", [true, false]);\r\n\r\n const eyeOffsetX = r * 0.36;\r\n const eyeOffsetY = r * 0.22;\r\n const eyeR = Math.max(2, r * 0.08);\r\n const pupilR = eyeR * 0.5;\r\n const mouthWidth = r * 0.7;\r\n const mouthLift = r * 0.2;\r\n const mouthStroke = Math.max(1, Math.round(r * 0.06));\r\n\r\n const finalPupilColor = pupilColor && pupilColor !== \"auto\" ? pupilColor : yiq(color) > 150 ? \"#111827\" : \"#ffffff\";\r\n const x0 = cx - mouthWidth / 2;\r\n const x1 = cx + mouthWidth / 2;\r\n const my = cy + mouthLift;\r\n\r\n const mouthPaths = {\r\n smile: `M ${x0} ${my} Q ${cx} ${my - r * 0.2} ${x1} ${my}`,\r\n frown: `M ${x0} ${my} Q ${cx} ${my + r * 0.2} ${x1} ${my}`,\r\n flat: `M ${x0} ${my} L ${x1} ${my}`,\r\n zigzag: (() => {\r\n const segs = 6;\r\n const step = mouthWidth / (segs - 1);\r\n let d = `M ${x0} ${my}`;\r\n for (let i = 1; i < segs; i++) {\r\n const px = x0 + step * i;\r\n const py = my + (i % 2 === 0 ? -r * 0.08 : r * 0.08);\r\n d += ` L ${px} ${py}`;\r\n }\r\n return d;\r\n })(),\r\n };\r\n\r\n const drawEye = (ex: number, ey: number, key: string) => {\r\n switch (eyeShape) {\r\n case \"ellipse\":\r\n return <ellipse key={key} cx={ex} cy={ey} rx={eyeR * 1.1} ry={eyeR * 0.7} fill={color} />;\r\n case \"line\":\r\n return <line key={key} x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={eyeR * 0.5} strokeLinecap=\"round\" />;\r\n case \"wink\":\r\n return <line key={key} x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={eyeR * 0.5} strokeLinecap=\"round\" />;\r\n case \"sleepy\":\r\n return <ellipse key={key} cx={ex} cy={ey} rx={eyeR * 1.05} ry={eyeR * 0.45} fill={color} />;\r\n case \"surprised\":\r\n return <circle key={key} cx={ex} cy={ey} r={eyeR * 1.1} fill={color} />;\r\n default:\r\n return <circle key={key} cx={ex} cy={ey} r={eyeR} fill={color} />;\r\n }\r\n };\r\n\r\n const leftEye = drawEye(cx - eyeOffsetX, cy - eyeOffsetY, \"le\");\r\n const rightEye = drawEye(cx + eyeOffsetX, cy - eyeOffsetY, \"re\");\r\n\r\n const pupils = (\r\n <>\r\n <circle cx={cx - eyeOffsetX} cy={cy - eyeOffsetY} r={pupilR} fill={finalPupilColor} />\r\n <circle cx={cx + eyeOffsetX} cy={cy - eyeOffsetY} r={pupilR} fill={finalPupilColor} />\r\n </>\r\n );\r\n\r\n const shine = eyeShine ? (\r\n <>\r\n <circle cx={cx - eyeOffsetX - pupilR * 0.4} cy={cy - eyeOffsetY - pupilR * 0.6} r={pupilR * 0.3} fill=\"#fff\" opacity={0.8} />\r\n <circle cx={cx + eyeOffsetX - pupilR * 0.4} cy={cy - eyeOffsetY - pupilR * 0.6} r={pupilR * 0.3} fill=\"#fff\" opacity={0.8} />\r\n </>\r\n ) : null;\r\n\r\n const mouth = <path d={mouthPaths[mouthShape]} stroke={color} strokeWidth={mouthStroke} fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />;\r\n\r\n return (\r\n <>\r\n {leftEye}\r\n {rightEye}\r\n {pupils}\r\n {shine}\r\n {mouth}\r\n </>\r\n );\r\n}\r\n\r\nexport default function Avatar({ name, size = 120, bg = \"random\", colors = \"random\" }: AvatarProps) {\r\n const rand = rngFromSeed(name);\r\n const [bg1, bg2] = resolveBg(rand, bg);\r\n const [base] = resolveCharColors(rand, colors);\r\n const cx = size / 2;\r\n const cy = size / 2;\r\n\r\n return (\r\n <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} style={{ borderRadius: \"50%\", background: `linear-gradient(135deg, ${bg1}, ${bg2})` }}>\r\n <Face cx={cx} cy={cy} r={size / 3} color={base} rand={rand} />\r\n </svg>\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,iCAAwB;AAyMT;AApJf,SAAS,QAAQ,KAAa;AAC5B,MAAI,KAAK,YACP,KAAK,YACL,KAAK,YACL,KAAK;AACP,WAAS,IAAI,GAAG,GAAG,IAAI,IAAI,QAAQ,KAAK;AACtC,QAAI,IAAI,WAAW,CAAC;AACpB,SAAK,KAAK,KAAK,KAAK,KAAK,GAAG,SAAS;AACrC,SAAK,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU;AACtC,SAAK,KAAK,KAAK,KAAK,KAAK,GAAG,SAAS;AACrC,SAAK,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU;AAAA,EACxC;AACA,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,SAAS;AAC1C,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;AAC3C,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,SAAS;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AAO;AAClB,QAAM,KAAK,OAAO;AAElB,SACE,4CAAC,SAAI,OAAO,MAAM,QAAQ,MAAM,SAAS,OAAO,IAAI,IAAI,IAAI,IAAI,OAAO,EAAE,cAAc,OAAO,YAAY,2BAA2B,GAAG,KAAK,GAAG,IAAI,GAClJ,sDAAC,QAAK,IAAQ,IAAQ,GAAG,OAAO,GAAG,OAAO,MAAM,MAAY,GAC9D;AAEJ;","names":["palettes100","base","a1","a2"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/Avatar.tsx"],"sourcesContent":["export { default as Avatar } from \"./Avatar\";\r\nexport { default } from \"./Avatar\";\r\n","import * as React from \"react\";\r\nimport palettes100 from \"nice-color-palettes\";\r\n\r\nexport type HeadShape = \"circle\" | \"square\";\r\nexport type Variant =\r\n | \"auto\"\r\n | \"plain\"\r\n | \"split\"\r\n | \"swoop\"\r\n | \"diagonal\"\r\n | \"cap\"\r\n | \"crescent\"\r\n | \"band\"\r\n | \"corner\"\r\n | \"ring\"\r\n | \"arc\"\r\n | \"wave\"\r\n | \"half\";\r\nexport type AlignX = \"left\" | \"center\" | \"right\";\r\nexport type AlignY = \"top\" | \"center\" | \"bottom\";\r\n\r\nexport type FaceProps = {\r\n cx: number;\r\n cy: number;\r\n r: number;\r\n color: string;\r\n eyeShape?: \"circle\" | \"ellipse\" | \"line\" | \"wink\" | \"sleepy\" | \"surprised\" | \"random\";\r\n mouthShape?: \"smile\" | \"frown\" | \"flat\" | \"zigzag\" | \"random\";\r\n pupilColor?: string | \"auto\";\r\n eyeShine?: boolean | \"random\";\r\n rand: () => number;\r\n};\r\n\r\nexport type AvatarProps = {\r\n name: string;\r\n\r\n // pixel background\r\n size?: number;\r\n pixelSize?: number;\r\n mirrored?: boolean;\r\n bg?: [string, string] | string | \"random\";\r\n\r\n // character controls\r\n headShape?: HeadShape;\r\n square?: boolean; // deprecated\r\n alignX?: AlignX;\r\n alignY?: AlignY;\r\n padding?: number;\r\n\r\n colors?: string | [string, string] | [string, string, string] | \"random\";\r\n variant?: Variant;\r\n\r\n // new feature props (optional)\r\n eyeShape?: FaceProps[\"eyeShape\"];\r\n mouthShape?: FaceProps[\"mouthShape\"];\r\n pupilColor?: string | \"auto\";\r\n eyeShine?: boolean;\r\n\r\n // styling/a11y\r\n className?: string;\r\n style?: React.CSSProperties;\r\n title?: string;\r\n};\r\n\r\n//\r\n// Deterministic RNG (seeded)\r\n// (unchanged from original)\r\nfunction cyrb128(str: string) {\r\n let h1 = 1779033703,\r\n h2 = 3144134277,\r\n h3 = 1013904242,\r\n h4 = 2773480762;\r\n for (let i = 0, k; i < str.length; i++) {\r\n k = str.charCodeAt(i);\r\n h1 = h2 ^ Math.imul(h1 ^ k, 597399067);\r\n h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);\r\n h3 = h4 ^ Math.imul(h3 ^ k, 951274213);\r\n h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);\r\n }\r\n h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);\r\n h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);\r\n h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);\r\n h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);\r\n return [(h1 ^ h2 ^ h3 ^ h4) >>> 0, (h2 ^ h1) >>> 0, (h3 ^ h1) >>> 0, (h4 ^ h1) >>> 0];\r\n}\r\nfunction sfc32(a: number, b: number, c: number, d: number) {\r\n return function () {\r\n a >>>= 0;\r\n b >>>= 0;\r\n c >>>= 0;\r\n d >>>= 0;\r\n let t = (a + b) | 0;\r\n a = b ^ (b >>> 9);\r\n b = (c + (c << 3)) | 0;\r\n c = (c << 21) | (c >>> 11);\r\n d = (d + 1) | 0;\r\n t = (t + d) | 0;\r\n c = (c + t) | 0;\r\n return (t >>> 0) / 4294967296;\r\n };\r\n}\r\nfunction rngFromSeed(seed: string) {\r\n const [a, b, c, d] = cyrb128(seed || \"pixelpeeps\");\r\n return sfc32(a, b, c, d);\r\n}\r\nfunction pick<T>(rand: () => number, arr: T[]) {\r\n return arr[Math.floor(rand() * arr.length)];\r\n}\r\n\r\n//\r\n// Color helpers (unchanged)\r\n//\r\nfunction hexToRgb(hex: string) {\r\n const h = hex.replace(\"#\", \"\");\r\n const full = h.length === 3 ? h.split(\"\").map((c) => c + c).join(\"\") : h;\r\n const n = parseInt(full, 16);\r\n return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };\r\n}\r\nfunction rgbToHex(r: number, g: number, b: number) {\r\n return \"#\" + [r, g, b].map((v) => v.toString(16).padStart(2, \"0\")).join(\"\");\r\n}\r\nfunction shade(hex: string, percent: number) {\r\n const { r, g, b } = hexToRgb(hex);\r\n const t = percent < 0 ? 0 : 255;\r\n const p = Math.abs(percent);\r\n return rgbToHex(\r\n Math.round((t - r) * p) + r,\r\n Math.round((t - g) * p) + g,\r\n Math.round((t - b) * p) + b\r\n );\r\n}\r\nfunction yiq(hex: string) {\r\n const { r, g, b } = hexToRgb(hex);\r\n return (r * 299 + g * 587 + b * 114) / 1000;\r\n}\r\nfunction bestFeatureColor(base: string) {\r\n return yiq(base) > 150 ? \"#111827\" : \"#ffffff\";\r\n}\r\n\r\n//\r\n// Palettes: use nice-color-palettes (top 100)\r\n//\r\nconst NICE_PALETTES: string[][] =\r\n palettes100 && Array.isArray(palettes100) ? (palettes100 as string[][]) : [[\"#73a9ff\", \"#fef3c7\", \"#ffd6a5\", \"#d4b4ff\", \"#a7f3d0\"]];\r\n\r\nfunction resolveBg(rand: () => number, bg?: AvatarProps[\"bg\"]): [string, string] {\r\n if (!bg || bg === \"random\") {\r\n return pick(rand, NICE_PALETTES).slice(0, 2) as [string, string];\r\n }\r\n if (Array.isArray(bg)) return [bg[0], bg[1] ?? bg[0]];\r\n return [shade(bg, 0.12), shade(bg, -0.06)];\r\n}\r\nfunction resolveCharColors(rand: () => number, colors?: AvatarProps[\"colors\"]): [string, string, string] {\r\n if (!colors || colors === \"random\") {\r\n const pal = pick(rand, NICE_PALETTES);\r\n const base = pal[0];\r\n const a1 = pal[1] ?? shade(base, 0.25);\r\n const a2 = pal[2] ?? shade(base, -0.2);\r\n return [base, a1, a2];\r\n }\r\n if (typeof colors === \"string\") {\r\n return [colors, shade(colors, 0.25), shade(colors, -0.2)];\r\n }\r\n const base = (colors as string[])[0];\r\n const a1 = (colors as string[])[1] ?? shade(base, 0.25);\r\n const a2 = (colors as string[])[2] ?? shade(base, -0.2);\r\n return [base, a1, a2];\r\n}\r\n\r\n//\r\n// Face component: simplified features\r\n//\r\nfunction Face({\r\n cx,\r\n cy,\r\n r,\r\n color,\r\n eyeShape: eyeShapeProp,\r\n mouthShape: mouthShapeProp,\r\n pupilColor,\r\n eyeShine: eyeShineProp,\r\n rand,\r\n}: FaceProps) {\r\n // 🌿 deterministic pick helpers\r\n const decide = <T,>(prop: T | \"random\" | undefined, opts: T[]) => {\r\n if (prop === undefined || prop === \"random\") return pick(rand, opts as any) as T;\r\n return prop as T;\r\n };\r\n\r\n // pick features deterministically if prop is \"random\"/undefined\r\n const eyeShape = decide(eyeShapeProp ?? \"random\", [\"circle\", \"ellipse\", \"line\", \"wink\", \"sleepy\", \"surprised\"]);\r\n const mouthShape = decide(mouthShapeProp ?? \"random\", [\"smile\", \"frown\", \"flat\", \"zigzag\"]);\r\n const eyeShine = decide(eyeShineProp ?? \"random\", [true, false]);\r\n\r\n // geometry\r\n const eyeOffsetX = r * (0.34 + rand() * 0.06);\r\n const eyeOffsetY = r * (0.20 + rand() * 0.06);\r\n const eyeR = Math.max(2, Math.round(r * (0.08 + rand() * 0.02)));\r\n const pupilR = Math.max(1, Math.round(eyeR * (0.45 + rand() * 0.25)));\r\n const mouthWidth = r * (0.7 + rand() * 0.3);\r\n const mouthLift = r * (0.18 + rand() * 0.16);\r\n const mouthStroke = Math.max(1, Math.round(r * 0.06));\r\n\r\n // pupil color\r\n let finalPupilColor = \"#111827\";\r\n if (pupilColor && pupilColor !== \"auto\") finalPupilColor = pupilColor;\r\n else finalPupilColor = yiq(color) > 150 ? \"#111827\" : \"#ffffff\";\r\n\r\n // helper positions\r\n const x0 = cx - mouthWidth / 2;\r\n const x1 = cx + mouthWidth / 2;\r\n const my = cy + mouthLift;\r\n\r\n // small helpers to draw various mouth shapes\r\n const mouthPathSmile = (() => {\r\n const mouthCurve = (rand() - 0.5) * 0.8;\r\n const cxQ = cx;\r\n const cyQ = my + r * (-0.25 * mouthCurve - 0.1);\r\n return `M ${x0} ${my} Q ${cxQ} ${cyQ} ${x1} ${my}`;\r\n })();\r\n\r\n const mouthPathFrown = (() => {\r\n const mouthCurve = (rand() - 0.5) * 0.8;\r\n const cxQ = cx;\r\n const cyQ = my + r * (0.25 * mouthCurve + 0.08); // control point below -> frown\r\n return `M ${x0} ${my} Q ${cxQ} ${cyQ} ${x1} ${my}`;\r\n })();\r\n\r\n const mouthPathZigzag = (() => {\r\n // create small zigzag across mouth width\r\n const segs = 6;\r\n const step = mouthWidth / (segs - 1);\r\n let d = `M ${x0} ${my}`;\r\n for (let i = 1; i < segs; i++) {\r\n const px = x0 + step * i;\r\n const py = my + (i % 2 === 0 ? -r * 0.08 : r * 0.08);\r\n d += ` L ${px} ${py}`;\r\n }\r\n return d;\r\n })();\r\n\r\n // build JSX pieces\r\n const eyes = (\r\n <>\r\n {/* left eye */}\r\n {(() => {\r\n const ex = cx - eyeOffsetX;\r\n const ey = cy - eyeOffsetY;\r\n\r\n switch (eyeShape) {\r\n case \"ellipse\":\r\n return (\r\n <ellipse cx={ex} cy={ey} rx={eyeR * 1.1} ry={eyeR * 0.7} fill={color} key=\"le\" />\r\n );\r\n case \"line\":\r\n return <line x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={Math.max(1, Math.round(eyeR * 0.4))} strokeLinecap=\"round\" key=\"ll\" />;\r\n case \"wink\":\r\n // wink left = closed (line)\r\n return <line x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={Math.max(1, Math.round(eyeR * 0.4))} strokeLinecap=\"round\" key=\"lw\" />;\r\n case \"sleepy\":\r\n return (\r\n <>\r\n <ellipse cx={ex} cy={ey} rx={eyeR * 1.05} ry={eyeR * 0.45} fill={color} key=\"ls\" />\r\n </>\r\n );\r\n case \"surprised\":\r\n return <circle cx={ex} cy={ey} r={eyeR * 1.1} fill={color} key=\"lsp\" />;\r\n default:\r\n // circle\r\n return <circle cx={ex} cy={ey} r={eyeR} fill={color} key=\"lc\" />;\r\n }\r\n })()}\r\n\r\n {/* left pupil */}\r\n {(() => {\r\n const ex = cx - eyeOffsetX;\r\n const ey = cy - eyeOffsetY;\r\n // if line/wink (closed) skip pupil\r\n if (eyeShape === \"line\" || eyeShape === \"wink\") return null;\r\n if (eyeShape === \"sleepy\") {\r\n // smaller pupil\r\n return <circle cx={ex} cy={ey} r={Math.max(1, pupilR * 0.6)} fill={finalPupilColor} key=\"lps\" />;\r\n }\r\n return (\r\n <>\r\n <circle cx={ex} cy={ey} r={pupilR} fill={finalPupilColor} key=\"lp\" />\r\n {eyeShine ? <circle cx={ex - pupilR * 0.4} cy={ey - pupilR * 0.6} r={Math.max(0.6, pupilR * 0.35)} fill=\"#ffffff\" opacity={0.8} key=\"lshine\" /> : null}\r\n </>\r\n );\r\n })()}\r\n\r\n {/* right eye */}\r\n {(() => {\r\n const ex = cx + eyeOffsetX;\r\n const ey = cy - eyeOffsetY;\r\n\r\n switch (eyeShape) {\r\n case \"ellipse\":\r\n return (\r\n <ellipse cx={ex} cy={ey} rx={eyeR * 1.1} ry={eyeR * 0.7} fill={color} key=\"re\" />\r\n );\r\n case \"line\":\r\n return <line x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={Math.max(1, Math.round(eyeR * 0.4))} strokeLinecap=\"round\" key=\"rl\" />;\r\n case \"wink\":\r\n // wink right -> keep open; variety: one eye wink looks cute\r\n return <circle cx={ex} cy={ey} r={eyeR} fill={color} key=\"rw\" />;\r\n case \"sleepy\":\r\n return <ellipse cx={ex} cy={ey} rx={eyeR * 1.05} ry={eyeR * 0.45} fill={color} key=\"rs\" />;\r\n case \"surprised\":\r\n return <circle cx={ex} cy={ey} r={eyeR * 1.1} fill={color} key=\"rsp\" />;\r\n default:\r\n return <circle cx={ex} cy={ey} r={eyeR} fill={color} key=\"rc\" />;\r\n }\r\n })()}\r\n\r\n {/* right pupil */}\r\n {(() => {\r\n const ex = cx + eyeOffsetX;\r\n const ey = cy - eyeOffsetY;\r\n if (eyeShape === \"line\" || (eyeShape === \"wink\" && rand() > 0.2)) {\r\n // sometimes wink will be left eye closed; we've drawn right open earlier; if right is closed skip\r\n if (eyeShape === \"line\") return null;\r\n }\r\n if (eyeShape === \"sleepy\") {\r\n return <circle cx={ex} cy={ey} r={Math.max(1, pupilR * 0.6)} fill={finalPupilColor} key=\"rps\" />;\r\n }\r\n if (eyeShape === \"wink\") {\r\n // keep pupil\r\n return (\r\n <>\r\n <circle cx={ex} cy={ey} r={pupilR} fill={finalPupilColor} key=\"rp\" />\r\n {eyeShine ? <circle cx={ex - pupilR * 0.4} cy={ey - pupilR * 0.6} r={Math.max(0.6, pupilR * 0.35)} fill=\"#ffffff\" opacity={0.8} key=\"rshine\" /> : null}\r\n </>\r\n );\r\n }\r\n return (\r\n <>\r\n <circle cx={ex} cy={ey} r={pupilR} fill={finalPupilColor} key=\"rp\" />\r\n {eyeShine ? <circle cx={ex - pupilR * 0.4} cy={ey - pupilR * 0.6} r={Math.max(0.6, pupilR * 0.35)} fill=\"#ffffff\" opacity={0.8} key=\"rshine2\" /> : null}\r\n </>\r\n );\r\n })()}\r\n </>\r\n );\r\n\r\n // mouth drawing based on mouthShape\r\n const mouth = (() => {\r\n switch (mouthShape) {\r\n case \"frown\":\r\n return <path d={mouthPathFrown} stroke={color} strokeWidth={mouthStroke} fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />;\r\n case \"flat\":\r\n return <line x1={x0} y1={my} x2={x1} y2={my} stroke={color} strokeWidth={Math.max(1, Math.round(mouthStroke * 0.9))} strokeLinecap=\"round\" />;\r\n case \"zigzag\":\r\n return <path d={mouthPathZigzag} stroke={color} strokeWidth={Math.max(1, Math.round(mouthStroke * 0.9))} fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />;\r\n default:\r\n return <path d={mouthPathSmile} stroke={color} strokeWidth={mouthStroke} fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />;\r\n }\r\n })();\r\n\r\n return (\r\n <g>\r\n {eyes}\r\n <g>{mouth}</g>\r\n </g>\r\n );\r\n}\r\n\r\n//\r\n// Overlays (variants) -- unchanged, but kept in file\r\n//\r\nfunction Overlays({\r\n cx,\r\n cy,\r\n r,\r\n a1,\r\n a2,\r\n variant,\r\n shape,\r\n rand,\r\n}: {\r\n cx: number;\r\n cy: number;\r\n r: number;\r\n a1: string;\r\n a2: string;\r\n variant: Exclude<Variant, \"auto\">;\r\n shape: HeadShape;\r\n rand: () => number;\r\n}) {\r\n const x0 = cx - r,\r\n y0 = cy - r,\r\n x1 = cx + r,\r\n y1 = cy + r;\r\n\r\n // deterministic options\r\n const left = rand() > 0.5;\r\n const tlbr = rand() > 0.5;\r\n const horiz = rand() > 0.5;\r\n const cornerTL = rand() > 0.5;\r\n\r\n switch (variant) {\r\n case \"plain\":\r\n return null;\r\n\r\n case \"split\":\r\n return <rect x={left ? x0 : cx} y={y0} width={r} height={2 * r} fill={a1} />;\r\n\r\n case \"diagonal\":\r\n return tlbr ? <polygon points={`${x0},${y0} ${x1},${y0} ${x1},${y1}`} fill={a1} /> : <polygon points={`${x0},${y0} ${x0},${y1} ${x1},${y1}`} fill={a1} />;\r\n\r\n case \"cap\":\r\n return <path d={`M ${x0} ${y0 + r * 0.25} L ${x1} ${y0} L ${x1} ${y0 + r * 0.6} Q ${cx} ${y0 + r * 0.85} ${x0} ${y0 + r * 0.6} Z`} fill={a1} />;\r\n\r\n case \"swoop\":\r\n return <path d={`M ${x0} ${cy - r * 0.55} Q ${cx} ${cy - r * 1.1} ${x1} ${cy - r * 0.35} L ${x1} ${y1} Q ${cx} ${cy + r * 0.95} ${x0} ${y1} Z`} fill={a1} />;\r\n\r\n case \"crescent\":\r\n return (\r\n <>\r\n <circle cx={left ? cx - r * 0.55 : cx + r * 0.55} cy={cy} r={r * 0.95} fill={a2} />\r\n <circle cx={left ? cx - r * 0.52 : cx + r * 0.52} cy={cy} r={r * 0.75} fill=\"transparent\" stroke={shade(a2, -0.25)} strokeWidth={r * 0.08} />\r\n </>\r\n );\r\n\r\n case \"band\":\r\n return horiz ? <rect x={x0} y={cy - r * 0.35} width={2 * r} height={r * 0.5} fill={a1} /> : <rect x={cx - r * 0.35} y={y0} width={r * 0.5} height={2 * r} fill={a1} />;\r\n\r\n case \"corner\":\r\n return cornerTL ? <polygon points={`${x0},${y0} ${x0 + r * 0.9},${y0} ${x0},${y0 + r * 0.9}`} fill={a1} /> : <polygon points={`${x1},${y0} ${x1 - r * 0.9},${y0} ${x1},${y0 + r * 0.9}`} fill={a1} />;\r\n\r\n case \"ring\":\r\n return shape === \"circle\" ? <circle cx={cx} cy={cy} r={r * 0.86} fill=\"none\" stroke={a1} strokeWidth={r * 0.18} /> : <rect x={cx - r * 0.86} y={cy - r * 0.86} width={2 * r * 0.86} height={2 * r * 0.86} rx={r * 0.18} fill=\"none\" stroke={a1} strokeWidth={r * 0.18} />;\r\n\r\n case \"arc\":\r\n return <path d={`M ${x0} ${cy - r * 0.2} A ${r} ${r} 0 0 1 ${x1} ${cy - r * 0.2} L ${x1} ${cy + r * 0.15} A ${r} ${r} 0 0 0 ${x0} ${cy + r * 0.15} Z`} fill={a1} />;\r\n\r\n case \"wave\":\r\n return <path d={`M ${x0} ${cy - r * 0.3} C ${cx - r * 0.6} ${cy - r * 0.8}, ${cx - r * 0.2} ${cy + r * 0.1}, ${cx} ${cy} S ${cx + r * 0.6} ${cy + r * 0.8}, ${x1} ${cy + r * 0.3} L ${x1} ${y1} L ${x0} ${y1} Z`} fill={a1} />;\r\n\r\n case \"half\": {\r\n const diag = rand() > 0.4;\r\n if (diag) {\r\n return <polygon points={`${x0},${y0} ${x1},${y0} ${x1},${cy + (left ? r * 0.1 : -r * 0.1)}`} fill={a1} />;\r\n } else {\r\n const offset = left ? -r * 0.18 : r * 0.18;\r\n return <circle cx={cx + offset} cy={cy} r={r * 0.95} fill={a1} />;\r\n }\r\n }\r\n\r\n default:\r\n return null;\r\n }\r\n}\r\n\r\n//\r\n// Main component (simplified props)\r\n//\r\nexport default function Avatar({\r\n name,\r\n size = 128,\r\n pixelSize = 12,\r\n mirrored = true,\r\n bg,\r\n colors,\r\n headShape,\r\n square,\r\n alignX = \"center\",\r\n alignY = \"center\",\r\n padding,\r\n variant = \"auto\",\r\n className,\r\n style,\r\n title,\r\n\r\n // simplified feature props\r\n eyeShape,\r\n mouthShape,\r\n pupilColor,\r\n eyeShine,\r\n}: AvatarProps) {\r\n const shape: HeadShape = headShape ?? (square ? \"square\" : \"circle\");\r\n const rand = React.useMemo(() => rngFromSeed(String(name)), [name]);\r\n\r\n // colors\r\n const [bg1, bg2] = React.useMemo(() => resolveBg(rand, bg), [rand, bg]);\r\n const [base, a1, a2] = React.useMemo(() => resolveCharColors(rand, colors), [rand, colors]);\r\n const faceColor = bestFeatureColor(base);\r\n\r\n // Pixel grid\r\n const grid = Math.max(6, Math.floor(size / pixelSize));\r\n const tile = Math.ceil(size / grid);\r\n\r\n // geometry\r\n const autoPad = Math.max(4, Math.round(size * (0.06 + rand() * 0.02)));\r\n const pad = padding ?? autoPad;\r\n const baseR = Math.floor(size * (0.36 + rand() * 0.04));\r\n const maxR = Math.floor(size / 2 - pad);\r\n const r = Math.max(8, Math.min(baseR, maxR));\r\n\r\n let cx = size / 2;\r\n let cy = size / 2;\r\n if (alignX === \"left\") cx = r + pad;\r\n if (alignX === \"right\") cx = size - (r + pad);\r\n if (alignY === \"top\") cy = r + pad;\r\n if (alignY === \"bottom\") cy = size - (r + pad);\r\n\r\n // pixel pattern\r\n const cells: React.ReactElement[] = [];\r\n const cols = mirrored ? Math.ceil(grid / 2) : grid;\r\n for (let y = 0; y < grid; y++) {\r\n for (let x = 0; x < cols; x++) {\r\n const use = rand() > 0.5;\r\n const fill = use ? bg1 : bg2;\r\n const px = x * tile;\r\n const py = y * tile;\r\n cells.push(<rect key={`L${x},${y}`} x={px} y={py} width={tile} height={tile} fill={fill} />);\r\n if (mirrored) {\r\n const mx = grid - x - 1;\r\n const mpx = mx * tile;\r\n cells.push(<rect key={`R${mx},${y}`} x={mpx} y={py} width={tile} height={tile} fill={fill} />);\r\n }\r\n }\r\n }\r\n\r\n // variants\r\n const variants: Exclude<Variant, \"auto\">[] = [\"split\", \"swoop\", \"diagonal\", \"cap\", \"crescent\", \"band\", \"corner\", \"ring\", \"arc\", \"wave\", \"plain\", \"half\"];\r\n const chosenVariant: Exclude<Variant, \"auto\"> = variant === \"auto\" ? pick(rand, variants) : (variant as Exclude<Variant, \"auto\">);\r\n\r\n // clip path id\r\n const clipId = React.useMemo(() => {\r\n const [a, b, c, d] = cyrb128(`pp-shape-${name}-${shape}-${r}`);\r\n return `pps-${a.toString(16)}${b.toString(16)}${c.toString(16)}${d.toString(16)}`;\r\n }, [name, shape, r]);\r\n\r\n return (\r\n <svg\r\n width={size}\r\n height={size}\r\n viewBox={`0 0 ${size} ${size}`}\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n role=\"img\"\r\n aria-label={title ?? `Avatar ${name}`}\r\n className={className}\r\n style={{ display: \"inline-block\", borderRadius: 12, ...style }}\r\n >\r\n {/* background grid */}\r\n <rect width={size} height={size} fill={bg1} />\r\n {cells}\r\n\r\n <defs>\r\n <clipPath id={clipId}>\r\n {shape === \"square\" ? (\r\n <rect x={cx - r} y={cy - r} width={2 * r} height={2 * r} rx={Math.max(4, r * 0.12)} />\r\n ) : (\r\n <circle cx={cx} cy={cy} r={r} />\r\n )}\r\n </clipPath>\r\n </defs>\r\n\r\n {/* head + overlays */}\r\n <g clipPath={`url(#${clipId})`}>\r\n {shape === \"square\" ? (\r\n <rect\r\n x={cx - r}\r\n y={cy - r}\r\n width={2 * r}\r\n height={2 * r}\r\n rx={Math.max(4, r * 0.12)}\r\n fill={base}\r\n />\r\n ) : (\r\n <circle cx={cx} cy={cy} r={r} fill={base} />\r\n )}\r\n\r\n <Overlays cx={cx} cy={cy} r={r} a1={a1} a2={a2} variant={chosenVariant} shape={shape} rand={rand} />\r\n </g>\r\n\r\n {/* facial features: pass randomized or explicit props */}\r\n <Face\r\n cx={cx}\r\n cy={cy}\r\n r={r}\r\n color={faceColor}\r\n eyeShape={eyeShape}\r\n mouthShape={mouthShape}\r\n pupilColor={pupilColor ?? \"auto\"}\r\n eyeShine={eyeShine}\r\n rand={rand}\r\n />\r\n </svg>\r\n );\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,iCAAwB;AA2PV;AAzLd,SAAS,QAAQ,KAAa;AAC5B,MAAI,KAAK,YACP,KAAK,YACL,KAAK,YACL,KAAK;AACP,WAAS,IAAI,GAAG,GAAG,IAAI,IAAI,QAAQ,KAAK;AACtC,QAAI,IAAI,WAAW,CAAC;AACpB,SAAK,KAAK,KAAK,KAAK,KAAK,GAAG,SAAS;AACrC,SAAK,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU;AACtC,SAAK,KAAK,KAAK,KAAK,KAAK,GAAG,SAAS;AACrC,SAAK,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU;AAAA,EACxC;AACA,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,SAAS;AAC1C,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;AAC3C,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,SAAS;AAC1C,OAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;AAC3C,SAAO,EAAE,KAAK,KAAK,KAAK,QAAQ,IAAI,KAAK,QAAQ,IAAI,KAAK,QAAQ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AS,IAAI,QACX,oBAAU,WACT,4CAAC,UAAK,GAAG,KAAK,GAAG,GAAG,KAAK,GAAG,OAAO,IAAI,GAAG,QAAQ,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,IAAI,GAAG,IAEpF,4CAAC,YAAO,IAAQ,IAAQ,GAAM,GAElC,GACF;AAAA,QAGA,6CAAC,OAAE,UAAU,QAAQ,MAAM,KACxB;AAAA,oBAAU,WACT;AAAA,YAAC;AAAA;AAAA,cACC,GAAG,KAAK;AAAA,cACR,GAAG,KAAK;AAAA,cACR,OAAO,IAAI;AAAA,cACX,QAAQ,IAAI;AAAA,cACZ,IAAI,KAAK,IAAI,GAAG,IAAI,IAAI;AAAA,cACxB,MAAM;AAAA;AAAA,UACR,IAEA,4CAAC,YAAO,IAAQ,IAAQ,GAAM,MAAM,MAAM;AAAA,UAG5C,4CAAC,YAAS,IAAQ,IAAQ,GAAM,IAAQ,IAAQ,SAAS,eAAe,OAAc,MAAY;AAAA,WACpG;AAAA,QAGA;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YACA,YAAY,cAAc;AAAA,YAC1B;AAAA,YACA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["palettes100","base","a1","a2"]}
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/Avatar.tsx
2
+ import * as React from "react";
2
3
  import palettes100 from "nice-color-palettes";
3
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
5
  function cyrb128(str) {
@@ -62,6 +63,9 @@ function yiq(hex) {
62
63
  const { r, g, b } = hexToRgb(hex);
63
64
  return (r * 299 + g * 587 + b * 114) / 1e3;
64
65
  }
66
+ function bestFeatureColor(base) {
67
+ return yiq(base) > 150 ? "#111827" : "#ffffff";
68
+ }
65
69
  var NICE_PALETTES = palettes100 && Array.isArray(palettes100) ? palettes100 : [["#73a9ff", "#fef3c7", "#ffd6a5", "#d4b4ff", "#a7f3d0"]];
66
70
  function resolveBg(rand, bg) {
67
71
  if (!bg || bg === "random") {
@@ -104,75 +108,291 @@ function Face({
104
108
  const eyeShape = decide(eyeShapeProp ?? "random", ["circle", "ellipse", "line", "wink", "sleepy", "surprised"]);
105
109
  const mouthShape = decide(mouthShapeProp ?? "random", ["smile", "frown", "flat", "zigzag"]);
106
110
  const eyeShine = decide(eyeShineProp ?? "random", [true, false]);
107
- const eyeOffsetX = r * 0.36;
108
- const eyeOffsetY = r * 0.22;
109
- const eyeR = Math.max(2, r * 0.08);
110
- const pupilR = eyeR * 0.5;
111
- const mouthWidth = r * 0.7;
112
- const mouthLift = r * 0.2;
111
+ const eyeOffsetX = r * (0.34 + rand() * 0.06);
112
+ const eyeOffsetY = r * (0.2 + rand() * 0.06);
113
+ const eyeR = Math.max(2, Math.round(r * (0.08 + rand() * 0.02)));
114
+ const pupilR = Math.max(1, Math.round(eyeR * (0.45 + rand() * 0.25)));
115
+ const mouthWidth = r * (0.7 + rand() * 0.3);
116
+ const mouthLift = r * (0.18 + rand() * 0.16);
113
117
  const mouthStroke = Math.max(1, Math.round(r * 0.06));
114
- const finalPupilColor = pupilColor && pupilColor !== "auto" ? pupilColor : yiq(color) > 150 ? "#111827" : "#ffffff";
118
+ let finalPupilColor = "#111827";
119
+ if (pupilColor && pupilColor !== "auto") finalPupilColor = pupilColor;
120
+ else finalPupilColor = yiq(color) > 150 ? "#111827" : "#ffffff";
115
121
  const x0 = cx - mouthWidth / 2;
116
122
  const x1 = cx + mouthWidth / 2;
117
123
  const my = cy + mouthLift;
118
- const mouthPaths = {
119
- smile: `M ${x0} ${my} Q ${cx} ${my - r * 0.2} ${x1} ${my}`,
120
- frown: `M ${x0} ${my} Q ${cx} ${my + r * 0.2} ${x1} ${my}`,
121
- flat: `M ${x0} ${my} L ${x1} ${my}`,
122
- zigzag: (() => {
123
- const segs = 6;
124
- const step = mouthWidth / (segs - 1);
125
- let d = `M ${x0} ${my}`;
126
- for (let i = 1; i < segs; i++) {
127
- const px = x0 + step * i;
128
- const py = my + (i % 2 === 0 ? -r * 0.08 : r * 0.08);
129
- d += ` L ${px} ${py}`;
124
+ const mouthPathSmile = (() => {
125
+ const mouthCurve = (rand() - 0.5) * 0.8;
126
+ const cxQ = cx;
127
+ const cyQ = my + r * (-0.25 * mouthCurve - 0.1);
128
+ return `M ${x0} ${my} Q ${cxQ} ${cyQ} ${x1} ${my}`;
129
+ })();
130
+ const mouthPathFrown = (() => {
131
+ const mouthCurve = (rand() - 0.5) * 0.8;
132
+ const cxQ = cx;
133
+ const cyQ = my + r * (0.25 * mouthCurve + 0.08);
134
+ return `M ${x0} ${my} Q ${cxQ} ${cyQ} ${x1} ${my}`;
135
+ })();
136
+ const mouthPathZigzag = (() => {
137
+ const segs = 6;
138
+ const step = mouthWidth / (segs - 1);
139
+ let d = `M ${x0} ${my}`;
140
+ for (let i = 1; i < segs; i++) {
141
+ const px = x0 + step * i;
142
+ const py = my + (i % 2 === 0 ? -r * 0.08 : r * 0.08);
143
+ d += ` L ${px} ${py}`;
144
+ }
145
+ return d;
146
+ })();
147
+ const eyes = /* @__PURE__ */ jsxs(Fragment, { children: [
148
+ (() => {
149
+ const ex = cx - eyeOffsetX;
150
+ const ey = cy - eyeOffsetY;
151
+ switch (eyeShape) {
152
+ case "ellipse":
153
+ return /* @__PURE__ */ jsx("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.1, ry: eyeR * 0.7, fill: color }, "le");
154
+ case "line":
155
+ return /* @__PURE__ */ jsx("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: Math.max(1, Math.round(eyeR * 0.4)), strokeLinecap: "round" }, "ll");
156
+ case "wink":
157
+ return /* @__PURE__ */ jsx("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: Math.max(1, Math.round(eyeR * 0.4)), strokeLinecap: "round" }, "lw");
158
+ case "sleepy":
159
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.05, ry: eyeR * 0.45, fill: color }, "ls") });
160
+ case "surprised":
161
+ return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: eyeR * 1.1, fill: color }, "lsp");
162
+ default:
163
+ return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: eyeR, fill: color }, "lc");
164
+ }
165
+ })(),
166
+ (() => {
167
+ const ex = cx - eyeOffsetX;
168
+ const ey = cy - eyeOffsetY;
169
+ if (eyeShape === "line" || eyeShape === "wink") return null;
170
+ if (eyeShape === "sleepy") {
171
+ return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: Math.max(1, pupilR * 0.6), fill: finalPupilColor }, "lps");
172
+ }
173
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
174
+ /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: pupilR, fill: finalPupilColor }, "lp"),
175
+ eyeShine ? /* @__PURE__ */ jsx("circle", { cx: ex - pupilR * 0.4, cy: ey - pupilR * 0.6, r: Math.max(0.6, pupilR * 0.35), fill: "#ffffff", opacity: 0.8 }, "lshine") : null
176
+ ] });
177
+ })(),
178
+ (() => {
179
+ const ex = cx + eyeOffsetX;
180
+ const ey = cy - eyeOffsetY;
181
+ switch (eyeShape) {
182
+ case "ellipse":
183
+ return /* @__PURE__ */ jsx("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.1, ry: eyeR * 0.7, fill: color }, "re");
184
+ case "line":
185
+ return /* @__PURE__ */ jsx("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: Math.max(1, Math.round(eyeR * 0.4)), strokeLinecap: "round" }, "rl");
186
+ case "wink":
187
+ return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: eyeR, fill: color }, "rw");
188
+ case "sleepy":
189
+ return /* @__PURE__ */ jsx("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.05, ry: eyeR * 0.45, fill: color }, "rs");
190
+ case "surprised":
191
+ return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: eyeR * 1.1, fill: color }, "rsp");
192
+ default:
193
+ return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: eyeR, fill: color }, "rc");
194
+ }
195
+ })(),
196
+ (() => {
197
+ const ex = cx + eyeOffsetX;
198
+ const ey = cy - eyeOffsetY;
199
+ if (eyeShape === "line" || eyeShape === "wink" && rand() > 0.2) {
200
+ if (eyeShape === "line") return null;
201
+ }
202
+ if (eyeShape === "sleepy") {
203
+ return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: Math.max(1, pupilR * 0.6), fill: finalPupilColor }, "rps");
204
+ }
205
+ if (eyeShape === "wink") {
206
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
207
+ /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: pupilR, fill: finalPupilColor }, "rp"),
208
+ eyeShine ? /* @__PURE__ */ jsx("circle", { cx: ex - pupilR * 0.4, cy: ey - pupilR * 0.6, r: Math.max(0.6, pupilR * 0.35), fill: "#ffffff", opacity: 0.8 }, "rshine") : null
209
+ ] });
130
210
  }
131
- return d;
211
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
212
+ /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: pupilR, fill: finalPupilColor }, "rp"),
213
+ eyeShine ? /* @__PURE__ */ jsx("circle", { cx: ex - pupilR * 0.4, cy: ey - pupilR * 0.6, r: Math.max(0.6, pupilR * 0.35), fill: "#ffffff", opacity: 0.8 }, "rshine2") : null
214
+ ] });
132
215
  })()
133
- };
134
- const drawEye = (ex, ey, key) => {
135
- switch (eyeShape) {
136
- case "ellipse":
137
- return /* @__PURE__ */ jsx("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.1, ry: eyeR * 0.7, fill: color }, key);
138
- case "line":
139
- return /* @__PURE__ */ jsx("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: eyeR * 0.5, strokeLinecap: "round" }, key);
140
- case "wink":
141
- return /* @__PURE__ */ jsx("line", { x1: ex - eyeR, y1: ey, x2: ex + eyeR, y2: ey, stroke: color, strokeWidth: eyeR * 0.5, strokeLinecap: "round" }, key);
142
- case "sleepy":
143
- return /* @__PURE__ */ jsx("ellipse", { cx: ex, cy: ey, rx: eyeR * 1.05, ry: eyeR * 0.45, fill: color }, key);
144
- case "surprised":
145
- return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: eyeR * 1.1, fill: color }, key);
216
+ ] });
217
+ const mouth = (() => {
218
+ switch (mouthShape) {
219
+ case "frown":
220
+ return /* @__PURE__ */ jsx("path", { d: mouthPathFrown, stroke: color, strokeWidth: mouthStroke, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" });
221
+ case "flat":
222
+ return /* @__PURE__ */ jsx("line", { x1: x0, y1: my, x2: x1, y2: my, stroke: color, strokeWidth: Math.max(1, Math.round(mouthStroke * 0.9)), strokeLinecap: "round" });
223
+ case "zigzag":
224
+ return /* @__PURE__ */ jsx("path", { d: mouthPathZigzag, stroke: color, strokeWidth: Math.max(1, Math.round(mouthStroke * 0.9)), fill: "none", strokeLinecap: "round", strokeLinejoin: "round" });
146
225
  default:
147
- return /* @__PURE__ */ jsx("circle", { cx: ex, cy: ey, r: eyeR, fill: color }, key);
226
+ return /* @__PURE__ */ jsx("path", { d: mouthPathSmile, stroke: color, strokeWidth: mouthStroke, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" });
148
227
  }
149
- };
150
- const leftEye = drawEye(cx - eyeOffsetX, cy - eyeOffsetY, "le");
151
- const rightEye = drawEye(cx + eyeOffsetX, cy - eyeOffsetY, "re");
152
- const pupils = /* @__PURE__ */ jsxs(Fragment, { children: [
153
- /* @__PURE__ */ jsx("circle", { cx: cx - eyeOffsetX, cy: cy - eyeOffsetY, r: pupilR, fill: finalPupilColor }),
154
- /* @__PURE__ */ jsx("circle", { cx: cx + eyeOffsetX, cy: cy - eyeOffsetY, r: pupilR, fill: finalPupilColor })
155
- ] });
156
- const shine = eyeShine ? /* @__PURE__ */ jsxs(Fragment, { children: [
157
- /* @__PURE__ */ jsx("circle", { cx: cx - eyeOffsetX - pupilR * 0.4, cy: cy - eyeOffsetY - pupilR * 0.6, r: pupilR * 0.3, fill: "#fff", opacity: 0.8 }),
158
- /* @__PURE__ */ jsx("circle", { cx: cx + eyeOffsetX - pupilR * 0.4, cy: cy - eyeOffsetY - pupilR * 0.6, r: pupilR * 0.3, fill: "#fff", opacity: 0.8 })
159
- ] }) : null;
160
- const mouth = /* @__PURE__ */ jsx("path", { d: mouthPaths[mouthShape], stroke: color, strokeWidth: mouthStroke, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" });
161
- return /* @__PURE__ */ jsxs(Fragment, { children: [
162
- leftEye,
163
- rightEye,
164
- pupils,
165
- shine,
166
- mouth
228
+ })();
229
+ return /* @__PURE__ */ jsxs("g", { children: [
230
+ eyes,
231
+ /* @__PURE__ */ jsx("g", { children: mouth })
167
232
  ] });
168
233
  }
169
- function Avatar({ name, size = 120, bg = "random", colors = "random" }) {
170
- const rand = rngFromSeed(name);
171
- const [bg1, bg2] = resolveBg(rand, bg);
172
- const [base] = resolveCharColors(rand, colors);
173
- const cx = size / 2;
174
- const cy = size / 2;
175
- return /* @__PURE__ */ jsx("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, style: { borderRadius: "50%", background: `linear-gradient(135deg, ${bg1}, ${bg2})` }, children: /* @__PURE__ */ jsx(Face, { cx, cy, r: size / 3, color: base, rand }) });
234
+ function Overlays({
235
+ cx,
236
+ cy,
237
+ r,
238
+ a1,
239
+ a2,
240
+ variant,
241
+ shape,
242
+ rand
243
+ }) {
244
+ const x0 = cx - r, y0 = cy - r, x1 = cx + r, y1 = cy + r;
245
+ const left = rand() > 0.5;
246
+ const tlbr = rand() > 0.5;
247
+ const horiz = rand() > 0.5;
248
+ const cornerTL = rand() > 0.5;
249
+ switch (variant) {
250
+ case "plain":
251
+ return null;
252
+ case "split":
253
+ return /* @__PURE__ */ jsx("rect", { x: left ? x0 : cx, y: y0, width: r, height: 2 * r, fill: a1 });
254
+ case "diagonal":
255
+ return tlbr ? /* @__PURE__ */ jsx("polygon", { points: `${x0},${y0} ${x1},${y0} ${x1},${y1}`, fill: a1 }) : /* @__PURE__ */ jsx("polygon", { points: `${x0},${y0} ${x0},${y1} ${x1},${y1}`, fill: a1 });
256
+ case "cap":
257
+ return /* @__PURE__ */ jsx("path", { d: `M ${x0} ${y0 + r * 0.25} L ${x1} ${y0} L ${x1} ${y0 + r * 0.6} Q ${cx} ${y0 + r * 0.85} ${x0} ${y0 + r * 0.6} Z`, fill: a1 });
258
+ case "swoop":
259
+ return /* @__PURE__ */ jsx("path", { d: `M ${x0} ${cy - r * 0.55} Q ${cx} ${cy - r * 1.1} ${x1} ${cy - r * 0.35} L ${x1} ${y1} Q ${cx} ${cy + r * 0.95} ${x0} ${y1} Z`, fill: a1 });
260
+ case "crescent":
261
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
262
+ /* @__PURE__ */ jsx("circle", { cx: left ? cx - r * 0.55 : cx + r * 0.55, cy, r: r * 0.95, fill: a2 }),
263
+ /* @__PURE__ */ jsx("circle", { cx: left ? cx - r * 0.52 : cx + r * 0.52, cy, r: r * 0.75, fill: "transparent", stroke: shade(a2, -0.25), strokeWidth: r * 0.08 })
264
+ ] });
265
+ case "band":
266
+ return horiz ? /* @__PURE__ */ jsx("rect", { x: x0, y: cy - r * 0.35, width: 2 * r, height: r * 0.5, fill: a1 }) : /* @__PURE__ */ jsx("rect", { x: cx - r * 0.35, y: y0, width: r * 0.5, height: 2 * r, fill: a1 });
267
+ case "corner":
268
+ return cornerTL ? /* @__PURE__ */ jsx("polygon", { points: `${x0},${y0} ${x0 + r * 0.9},${y0} ${x0},${y0 + r * 0.9}`, fill: a1 }) : /* @__PURE__ */ jsx("polygon", { points: `${x1},${y0} ${x1 - r * 0.9},${y0} ${x1},${y0 + r * 0.9}`, fill: a1 });
269
+ case "ring":
270
+ return shape === "circle" ? /* @__PURE__ */ jsx("circle", { cx, cy, r: r * 0.86, fill: "none", stroke: a1, strokeWidth: r * 0.18 }) : /* @__PURE__ */ jsx("rect", { x: cx - r * 0.86, y: cy - r * 0.86, width: 2 * r * 0.86, height: 2 * r * 0.86, rx: r * 0.18, fill: "none", stroke: a1, strokeWidth: r * 0.18 });
271
+ case "arc":
272
+ return /* @__PURE__ */ jsx("path", { d: `M ${x0} ${cy - r * 0.2} A ${r} ${r} 0 0 1 ${x1} ${cy - r * 0.2} L ${x1} ${cy + r * 0.15} A ${r} ${r} 0 0 0 ${x0} ${cy + r * 0.15} Z`, fill: a1 });
273
+ case "wave":
274
+ return /* @__PURE__ */ jsx("path", { d: `M ${x0} ${cy - r * 0.3} C ${cx - r * 0.6} ${cy - r * 0.8}, ${cx - r * 0.2} ${cy + r * 0.1}, ${cx} ${cy} S ${cx + r * 0.6} ${cy + r * 0.8}, ${x1} ${cy + r * 0.3} L ${x1} ${y1} L ${x0} ${y1} Z`, fill: a1 });
275
+ case "half": {
276
+ const diag = rand() > 0.4;
277
+ if (diag) {
278
+ return /* @__PURE__ */ jsx("polygon", { points: `${x0},${y0} ${x1},${y0} ${x1},${cy + (left ? r * 0.1 : -r * 0.1)}`, fill: a1 });
279
+ } else {
280
+ const offset = left ? -r * 0.18 : r * 0.18;
281
+ return /* @__PURE__ */ jsx("circle", { cx: cx + offset, cy, r: r * 0.95, fill: a1 });
282
+ }
283
+ }
284
+ default:
285
+ return null;
286
+ }
287
+ }
288
+ function Avatar({
289
+ name,
290
+ size = 128,
291
+ pixelSize = 12,
292
+ mirrored = true,
293
+ bg,
294
+ colors,
295
+ headShape,
296
+ square,
297
+ alignX = "center",
298
+ alignY = "center",
299
+ padding,
300
+ variant = "auto",
301
+ className,
302
+ style,
303
+ title,
304
+ // simplified feature props
305
+ eyeShape,
306
+ mouthShape,
307
+ pupilColor,
308
+ eyeShine
309
+ }) {
310
+ const shape = headShape ?? (square ? "square" : "circle");
311
+ const rand = React.useMemo(() => rngFromSeed(String(name)), [name]);
312
+ const [bg1, bg2] = React.useMemo(() => resolveBg(rand, bg), [rand, bg]);
313
+ const [base, a1, a2] = React.useMemo(() => resolveCharColors(rand, colors), [rand, colors]);
314
+ const faceColor = bestFeatureColor(base);
315
+ const grid = Math.max(6, Math.floor(size / pixelSize));
316
+ const tile = Math.ceil(size / grid);
317
+ const autoPad = Math.max(4, Math.round(size * (0.06 + rand() * 0.02)));
318
+ const pad = padding ?? autoPad;
319
+ const baseR = Math.floor(size * (0.36 + rand() * 0.04));
320
+ const maxR = Math.floor(size / 2 - pad);
321
+ const r = Math.max(8, Math.min(baseR, maxR));
322
+ let cx = size / 2;
323
+ let cy = size / 2;
324
+ if (alignX === "left") cx = r + pad;
325
+ if (alignX === "right") cx = size - (r + pad);
326
+ if (alignY === "top") cy = r + pad;
327
+ if (alignY === "bottom") cy = size - (r + pad);
328
+ const cells = [];
329
+ const cols = mirrored ? Math.ceil(grid / 2) : grid;
330
+ for (let y = 0; y < grid; y++) {
331
+ for (let x = 0; x < cols; x++) {
332
+ const use = rand() > 0.5;
333
+ const fill = use ? bg1 : bg2;
334
+ const px = x * tile;
335
+ const py = y * tile;
336
+ cells.push(/* @__PURE__ */ jsx("rect", { x: px, y: py, width: tile, height: tile, fill }, `L${x},${y}`));
337
+ if (mirrored) {
338
+ const mx = grid - x - 1;
339
+ const mpx = mx * tile;
340
+ cells.push(/* @__PURE__ */ jsx("rect", { x: mpx, y: py, width: tile, height: tile, fill }, `R${mx},${y}`));
341
+ }
342
+ }
343
+ }
344
+ const variants = ["split", "swoop", "diagonal", "cap", "crescent", "band", "corner", "ring", "arc", "wave", "plain", "half"];
345
+ const chosenVariant = variant === "auto" ? pick(rand, variants) : variant;
346
+ const clipId = React.useMemo(() => {
347
+ const [a, b, c, d] = cyrb128(`pp-shape-${name}-${shape}-${r}`);
348
+ return `pps-${a.toString(16)}${b.toString(16)}${c.toString(16)}${d.toString(16)}`;
349
+ }, [name, shape, r]);
350
+ return /* @__PURE__ */ jsxs(
351
+ "svg",
352
+ {
353
+ width: size,
354
+ height: size,
355
+ viewBox: `0 0 ${size} ${size}`,
356
+ xmlns: "http://www.w3.org/2000/svg",
357
+ role: "img",
358
+ "aria-label": title ?? `Avatar ${name}`,
359
+ className,
360
+ style: { display: "inline-block", borderRadius: 12, ...style },
361
+ children: [
362
+ /* @__PURE__ */ jsx("rect", { width: size, height: size, fill: bg1 }),
363
+ cells,
364
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: clipId, children: shape === "square" ? /* @__PURE__ */ jsx("rect", { x: cx - r, y: cy - r, width: 2 * r, height: 2 * r, rx: Math.max(4, r * 0.12) }) : /* @__PURE__ */ jsx("circle", { cx, cy, r }) }) }),
365
+ /* @__PURE__ */ jsxs("g", { clipPath: `url(#${clipId})`, children: [
366
+ shape === "square" ? /* @__PURE__ */ jsx(
367
+ "rect",
368
+ {
369
+ x: cx - r,
370
+ y: cy - r,
371
+ width: 2 * r,
372
+ height: 2 * r,
373
+ rx: Math.max(4, r * 0.12),
374
+ fill: base
375
+ }
376
+ ) : /* @__PURE__ */ jsx("circle", { cx, cy, r, fill: base }),
377
+ /* @__PURE__ */ jsx(Overlays, { cx, cy, r, a1, a2, variant: chosenVariant, shape, rand })
378
+ ] }),
379
+ /* @__PURE__ */ jsx(
380
+ Face,
381
+ {
382
+ cx,
383
+ cy,
384
+ r,
385
+ color: faceColor,
386
+ eyeShape,
387
+ mouthShape,
388
+ pupilColor: pupilColor ?? "auto",
389
+ eyeShine,
390
+ rand
391
+ }
392
+ )
393
+ ]
394
+ }
395
+ );
176
396
  }
177
397
  export {
178
398
  Avatar,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Avatar.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport palettes100 from \"nice-color-palettes\";\r\n\r\nexport type HeadShape = \"circle\" | \"square\";\r\nexport type Variant =\r\n | \"auto\"\r\n | \"plain\"\r\n | \"split\"\r\n | \"swoop\"\r\n | \"diagonal\"\r\n | \"cap\"\r\n | \"crescent\"\r\n | \"band\"\r\n | \"corner\"\r\n | \"ring\"\r\n | \"arc\"\r\n | \"wave\"\r\n | \"half\";\r\nexport type AlignX = \"left\" | \"center\" | \"right\";\r\nexport type AlignY = \"top\" | \"center\" | \"bottom\";\r\n\r\nexport type FaceProps = {\r\n cx: number;\r\n cy: number;\r\n r: number;\r\n color: string;\r\n eyeShape?: \"circle\" | \"ellipse\" | \"line\" | \"wink\" | \"sleepy\" | \"surprised\" | \"random\";\r\n mouthShape?: \"smile\" | \"frown\" | \"flat\" | \"zigzag\" | \"random\";\r\n pupilColor?: string | \"auto\";\r\n eyeShine?: boolean | \"random\";\r\n rand: () => number;\r\n};\r\n\r\nexport type AvatarProps = {\r\n name: string;\r\n size?: number;\r\n pixelSize?: number;\r\n mirrored?: boolean;\r\n bg?: [string, string] | string | \"random\";\r\n headShape?: HeadShape;\r\n alignX?: AlignX;\r\n alignY?: AlignY;\r\n padding?: number;\r\n colors?: string | [string, string] | [string, string, string] | \"random\";\r\n variant?: Variant;\r\n eyeShape?: FaceProps[\"eyeShape\"];\r\n mouthShape?: FaceProps[\"mouthShape\"];\r\n pupilColor?: string | \"auto\";\r\n eyeShine?: boolean;\r\n className?: string;\r\n style?: React.CSSProperties;\r\n title?: string;\r\n};\r\n\r\nfunction cyrb128(str: string) {\r\n let h1 = 1779033703,\r\n h2 = 3144134277,\r\n h3 = 1013904242,\r\n h4 = 2773480762;\r\n for (let i = 0, k; i < str.length; i++) {\r\n k = str.charCodeAt(i);\r\n h1 = h2 ^ Math.imul(h1 ^ k, 597399067);\r\n h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);\r\n h3 = h4 ^ Math.imul(h3 ^ k, 951274213);\r\n h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);\r\n }\r\n h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);\r\n h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);\r\n h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);\r\n h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);\r\n return [(h1 ^ h2 ^ h3 ^ h4) >>> 0, (h2 ^ h1) >>> 0, (h3 ^ h1) >>> 0, (h4 ^ h1) >>> 0];\r\n}\r\nfunction sfc32(a: number, b: number, c: number, d: number) {\r\n return function () {\r\n a >>>= 0;\r\n b >>>= 0;\r\n c >>>= 0;\r\n d >>>= 0;\r\n let t = (a + b) | 0;\r\n a = b ^ (b >>> 9);\r\n b = (c + (c << 3)) | 0;\r\n c = (c << 21) | (c >>> 11);\r\n d = (d + 1) | 0;\r\n t = (t + d) | 0;\r\n c = (c + t) | 0;\r\n return (t >>> 0) / 4294967296;\r\n };\r\n}\r\nfunction rngFromSeed(seed: string) {\r\n const [a, b, c, d] = cyrb128(seed || \"pixelpeeps\");\r\n return sfc32(a, b, c, d);\r\n}\r\nfunction pick<T>(rand: () => number, arr: T[]) {\r\n return arr[Math.floor(rand() * arr.length)];\r\n}\r\n\r\nfunction hexToRgb(hex: string) {\r\n const h = hex.replace(\"#\", \"\");\r\n const full = h.length === 3 ? h.split(\"\").map((c) => c + c).join(\"\") : h;\r\n const n = parseInt(full, 16);\r\n return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };\r\n}\r\nfunction rgbToHex(r: number, g: number, b: number) {\r\n return \"#\" + [r, g, b].map((v) => v.toString(16).padStart(2, \"0\")).join(\"\");\r\n}\r\nfunction shade(hex: string, percent: number) {\r\n const { r, g, b } = hexToRgb(hex);\r\n const t = percent < 0 ? 0 : 255;\r\n const p = Math.abs(percent);\r\n return rgbToHex(\r\n Math.round((t - r) * p) + r,\r\n Math.round((t - g) * p) + g,\r\n Math.round((t - b) * p) + b\r\n );\r\n}\r\nfunction yiq(hex: string) {\r\n const { r, g, b } = hexToRgb(hex);\r\n return (r * 299 + g * 587 + b * 114) / 1000;\r\n}\r\n\r\nconst NICE_PALETTES: string[][] =\r\n palettes100 && Array.isArray(palettes100)\r\n ? (palettes100 as string[][])\r\n : [[\"#73a9ff\", \"#fef3c7\", \"#ffd6a5\", \"#d4b4ff\", \"#a7f3d0\"]];\r\n\r\nfunction resolveBg(rand: () => number, bg?: AvatarProps[\"bg\"]): [string, string] {\r\n if (!bg || bg === \"random\") {\r\n return pick(rand, NICE_PALETTES).slice(0, 2) as [string, string];\r\n }\r\n if (Array.isArray(bg)) return [bg[0], bg[1] ?? bg[0]];\r\n return [shade(bg, 0.12), shade(bg, -0.06)];\r\n}\r\nfunction resolveCharColors(rand: () => number, colors?: AvatarProps[\"colors\"]): [string, string, string] {\r\n if (!colors || colors === \"random\") {\r\n const pal = pick(rand, NICE_PALETTES);\r\n const base = pal[0];\r\n const a1 = pal[1] ?? shade(base, 0.25);\r\n const a2 = pal[2] ?? shade(base, -0.2);\r\n return [base, a1, a2];\r\n }\r\n if (typeof colors === \"string\") {\r\n return [colors, shade(colors, 0.25), shade(colors, -0.2)];\r\n }\r\n const base = (colors as string[])[0];\r\n const a1 = (colors as string[])[1] ?? shade(base, 0.25);\r\n const a2 = (colors as string[])[2] ?? shade(base, -0.2);\r\n return [base, a1, a2];\r\n}\r\n\r\nfunction Face({\r\n cx,\r\n cy,\r\n r,\r\n color,\r\n eyeShape: eyeShapeProp,\r\n mouthShape: mouthShapeProp,\r\n pupilColor,\r\n eyeShine: eyeShineProp,\r\n rand,\r\n}: FaceProps) {\r\n const decide = <T,>(prop: T | \"random\" | undefined, opts: T[]) => {\r\n if (prop === undefined || prop === \"random\") return pick(rand, opts);\r\n return prop;\r\n };\r\n\r\n const eyeShape = decide(eyeShapeProp ?? \"random\", [\"circle\", \"ellipse\", \"line\", \"wink\", \"sleepy\", \"surprised\"]);\r\n const mouthShape = decide(mouthShapeProp ?? \"random\", [\"smile\", \"frown\", \"flat\", \"zigzag\"]);\r\n const eyeShine = decide(eyeShineProp ?? \"random\", [true, false]);\r\n\r\n const eyeOffsetX = r * 0.36;\r\n const eyeOffsetY = r * 0.22;\r\n const eyeR = Math.max(2, r * 0.08);\r\n const pupilR = eyeR * 0.5;\r\n const mouthWidth = r * 0.7;\r\n const mouthLift = r * 0.2;\r\n const mouthStroke = Math.max(1, Math.round(r * 0.06));\r\n\r\n const finalPupilColor = pupilColor && pupilColor !== \"auto\" ? pupilColor : yiq(color) > 150 ? \"#111827\" : \"#ffffff\";\r\n const x0 = cx - mouthWidth / 2;\r\n const x1 = cx + mouthWidth / 2;\r\n const my = cy + mouthLift;\r\n\r\n const mouthPaths = {\r\n smile: `M ${x0} ${my} Q ${cx} ${my - r * 0.2} ${x1} ${my}`,\r\n frown: `M ${x0} ${my} Q ${cx} ${my + r * 0.2} ${x1} ${my}`,\r\n flat: `M ${x0} ${my} L ${x1} ${my}`,\r\n zigzag: (() => {\r\n const segs = 6;\r\n const step = mouthWidth / (segs - 1);\r\n let d = `M ${x0} ${my}`;\r\n for (let i = 1; i < segs; i++) {\r\n const px = x0 + step * i;\r\n const py = my + (i % 2 === 0 ? -r * 0.08 : r * 0.08);\r\n d += ` L ${px} ${py}`;\r\n }\r\n return d;\r\n })(),\r\n };\r\n\r\n const drawEye = (ex: number, ey: number, key: string) => {\r\n switch (eyeShape) {\r\n case \"ellipse\":\r\n return <ellipse key={key} cx={ex} cy={ey} rx={eyeR * 1.1} ry={eyeR * 0.7} fill={color} />;\r\n case \"line\":\r\n return <line key={key} x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={eyeR * 0.5} strokeLinecap=\"round\" />;\r\n case \"wink\":\r\n return <line key={key} x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={eyeR * 0.5} strokeLinecap=\"round\" />;\r\n case \"sleepy\":\r\n return <ellipse key={key} cx={ex} cy={ey} rx={eyeR * 1.05} ry={eyeR * 0.45} fill={color} />;\r\n case \"surprised\":\r\n return <circle key={key} cx={ex} cy={ey} r={eyeR * 1.1} fill={color} />;\r\n default:\r\n return <circle key={key} cx={ex} cy={ey} r={eyeR} fill={color} />;\r\n }\r\n };\r\n\r\n const leftEye = drawEye(cx - eyeOffsetX, cy - eyeOffsetY, \"le\");\r\n const rightEye = drawEye(cx + eyeOffsetX, cy - eyeOffsetY, \"re\");\r\n\r\n const pupils = (\r\n <>\r\n <circle cx={cx - eyeOffsetX} cy={cy - eyeOffsetY} r={pupilR} fill={finalPupilColor} />\r\n <circle cx={cx + eyeOffsetX} cy={cy - eyeOffsetY} r={pupilR} fill={finalPupilColor} />\r\n </>\r\n );\r\n\r\n const shine = eyeShine ? (\r\n <>\r\n <circle cx={cx - eyeOffsetX - pupilR * 0.4} cy={cy - eyeOffsetY - pupilR * 0.6} r={pupilR * 0.3} fill=\"#fff\" opacity={0.8} />\r\n <circle cx={cx + eyeOffsetX - pupilR * 0.4} cy={cy - eyeOffsetY - pupilR * 0.6} r={pupilR * 0.3} fill=\"#fff\" opacity={0.8} />\r\n </>\r\n ) : null;\r\n\r\n const mouth = <path d={mouthPaths[mouthShape]} stroke={color} strokeWidth={mouthStroke} fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />;\r\n\r\n return (\r\n <>\r\n {leftEye}\r\n {rightEye}\r\n {pupils}\r\n {shine}\r\n {mouth}\r\n </>\r\n );\r\n}\r\n\r\nexport default function Avatar({ name, size = 120, bg = \"random\", colors = \"random\" }: AvatarProps) {\r\n const rand = rngFromSeed(name);\r\n const [bg1, bg2] = resolveBg(rand, bg);\r\n const [base] = resolveCharColors(rand, colors);\r\n const cx = size / 2;\r\n const cy = size / 2;\r\n\r\n return (\r\n <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} style={{ borderRadius: \"50%\", background: `linear-gradient(135deg, ${bg1}, ${bg2})` }}>\r\n <Face cx={cx} cy={cy} r={size / 3} color={base} rand={rand} />\r\n </svg>\r\n );\r\n}\r\n"],"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AAa,SAAS,KAAK,IAAI,KAAK,aAAa,SAAS,KAAK,GAAG,SAAS,KAAK,MAAK,QAAO,SAAS,KAAK;AAAA,KAC7H,IACE;AAEJ,QAAM,QAAQ,oBAAC,UAAK,GAAG,WAAW,UAAU,GAAG,QAAQ,OAAO,aAAa,aAAa,MAAK,QAAO,eAAc,SAAQ,gBAAe,SAAQ;AAEjJ,SACE,iCACG;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KACH;AAEJ;AAEe,SAAR,OAAwB,EAAE,MAAM,OAAO,KAAK,KAAK,UAAU,SAAS,SAAS,GAAgB;AAClG,QAAM,OAAO,YAAY,IAAI;AAC7B,QAAM,CAAC,KAAK,GAAG,IAAI,UAAU,MAAM,EAAE;AACrC,QAAM,CAAC,IAAI,IAAI,kBAAkB,MAAM,MAAM;AAC7C,QAAM,KAAK,OAAO;AAClB,QAAM,KAAK,OAAO;AAElB,SACE,oBAAC,SAAI,OAAO,MAAM,QAAQ,MAAM,SAAS,OAAO,IAAI,IAAI,IAAI,IAAI,OAAO,EAAE,cAAc,OAAO,YAAY,2BAA2B,GAAG,KAAK,GAAG,IAAI,GAClJ,8BAAC,QAAK,IAAQ,IAAQ,GAAG,OAAO,GAAG,OAAO,MAAM,MAAY,GAC9D;AAEJ;","names":["base","a1","a2"]}
1
+ {"version":3,"sources":["../src/Avatar.tsx"],"sourcesContent":["import * as React from \"react\";\r\nimport palettes100 from \"nice-color-palettes\";\r\n\r\nexport type HeadShape = \"circle\" | \"square\";\r\nexport type Variant =\r\n | \"auto\"\r\n | \"plain\"\r\n | \"split\"\r\n | \"swoop\"\r\n | \"diagonal\"\r\n | \"cap\"\r\n | \"crescent\"\r\n | \"band\"\r\n | \"corner\"\r\n | \"ring\"\r\n | \"arc\"\r\n | \"wave\"\r\n | \"half\";\r\nexport type AlignX = \"left\" | \"center\" | \"right\";\r\nexport type AlignY = \"top\" | \"center\" | \"bottom\";\r\n\r\nexport type FaceProps = {\r\n cx: number;\r\n cy: number;\r\n r: number;\r\n color: string;\r\n eyeShape?: \"circle\" | \"ellipse\" | \"line\" | \"wink\" | \"sleepy\" | \"surprised\" | \"random\";\r\n mouthShape?: \"smile\" | \"frown\" | \"flat\" | \"zigzag\" | \"random\";\r\n pupilColor?: string | \"auto\";\r\n eyeShine?: boolean | \"random\";\r\n rand: () => number;\r\n};\r\n\r\nexport type AvatarProps = {\r\n name: string;\r\n\r\n // pixel background\r\n size?: number;\r\n pixelSize?: number;\r\n mirrored?: boolean;\r\n bg?: [string, string] | string | \"random\";\r\n\r\n // character controls\r\n headShape?: HeadShape;\r\n square?: boolean; // deprecated\r\n alignX?: AlignX;\r\n alignY?: AlignY;\r\n padding?: number;\r\n\r\n colors?: string | [string, string] | [string, string, string] | \"random\";\r\n variant?: Variant;\r\n\r\n // new feature props (optional)\r\n eyeShape?: FaceProps[\"eyeShape\"];\r\n mouthShape?: FaceProps[\"mouthShape\"];\r\n pupilColor?: string | \"auto\";\r\n eyeShine?: boolean;\r\n\r\n // styling/a11y\r\n className?: string;\r\n style?: React.CSSProperties;\r\n title?: string;\r\n};\r\n\r\n//\r\n// Deterministic RNG (seeded)\r\n// (unchanged from original)\r\nfunction cyrb128(str: string) {\r\n let h1 = 1779033703,\r\n h2 = 3144134277,\r\n h3 = 1013904242,\r\n h4 = 2773480762;\r\n for (let i = 0, k; i < str.length; i++) {\r\n k = str.charCodeAt(i);\r\n h1 = h2 ^ Math.imul(h1 ^ k, 597399067);\r\n h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);\r\n h3 = h4 ^ Math.imul(h3 ^ k, 951274213);\r\n h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);\r\n }\r\n h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);\r\n h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);\r\n h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);\r\n h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);\r\n return [(h1 ^ h2 ^ h3 ^ h4) >>> 0, (h2 ^ h1) >>> 0, (h3 ^ h1) >>> 0, (h4 ^ h1) >>> 0];\r\n}\r\nfunction sfc32(a: number, b: number, c: number, d: number) {\r\n return function () {\r\n a >>>= 0;\r\n b >>>= 0;\r\n c >>>= 0;\r\n d >>>= 0;\r\n let t = (a + b) | 0;\r\n a = b ^ (b >>> 9);\r\n b = (c + (c << 3)) | 0;\r\n c = (c << 21) | (c >>> 11);\r\n d = (d + 1) | 0;\r\n t = (t + d) | 0;\r\n c = (c + t) | 0;\r\n return (t >>> 0) / 4294967296;\r\n };\r\n}\r\nfunction rngFromSeed(seed: string) {\r\n const [a, b, c, d] = cyrb128(seed || \"pixelpeeps\");\r\n return sfc32(a, b, c, d);\r\n}\r\nfunction pick<T>(rand: () => number, arr: T[]) {\r\n return arr[Math.floor(rand() * arr.length)];\r\n}\r\n\r\n//\r\n// Color helpers (unchanged)\r\n//\r\nfunction hexToRgb(hex: string) {\r\n const h = hex.replace(\"#\", \"\");\r\n const full = h.length === 3 ? h.split(\"\").map((c) => c + c).join(\"\") : h;\r\n const n = parseInt(full, 16);\r\n return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };\r\n}\r\nfunction rgbToHex(r: number, g: number, b: number) {\r\n return \"#\" + [r, g, b].map((v) => v.toString(16).padStart(2, \"0\")).join(\"\");\r\n}\r\nfunction shade(hex: string, percent: number) {\r\n const { r, g, b } = hexToRgb(hex);\r\n const t = percent < 0 ? 0 : 255;\r\n const p = Math.abs(percent);\r\n return rgbToHex(\r\n Math.round((t - r) * p) + r,\r\n Math.round((t - g) * p) + g,\r\n Math.round((t - b) * p) + b\r\n );\r\n}\r\nfunction yiq(hex: string) {\r\n const { r, g, b } = hexToRgb(hex);\r\n return (r * 299 + g * 587 + b * 114) / 1000;\r\n}\r\nfunction bestFeatureColor(base: string) {\r\n return yiq(base) > 150 ? \"#111827\" : \"#ffffff\";\r\n}\r\n\r\n//\r\n// Palettes: use nice-color-palettes (top 100)\r\n//\r\nconst NICE_PALETTES: string[][] =\r\n palettes100 && Array.isArray(palettes100) ? (palettes100 as string[][]) : [[\"#73a9ff\", \"#fef3c7\", \"#ffd6a5\", \"#d4b4ff\", \"#a7f3d0\"]];\r\n\r\nfunction resolveBg(rand: () => number, bg?: AvatarProps[\"bg\"]): [string, string] {\r\n if (!bg || bg === \"random\") {\r\n return pick(rand, NICE_PALETTES).slice(0, 2) as [string, string];\r\n }\r\n if (Array.isArray(bg)) return [bg[0], bg[1] ?? bg[0]];\r\n return [shade(bg, 0.12), shade(bg, -0.06)];\r\n}\r\nfunction resolveCharColors(rand: () => number, colors?: AvatarProps[\"colors\"]): [string, string, string] {\r\n if (!colors || colors === \"random\") {\r\n const pal = pick(rand, NICE_PALETTES);\r\n const base = pal[0];\r\n const a1 = pal[1] ?? shade(base, 0.25);\r\n const a2 = pal[2] ?? shade(base, -0.2);\r\n return [base, a1, a2];\r\n }\r\n if (typeof colors === \"string\") {\r\n return [colors, shade(colors, 0.25), shade(colors, -0.2)];\r\n }\r\n const base = (colors as string[])[0];\r\n const a1 = (colors as string[])[1] ?? shade(base, 0.25);\r\n const a2 = (colors as string[])[2] ?? shade(base, -0.2);\r\n return [base, a1, a2];\r\n}\r\n\r\n//\r\n// Face component: simplified features\r\n//\r\nfunction Face({\r\n cx,\r\n cy,\r\n r,\r\n color,\r\n eyeShape: eyeShapeProp,\r\n mouthShape: mouthShapeProp,\r\n pupilColor,\r\n eyeShine: eyeShineProp,\r\n rand,\r\n}: FaceProps) {\r\n // 🌿 deterministic pick helpers\r\n const decide = <T,>(prop: T | \"random\" | undefined, opts: T[]) => {\r\n if (prop === undefined || prop === \"random\") return pick(rand, opts as any) as T;\r\n return prop as T;\r\n };\r\n\r\n // pick features deterministically if prop is \"random\"/undefined\r\n const eyeShape = decide(eyeShapeProp ?? \"random\", [\"circle\", \"ellipse\", \"line\", \"wink\", \"sleepy\", \"surprised\"]);\r\n const mouthShape = decide(mouthShapeProp ?? \"random\", [\"smile\", \"frown\", \"flat\", \"zigzag\"]);\r\n const eyeShine = decide(eyeShineProp ?? \"random\", [true, false]);\r\n\r\n // geometry\r\n const eyeOffsetX = r * (0.34 + rand() * 0.06);\r\n const eyeOffsetY = r * (0.20 + rand() * 0.06);\r\n const eyeR = Math.max(2, Math.round(r * (0.08 + rand() * 0.02)));\r\n const pupilR = Math.max(1, Math.round(eyeR * (0.45 + rand() * 0.25)));\r\n const mouthWidth = r * (0.7 + rand() * 0.3);\r\n const mouthLift = r * (0.18 + rand() * 0.16);\r\n const mouthStroke = Math.max(1, Math.round(r * 0.06));\r\n\r\n // pupil color\r\n let finalPupilColor = \"#111827\";\r\n if (pupilColor && pupilColor !== \"auto\") finalPupilColor = pupilColor;\r\n else finalPupilColor = yiq(color) > 150 ? \"#111827\" : \"#ffffff\";\r\n\r\n // helper positions\r\n const x0 = cx - mouthWidth / 2;\r\n const x1 = cx + mouthWidth / 2;\r\n const my = cy + mouthLift;\r\n\r\n // small helpers to draw various mouth shapes\r\n const mouthPathSmile = (() => {\r\n const mouthCurve = (rand() - 0.5) * 0.8;\r\n const cxQ = cx;\r\n const cyQ = my + r * (-0.25 * mouthCurve - 0.1);\r\n return `M ${x0} ${my} Q ${cxQ} ${cyQ} ${x1} ${my}`;\r\n })();\r\n\r\n const mouthPathFrown = (() => {\r\n const mouthCurve = (rand() - 0.5) * 0.8;\r\n const cxQ = cx;\r\n const cyQ = my + r * (0.25 * mouthCurve + 0.08); // control point below -> frown\r\n return `M ${x0} ${my} Q ${cxQ} ${cyQ} ${x1} ${my}`;\r\n })();\r\n\r\n const mouthPathZigzag = (() => {\r\n // create small zigzag across mouth width\r\n const segs = 6;\r\n const step = mouthWidth / (segs - 1);\r\n let d = `M ${x0} ${my}`;\r\n for (let i = 1; i < segs; i++) {\r\n const px = x0 + step * i;\r\n const py = my + (i % 2 === 0 ? -r * 0.08 : r * 0.08);\r\n d += ` L ${px} ${py}`;\r\n }\r\n return d;\r\n })();\r\n\r\n // build JSX pieces\r\n const eyes = (\r\n <>\r\n {/* left eye */}\r\n {(() => {\r\n const ex = cx - eyeOffsetX;\r\n const ey = cy - eyeOffsetY;\r\n\r\n switch (eyeShape) {\r\n case \"ellipse\":\r\n return (\r\n <ellipse cx={ex} cy={ey} rx={eyeR * 1.1} ry={eyeR * 0.7} fill={color} key=\"le\" />\r\n );\r\n case \"line\":\r\n return <line x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={Math.max(1, Math.round(eyeR * 0.4))} strokeLinecap=\"round\" key=\"ll\" />;\r\n case \"wink\":\r\n // wink left = closed (line)\r\n return <line x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={Math.max(1, Math.round(eyeR * 0.4))} strokeLinecap=\"round\" key=\"lw\" />;\r\n case \"sleepy\":\r\n return (\r\n <>\r\n <ellipse cx={ex} cy={ey} rx={eyeR * 1.05} ry={eyeR * 0.45} fill={color} key=\"ls\" />\r\n </>\r\n );\r\n case \"surprised\":\r\n return <circle cx={ex} cy={ey} r={eyeR * 1.1} fill={color} key=\"lsp\" />;\r\n default:\r\n // circle\r\n return <circle cx={ex} cy={ey} r={eyeR} fill={color} key=\"lc\" />;\r\n }\r\n })()}\r\n\r\n {/* left pupil */}\r\n {(() => {\r\n const ex = cx - eyeOffsetX;\r\n const ey = cy - eyeOffsetY;\r\n // if line/wink (closed) skip pupil\r\n if (eyeShape === \"line\" || eyeShape === \"wink\") return null;\r\n if (eyeShape === \"sleepy\") {\r\n // smaller pupil\r\n return <circle cx={ex} cy={ey} r={Math.max(1, pupilR * 0.6)} fill={finalPupilColor} key=\"lps\" />;\r\n }\r\n return (\r\n <>\r\n <circle cx={ex} cy={ey} r={pupilR} fill={finalPupilColor} key=\"lp\" />\r\n {eyeShine ? <circle cx={ex - pupilR * 0.4} cy={ey - pupilR * 0.6} r={Math.max(0.6, pupilR * 0.35)} fill=\"#ffffff\" opacity={0.8} key=\"lshine\" /> : null}\r\n </>\r\n );\r\n })()}\r\n\r\n {/* right eye */}\r\n {(() => {\r\n const ex = cx + eyeOffsetX;\r\n const ey = cy - eyeOffsetY;\r\n\r\n switch (eyeShape) {\r\n case \"ellipse\":\r\n return (\r\n <ellipse cx={ex} cy={ey} rx={eyeR * 1.1} ry={eyeR * 0.7} fill={color} key=\"re\" />\r\n );\r\n case \"line\":\r\n return <line x1={ex - eyeR} y1={ey} x2={ex + eyeR} y2={ey} stroke={color} strokeWidth={Math.max(1, Math.round(eyeR * 0.4))} strokeLinecap=\"round\" key=\"rl\" />;\r\n case \"wink\":\r\n // wink right -> keep open; variety: one eye wink looks cute\r\n return <circle cx={ex} cy={ey} r={eyeR} fill={color} key=\"rw\" />;\r\n case \"sleepy\":\r\n return <ellipse cx={ex} cy={ey} rx={eyeR * 1.05} ry={eyeR * 0.45} fill={color} key=\"rs\" />;\r\n case \"surprised\":\r\n return <circle cx={ex} cy={ey} r={eyeR * 1.1} fill={color} key=\"rsp\" />;\r\n default:\r\n return <circle cx={ex} cy={ey} r={eyeR} fill={color} key=\"rc\" />;\r\n }\r\n })()}\r\n\r\n {/* right pupil */}\r\n {(() => {\r\n const ex = cx + eyeOffsetX;\r\n const ey = cy - eyeOffsetY;\r\n if (eyeShape === \"line\" || (eyeShape === \"wink\" && rand() > 0.2)) {\r\n // sometimes wink will be left eye closed; we've drawn right open earlier; if right is closed skip\r\n if (eyeShape === \"line\") return null;\r\n }\r\n if (eyeShape === \"sleepy\") {\r\n return <circle cx={ex} cy={ey} r={Math.max(1, pupilR * 0.6)} fill={finalPupilColor} key=\"rps\" />;\r\n }\r\n if (eyeShape === \"wink\") {\r\n // keep pupil\r\n return (\r\n <>\r\n <circle cx={ex} cy={ey} r={pupilR} fill={finalPupilColor} key=\"rp\" />\r\n {eyeShine ? <circle cx={ex - pupilR * 0.4} cy={ey - pupilR * 0.6} r={Math.max(0.6, pupilR * 0.35)} fill=\"#ffffff\" opacity={0.8} key=\"rshine\" /> : null}\r\n </>\r\n );\r\n }\r\n return (\r\n <>\r\n <circle cx={ex} cy={ey} r={pupilR} fill={finalPupilColor} key=\"rp\" />\r\n {eyeShine ? <circle cx={ex - pupilR * 0.4} cy={ey - pupilR * 0.6} r={Math.max(0.6, pupilR * 0.35)} fill=\"#ffffff\" opacity={0.8} key=\"rshine2\" /> : null}\r\n </>\r\n );\r\n })()}\r\n </>\r\n );\r\n\r\n // mouth drawing based on mouthShape\r\n const mouth = (() => {\r\n switch (mouthShape) {\r\n case \"frown\":\r\n return <path d={mouthPathFrown} stroke={color} strokeWidth={mouthStroke} fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />;\r\n case \"flat\":\r\n return <line x1={x0} y1={my} x2={x1} y2={my} stroke={color} strokeWidth={Math.max(1, Math.round(mouthStroke * 0.9))} strokeLinecap=\"round\" />;\r\n case \"zigzag\":\r\n return <path d={mouthPathZigzag} stroke={color} strokeWidth={Math.max(1, Math.round(mouthStroke * 0.9))} fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />;\r\n default:\r\n return <path d={mouthPathSmile} stroke={color} strokeWidth={mouthStroke} fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />;\r\n }\r\n })();\r\n\r\n return (\r\n <g>\r\n {eyes}\r\n <g>{mouth}</g>\r\n </g>\r\n );\r\n}\r\n\r\n//\r\n// Overlays (variants) -- unchanged, but kept in file\r\n//\r\nfunction Overlays({\r\n cx,\r\n cy,\r\n r,\r\n a1,\r\n a2,\r\n variant,\r\n shape,\r\n rand,\r\n}: {\r\n cx: number;\r\n cy: number;\r\n r: number;\r\n a1: string;\r\n a2: string;\r\n variant: Exclude<Variant, \"auto\">;\r\n shape: HeadShape;\r\n rand: () => number;\r\n}) {\r\n const x0 = cx - r,\r\n y0 = cy - r,\r\n x1 = cx + r,\r\n y1 = cy + r;\r\n\r\n // deterministic options\r\n const left = rand() > 0.5;\r\n const tlbr = rand() > 0.5;\r\n const horiz = rand() > 0.5;\r\n const cornerTL = rand() > 0.5;\r\n\r\n switch (variant) {\r\n case \"plain\":\r\n return null;\r\n\r\n case \"split\":\r\n return <rect x={left ? x0 : cx} y={y0} width={r} height={2 * r} fill={a1} />;\r\n\r\n case \"diagonal\":\r\n return tlbr ? <polygon points={`${x0},${y0} ${x1},${y0} ${x1},${y1}`} fill={a1} /> : <polygon points={`${x0},${y0} ${x0},${y1} ${x1},${y1}`} fill={a1} />;\r\n\r\n case \"cap\":\r\n return <path d={`M ${x0} ${y0 + r * 0.25} L ${x1} ${y0} L ${x1} ${y0 + r * 0.6} Q ${cx} ${y0 + r * 0.85} ${x0} ${y0 + r * 0.6} Z`} fill={a1} />;\r\n\r\n case \"swoop\":\r\n return <path d={`M ${x0} ${cy - r * 0.55} Q ${cx} ${cy - r * 1.1} ${x1} ${cy - r * 0.35} L ${x1} ${y1} Q ${cx} ${cy + r * 0.95} ${x0} ${y1} Z`} fill={a1} />;\r\n\r\n case \"crescent\":\r\n return (\r\n <>\r\n <circle cx={left ? cx - r * 0.55 : cx + r * 0.55} cy={cy} r={r * 0.95} fill={a2} />\r\n <circle cx={left ? cx - r * 0.52 : cx + r * 0.52} cy={cy} r={r * 0.75} fill=\"transparent\" stroke={shade(a2, -0.25)} strokeWidth={r * 0.08} />\r\n </>\r\n );\r\n\r\n case \"band\":\r\n return horiz ? <rect x={x0} y={cy - r * 0.35} width={2 * r} height={r * 0.5} fill={a1} /> : <rect x={cx - r * 0.35} y={y0} width={r * 0.5} height={2 * r} fill={a1} />;\r\n\r\n case \"corner\":\r\n return cornerTL ? <polygon points={`${x0},${y0} ${x0 + r * 0.9},${y0} ${x0},${y0 + r * 0.9}`} fill={a1} /> : <polygon points={`${x1},${y0} ${x1 - r * 0.9},${y0} ${x1},${y0 + r * 0.9}`} fill={a1} />;\r\n\r\n case \"ring\":\r\n return shape === \"circle\" ? <circle cx={cx} cy={cy} r={r * 0.86} fill=\"none\" stroke={a1} strokeWidth={r * 0.18} /> : <rect x={cx - r * 0.86} y={cy - r * 0.86} width={2 * r * 0.86} height={2 * r * 0.86} rx={r * 0.18} fill=\"none\" stroke={a1} strokeWidth={r * 0.18} />;\r\n\r\n case \"arc\":\r\n return <path d={`M ${x0} ${cy - r * 0.2} A ${r} ${r} 0 0 1 ${x1} ${cy - r * 0.2} L ${x1} ${cy + r * 0.15} A ${r} ${r} 0 0 0 ${x0} ${cy + r * 0.15} Z`} fill={a1} />;\r\n\r\n case \"wave\":\r\n return <path d={`M ${x0} ${cy - r * 0.3} C ${cx - r * 0.6} ${cy - r * 0.8}, ${cx - r * 0.2} ${cy + r * 0.1}, ${cx} ${cy} S ${cx + r * 0.6} ${cy + r * 0.8}, ${x1} ${cy + r * 0.3} L ${x1} ${y1} L ${x0} ${y1} Z`} fill={a1} />;\r\n\r\n case \"half\": {\r\n const diag = rand() > 0.4;\r\n if (diag) {\r\n return <polygon points={`${x0},${y0} ${x1},${y0} ${x1},${cy + (left ? r * 0.1 : -r * 0.1)}`} fill={a1} />;\r\n } else {\r\n const offset = left ? -r * 0.18 : r * 0.18;\r\n return <circle cx={cx + offset} cy={cy} r={r * 0.95} fill={a1} />;\r\n }\r\n }\r\n\r\n default:\r\n return null;\r\n }\r\n}\r\n\r\n//\r\n// Main component (simplified props)\r\n//\r\nexport default function Avatar({\r\n name,\r\n size = 128,\r\n pixelSize = 12,\r\n mirrored = true,\r\n bg,\r\n colors,\r\n headShape,\r\n square,\r\n alignX = \"center\",\r\n alignY = \"center\",\r\n padding,\r\n variant = \"auto\",\r\n className,\r\n style,\r\n title,\r\n\r\n // simplified feature props\r\n eyeShape,\r\n mouthShape,\r\n pupilColor,\r\n eyeShine,\r\n}: AvatarProps) {\r\n const shape: HeadShape = headShape ?? (square ? \"square\" : \"circle\");\r\n const rand = React.useMemo(() => rngFromSeed(String(name)), [name]);\r\n\r\n // colors\r\n const [bg1, bg2] = React.useMemo(() => resolveBg(rand, bg), [rand, bg]);\r\n const [base, a1, a2] = React.useMemo(() => resolveCharColors(rand, colors), [rand, colors]);\r\n const faceColor = bestFeatureColor(base);\r\n\r\n // Pixel grid\r\n const grid = Math.max(6, Math.floor(size / pixelSize));\r\n const tile = Math.ceil(size / grid);\r\n\r\n // geometry\r\n const autoPad = Math.max(4, Math.round(size * (0.06 + rand() * 0.02)));\r\n const pad = padding ?? autoPad;\r\n const baseR = Math.floor(size * (0.36 + rand() * 0.04));\r\n const maxR = Math.floor(size / 2 - pad);\r\n const r = Math.max(8, Math.min(baseR, maxR));\r\n\r\n let cx = size / 2;\r\n let cy = size / 2;\r\n if (alignX === \"left\") cx = r + pad;\r\n if (alignX === \"right\") cx = size - (r + pad);\r\n if (alignY === \"top\") cy = r + pad;\r\n if (alignY === \"bottom\") cy = size - (r + pad);\r\n\r\n // pixel pattern\r\n const cells: React.ReactElement[] = [];\r\n const cols = mirrored ? Math.ceil(grid / 2) : grid;\r\n for (let y = 0; y < grid; y++) {\r\n for (let x = 0; x < cols; x++) {\r\n const use = rand() > 0.5;\r\n const fill = use ? bg1 : bg2;\r\n const px = x * tile;\r\n const py = y * tile;\r\n cells.push(<rect key={`L${x},${y}`} x={px} y={py} width={tile} height={tile} fill={fill} />);\r\n if (mirrored) {\r\n const mx = grid - x - 1;\r\n const mpx = mx * tile;\r\n cells.push(<rect key={`R${mx},${y}`} x={mpx} y={py} width={tile} height={tile} fill={fill} />);\r\n }\r\n }\r\n }\r\n\r\n // variants\r\n const variants: Exclude<Variant, \"auto\">[] = [\"split\", \"swoop\", \"diagonal\", \"cap\", \"crescent\", \"band\", \"corner\", \"ring\", \"arc\", \"wave\", \"plain\", \"half\"];\r\n const chosenVariant: Exclude<Variant, \"auto\"> = variant === \"auto\" ? pick(rand, variants) : (variant as Exclude<Variant, \"auto\">);\r\n\r\n // clip path id\r\n const clipId = React.useMemo(() => {\r\n const [a, b, c, d] = cyrb128(`pp-shape-${name}-${shape}-${r}`);\r\n return `pps-${a.toString(16)}${b.toString(16)}${c.toString(16)}${d.toString(16)}`;\r\n }, [name, shape, r]);\r\n\r\n return (\r\n <svg\r\n width={size}\r\n height={size}\r\n viewBox={`0 0 ${size} ${size}`}\r\n xmlns=\"http://www.w3.org/2000/svg\"\r\n role=\"img\"\r\n aria-label={title ?? `Avatar ${name}`}\r\n className={className}\r\n style={{ display: \"inline-block\", borderRadius: 12, ...style }}\r\n >\r\n {/* background grid */}\r\n <rect width={size} height={size} fill={bg1} />\r\n {cells}\r\n\r\n <defs>\r\n <clipPath id={clipId}>\r\n {shape === \"square\" ? (\r\n <rect x={cx - r} y={cy - r} width={2 * r} height={2 * r} rx={Math.max(4, r * 0.12)} />\r\n ) : (\r\n <circle cx={cx} cy={cy} r={r} />\r\n )}\r\n </clipPath>\r\n </defs>\r\n\r\n {/* head + overlays */}\r\n <g clipPath={`url(#${clipId})`}>\r\n {shape === \"square\" ? (\r\n <rect\r\n x={cx - r}\r\n y={cy - r}\r\n width={2 * r}\r\n height={2 * r}\r\n rx={Math.max(4, r * 0.12)}\r\n fill={base}\r\n />\r\n ) : (\r\n <circle cx={cx} cy={cy} r={r} fill={base} />\r\n )}\r\n\r\n <Overlays cx={cx} cy={cy} r={r} a1={a1} a2={a2} variant={chosenVariant} shape={shape} rand={rand} />\r\n </g>\r\n\r\n {/* facial features: pass randomized or explicit props */}\r\n <Face\r\n cx={cx}\r\n cy={cy}\r\n r={r}\r\n color={faceColor}\r\n eyeShape={eyeShape}\r\n mouthShape={mouthShape}\r\n pupilColor={pupilColor ?? \"auto\"}\r\n eyeShine={eyeShine}\r\n rand={rand}\r\n />\r\n </svg>\r\n );\r\n}"],"mappings":";AAAA,YAAY,WAAW;AACvB,OAAO,iBAAiB;AA2PV,SASA,UATA,KAgCJ,YAhCI;AAzLd,SAAS,QAAQ,KAAa;AAC5B,MAAI,KAAK,YACP,KAAK,YACL,KAAK,YACL,KAAK;AACP,WAAS,IAAI,GAAG,GAAG,IAAI,IAAI,QAAQ,KAAK;AACtC,QAAI,IAAI,WAAW,CAAC;AACpB,SAAK,KAAK,KAAK,KAAK,KAAK,G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","names":["base","a1","a2"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelpeeps",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Deterministic, cute pixel avatars for React. Zero deps. SVG output.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "nice-color-palettes": "^4.0.0",
36
- "pixelpeeps": "^1.0.1"
36
+ "pixelpeeps": "^1.0.2"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/react": "^19.2.2",