Expand description
Procedural, asset-free avatar generation driven by stable identity hashes.
The crate produces deterministic avatar images from an input identifier without shipping image packs, sprites, or third-party artwork. All visual output is drawn from code using geometric primitives.
Typical usage:
use hashavatar::prelude::*;
let bytes = AvatarBuilder::for_id("robot@hashavatar.app")
.size(256, 256)
.kind(AvatarKind::Robot)
.background(AvatarBackground::Transparent)
.encode(AvatarOutputFormat::WebP)?;Modules§
- prelude
- Common imports for application code using the high-level avatar APIs.
Structs§
- Avatar
Builder - Fluent high-level API for common avatar rendering paths.
- Avatar
Identity - A stable avatar identity derived from a fixed 64-byte digest.
- Avatar
Identity Error - Avatar
Identity Options - Options for deriving a stable avatar identity.
- Avatar
Namespace - Avatar
Options - Avatar
Render Resource Budget - Resource budget estimate for raster rendering.
- Avatar
Spec - Input parameters for a generated avatar image.
- Avatar
Spec Error - Avatar
Style Options - Full avatar style selection including the baseline kind/background and optional visual layers.
- CatAvatar
- Cat-face avatar renderer built from simple geometric primitives.
- Color
- RGBA color helper for concise shape drawing.
- Hashed
CatAvatar - Cat-face avatar renderer driven by a stable identity digest.
- Hashed
DogAvatar - Hashed
Robot Avatar
Enums§
- Avatar
Accessory - Optional avatar accessory layer.
- Avatar
Background - Canvas background mode for raster and SVG avatar output.
- Avatar
Color - Optional avatar accent color palette.
- Avatar
Error - Unified error type for high-level avatar APIs.
- Avatar
Expression - Optional avatar expression layer.
- Avatar
Identity Component - Avatar
Kind - Avatar family selection.
- Avatar
Output Format - Export formats for encoded avatar assets.
- Avatar
Render Error - Avatar
Shape - Optional frame shape for the generated avatar.
Constants§
- AVATAR_
RGBA_ BYTES_ PER_ PIXEL - Number of bytes in one RGBA8 raster pixel.
- AVATAR_
STYLE_ ACCESSORY_ BYTE - Identity digest byte used for automatic accessory selection.
- AVATAR_
STYLE_ BACKGROUND_ BYTE - Identity digest byte used for automatic background selection.
- AVATAR_
STYLE_ COLOR_ BYTE - Identity digest byte used for automatic color-palette selection.
- AVATAR_
STYLE_ EXPRESSION_ BYTE - Identity digest byte used for automatic expression selection.
- AVATAR_
STYLE_ KIND_ BYTE - Identity digest byte used for automatic avatar family selection.
- AVATAR_
STYLE_ SHAPE_ BYTE - Identity digest byte used for automatic frame-shape selection.
- AVATAR_
STYLE_ VERSION - Rendering contract version for deterministic avatars.
- MAX_
AVATAR_ DIMENSION - Largest supported raster or SVG dimension.
- MAX_
AVATAR_ ID_ BYTES - Largest supported identity input in bytes.
- MAX_
AVATAR_ NAMESPACE_ COMPONENT_ BYTES - Largest supported namespace component in bytes.
- MAX_
AVATAR_ PIXELS - Largest supported raster pixel count.
- MAX_
AVATAR_ RGBA_ BYTES - Largest supported raw RGBA8 image buffer size before encoder overhead.
- MIN_
AVATAR_ DIMENSION - Smallest supported raster or SVG dimension.
Traits§
- Avatar
Renderer - Trait for renderers that can draw reusable avatar styles onto an image buffer.
Functions§
- encode_
avatar - Render and encode an avatar into memory.
- encode_
avatar_ auto_ for_ id - encode_
avatar_ auto_ for_ namespace - encode_
avatar_ auto_ with_ identity_ options - encode_
avatar_ for_ id - encode_
avatar_ for_ namespace - encode_
avatar_ style_ for_ id - encode_
avatar_ style_ for_ namespace - encode_
avatar_ style_ with_ identity_ options - encode_
avatar_ with_ identity_ options - encode_
cat_ avatar - Render and encode a cat avatar into memory.
- encode_
cat_ avatar_ for_ id - Render and encode a cat avatar for a stable identity string.
- render_
alien_ avatar_ for_ identity - render_
astronaut_ avatar_ for_ identity - render_
avatar_ auto_ for_ id - Render an avatar image with all public style choices derived from distinct identity digest bytes.
- render_
avatar_ auto_ for_ namespace - render_
avatar_ auto_ with_ identity_ options - render_
avatar_ for_ id - Render an avatar image directly without encoding it.
- render_
avatar_ for_ namespace - render_
avatar_ style_ for_ id - Render an avatar image with explicit visual layer style options.
- render_
avatar_ style_ for_ namespace - render_
avatar_ style_ with_ identity_ options - render_
avatar_ svg_ auto_ for_ id - Render an avatar SVG with all public style choices derived from distinct identity digest bytes.
- render_
avatar_ svg_ auto_ for_ namespace - render_
avatar_ svg_ auto_ with_ identity_ options - render_
avatar_ svg_ for_ id - Render an avatar as a compact SVG string.
- render_
avatar_ svg_ for_ namespace - render_
avatar_ svg_ style_ for_ id - Render an avatar with explicit visual layer style options as a compact SVG string.
- render_
avatar_ svg_ style_ for_ namespace - render_
avatar_ svg_ style_ with_ identity_ options - render_
avatar_ svg_ with_ identity_ options - render_
avatar_ with_ identity_ options - render_
bear_ avatar_ for_ identity - render_
bird_ avatar_ for_ identity - render_
cactus_ avatar_ for_ identity - Render a cactus avatar from a stable identity.
- render_
cat_ avatar - Render a cat face avatar into an RGBA image.
- render_
cat_ avatar_ for_ identity - Render a cat face avatar from a stable identity digest.
- render_
cat_ avatar_ for_ identity_ with_ background - render_
coffee_ cup_ avatar_ for_ identity - render_
cupcake_ avatar_ for_ identity - Render a cupcake avatar from a stable identity.
- render_
diamond_ avatar_ for_ identity - render_
dog_ avatar_ for_ identity - render_
dragon_ avatar_ for_ identity - render_
fox_ avatar_ for_ identity - render_
frog_ avatar_ for_ identity - Render a frog avatar from a stable identity.
- render_
ghost_ avatar_ for_ identity - render_
icecream_ avatar_ for_ identity - Render an ice cream cone avatar from a stable identity.
- render_
knight_ avatar_ for_ identity - Render a knight helmet avatar from a stable identity.
- render_
monster_ avatar_ for_ identity - render_
mushroom_ avatar_ for_ identity - Render a mushroom avatar from a stable identity.
- render_
ninja_ avatar_ for_ identity - render_
octopus_ avatar_ for_ identity - Render an octopus avatar from a stable identity.
- render_
panda_ avatar_ for_ identity - Render a panda avatar from a stable identity.
- render_
paws_ avatar_ for_ identity - render_
penguin_ avatar_ for_ identity - render_
pizza_ avatar_ for_ identity - Render a pizza-slice avatar from a stable identity.
- render_
planet_ avatar_ for_ identity - Render a ringed planet avatar from a stable identity.
- render_
robot_ avatar_ for_ identity - render_
rocket_ avatar_ for_ identity - Render a rocket avatar from a stable identity.
- render_
shield_ avatar_ for_ identity - render_
skull_ avatar_ for_ identity - render_
slime_ avatar_ for_ identity - render_
wizard_ avatar_ for_ identity