Skip to content
Concepts

Concepts

Optional Zdog avatar renderer and portable scene authoring

Sprite Zdog is an optional Canvas renderer for characters built with Zdog. It also provides built-in characters and tools for authoring a portable character document that Sprite can load.

The package root exports the Zdog renderer as the default export. To render a served character document whose renderer is zdog, register it with Sprite. This illustrative configuration uses assetPolicy as the host’s configured Sprite asset policy:

TS
const service = createSprite({
assets: assetPolicy,
renderers: {
zdog: () => import("@fungi.computer/sprite-zdog"),
},
});

assetPolicy stands for the host’s configured Sprite asset policy. Admit the document’s origin and set its byte and request limits. A local character does not need remote asset access.

For authoring, defineSprite validates a trusted scene definition, check returns a compact author-time summary, and toCharacter converts the definition into a JSON character document. The resulting document contains data, not executable authoring code. @fungi.computer/sprite-zdog/builtins exports the base, mushroom, cat, and burger characters.

For stored avatars, import avatarSchema or parseAvatar(data) from @fungi.computer/sprite-zdog/avatar. These validate against the built-in character controls and expressions, rather than checking only the envelope. deriveAgentAvatar(member, agentColors, seed, avoid?) uses that same catalog; agentColors is "keep" or "shift". avatarCatalog is also available from ./catalog for callers using Sprite’s catalog-parameterized helpers. memberAvatarSchema validates the strict {avatar, agentColors} preference; defaultMemberAvatar supplies the uncustomized mushroom with colour shift on.