Avatar generates a random avatar from a seed string. It is guaranteed to always generate the same avatar for the same seed, which makes it ideal for generating avatars based on usernames or ids.
import { generatePng, generateSvg } from "https://deno.land/x/avatar/mod.ts";
// Generate an SVG avatar with the default options.
let avatar = await generateSvg("jimbob");
// Generate an avatar with a custom size.
avatar = await generateSvg("marysue", { size: 128 });
// Generate an avatar with rounded corners...
avatar = await generateSvg("billybob", { radius: 10 });
// Or a full circle.
avatar = await generateSvg("libbymae", { radius: 100, size: 64 });
// Generate a PNG avatar.
avatar = await generatePng("cleetus", { radius: 20, size: 256 });
Avatar is open source software, released under the MIT license.
The avatars are generated using elements from the splendid Miniavs avatar builder, by Webpixels.