@blobz/avatar-core

中文文档
0.1.2发布于 2026/10/26MITTypeScriptES Module零依赖近 30 天下载 1932

Deterministic, framework-free SVG blob avatars.

原始使用文档

@blobz/avatar-core

The framework-free, deterministic SVG engine behind Blobz. The same normalized name and palette always produce the same avatar in Node.js, Bun, and the browser.

Usage

import { createAvatar } from "@blobz/avatar-core";

const avatar = createAvatar({
  name: "Janaki",
  palette: ["#f2f1f4", "#7c6cf2"],
  frame: "rounded",
});

avatar.svg; // Complete 80×80 accessible SVG markup
avatar.choices; // Numeric choices that can be saved or edited
avatar.features; // Human-readable choices for a UI

For compatibility with the original index.html generator, makeAvatar keeps the same positional API:

import { makeAvatar } from "@blobz/avatar-core";

const avatar = makeAvatar(
  "Janaki",
  ["#f2f1f4", "#7c6cf2"],
  "circle"
);

Build a face manually

createCustomAvatar renders semantic choices directly. It does not use a name or a name-derived hash to select missing features, and it validates every choice at runtime.

import { createCustomAvatar } from "@blobz/avatar-core";

const avatar = createCustomAvatar({
  palette: ["#ffffff", "#12b76a"],
  frame: "circle",
  choices: {
    shape: "leaf",
    eyes: "distorted",
    look: "centre",
    eyeSpacing: "medium",
    mouth: "wide smile",
    brows: "quizzical",
    mirrored: false,
    faceAngle: 2,
    bodyTilt: -4,
    facePosition: { x: 1, y: 0 },
  },
});

toCustomAvatarChoices converts a generated result into the semantic format, which lets an editor use a generated face as its custom starting point. The legacy choices option on createAvatar remains available for partial numeric overrides.

The current feature space contains 5,159,700,000 combinations before palette variation. It includes 21 silhouettes, 14 eye styles, 13 mouths, eight brow styles, and 25 face angles. Bodies use a soft gradient and rim lighting with highlights fitted to each silhouette.

The Faceprint v2 update adds uwu and angry mouths and removes the tilted brow style. The generator draw order stays stable, but the updated option counts change the generated mouth and brows for some names. Saved numeric brow index 7 now selects unibrow; index 8 is no longer valid. Semantic custom choices continue to use their named styles, except for the removed tilted option.

版本与发布记录

@blobz/avatar-core 共发布 4 个版本,首次发布于 2026/10/12;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.1.2latest2026/10/2613 天前
0.1.12026/10/1326 天前
0.1.02026/10/1227 天前
0.0.0-stage2026/10/1227 天前

关于 @blobz/avatar-core 的常见问题

@blobz/avatar-core 是什么?

Deterministic, framework-free SVG blob avatars.

如何安装 @blobz/avatar-core?

在项目目录运行 npm install @blobz/avatar-core,或使用 pnpm add / yarn add / bun add。

@blobz/avatar-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blobz/avatar-core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@blobz/avatar-core 可以商用吗?

@blobz/avatar-core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@blobz/avatar-core 的下载量有多少?

根据 npm 官方下载统计,@blobz/avatar-core 在 2026/10/09 – 2026/11/07 这 30 天内被下载 1,932 次,日均约 64 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@blobz/avatar-core 还在维护吗?

最新版本 0.1.2 发布于 2026/10/26(13 天前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/10/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。