JGuang

Dylan 角色

Dylan · DiceBear

交互预览
npm install @dicebear/core@9.4.2 @dicebear/collection@9.4.2

Dylan 角色 · Dylan

带情绪表情、发型和胡须的俏皮角色。

安装

npm install @dicebear/core@9.4.2 @dicebear/collection@9.4.2

生成头像

同一个种子(seed)总是生成同一个头像,适合用用户 ID 或用户名作为种子。头像在本地生成,不需要请求网络服务。

import { createAvatar } from '@dicebear/core';
import { dylan } from '@dicebear/collection';

// “Dylan! The Avatar Generator” by Natalia Spivak, CC BY 4.0 — credit the author where the avatar is used.
const avatar = createAvatar(dylan, {
  seed: 'Aria Chen',
  size: 128,
  radius: 50,
});

export const svg = avatar.toString();     // inline SVG markup
export const dataUri = avatar.toDataUri(); // use as an <img> src

React 组件:

import { useMemo } from 'react';
import { createAvatar } from '@dicebear/core';
import { dylan } from '@dicebear/collection';

export function UserAvatar({ seed, size = 64 }: { seed: string; size?: number }) {
  const src = useMemo(() => createAvatar(dylan, { seed, size }).toDataUri(), [seed, size]);
  return <img src={src} width={size} height={size} alt={`Avatar for ${seed}`} />;
}

选项

通用选项: seed, size, radius, backgroundColor, flip, rotate, scale.

此风格专有选项: facialHair, facialHairProbability, hair, hairColor, mood, skinColor.

完整选项说明见 https://www.dicebear.com/styles/dylan/

许可与署名