Skip to content
API reference

author

Import
import * as api from "@fungi.computer/sprite-zdog/author";
Kind Export Description
type alias SceneNode An opaque node in a renderer-neutral Sprite scene.
type alias Point A point in Sprite scene space.
type alias BezierStep One cubic Bezier path segment.
type alias PathStep One renderer-neutral shape path segment.
type alias Transform Optional translation, rotation, or scale coordinates.
type alias SceneNodeOptions Shared renderer-neutral options for one scene node.
type alias PathOptions Renderer-neutral options for a freeform shape.
type alias EllipseOptions Renderer-neutral options for an ellipse.
type alias HemisphereOptions Renderer-neutral options for a hemisphere.
type alias CylinderOptions Renderer-neutral options for a cylinder.
type alias SceneBuilder The complete renderer-neutral scene authoring surface.
type alias MotionSpec A named motion applied while presenting a Sprite.
type alias StandardActivity The standard presentation activity names accepted by every Sprite.
type alias StateGeometry Variant selections applied to one expression or activity.
type alias MouthCycleStep One timed mouth state in a speaking cycle.
type alias ActivitySpec Presentation behavior associated with an activity.
type alias ExpressionSpec Variant and motion behavior associated with an expression.
type alias BuildResult The root and named variants produced by one author build.
type alias AuthorContext Renderer-neutral capabilities available while authoring a Sprite.
type alias SpriteDefinitionInput Input accepted by the Sprite authoring seam.
type alias SpriteDefinition An authored Sprite definition preserving the author’s input shape.
type alias SpriteCheckResult A compact receipt describing one already-authored Sprite definition.
constant STANDARD_ACTIVITIES The standard presentation activities every Sprite understands.
function defineSprite() Validate and freeze one renderer-neutral Sprite definition.
function check() Return a compact, machine-readable receipt for an already authored definition.

SceneNodetype alias

Section titled “SceneNode”
Signature
type SceneNode = object;

An opaque node in a renderer-neutral Sprite scene.

Signature
readonly [sceneNodeBrand]: true;

Nominal marker that keeps renderer details out of the author surface.


Signature
type Point = object;

A point in Sprite scene space.

Signature
readonly x: number;

Horizontal scene coordinate.

Signature
readonly y: number;

Vertical scene coordinate.

Signature
readonly optional z?: number;

Optional depth coordinate.


BezierSteptype alias

Section titled “BezierStep”
Signature
type BezierStep = object;

One cubic Bezier path segment.

Signature
readonly bezier: readonly [Point, Point, Point];

Two control points followed by the segment endpoint.


Signature
type PathStep = Point | BezierStep;

One renderer-neutral shape path segment.


Transformtype alias

Section titled “Transform”
Signature
type Transform = object;

Optional translation, rotation, or scale coordinates.

Signature
readonly optional x?: number;

Optional horizontal component.

Signature
readonly optional y?: number;

Optional vertical component.

Signature
readonly optional z?: number;

Optional depth component.


SceneNodeOptionstype alias

Section titled “SceneNodeOptions”
Signature
type SceneNodeOptions = object;

Shared renderer-neutral options for one scene node.

Signature
readonly optional name?: string;

Definition-local name used by authored references.

Signature
readonly optional parent?: SceneNode;

Parent node in the same definition.

Signature
readonly optional x?: number;

Horizontal translation that takes precedence over translate.x.

Signature
readonly optional y?: number;

Vertical translation that takes precedence over translate.y.

Signature
readonly optional z?: number;

Depth translation that takes precedence over translate.z.

Signature
readonly optional translate?: Transform;

Translation components not supplied by the direct coordinates.

Signature
readonly optional rotate?: Transform;

Rotation around each scene axis, in radians.

Signature
readonly optional scale?: Transform;

Scale applied along each scene axis.

Signature
readonly optional visible?: boolean;

Whether the node participates in rendering.

Signature
readonly optional color?: string;

Literal paint or an opaque reference returned by color.

Signature
readonly optional stroke?: number | false;

A false stroke keeps a solid primitive edge-free, as in Zdog fills.

Signature
readonly optional fill?: boolean;
Signature
readonly optional backface?: string;

Optional rear/forward surface palette slots for 3D solids.

Signature
readonly optional frontFace?: string;

Paint used for a primitive’s front face when supported.

Signature
readonly optional updateSort?: boolean;

Whether supported primitives update child depth ordering.


PathOptionstype alias

Section titled “PathOptions”
Signature
type PathOptions = object & SceneNodeOptions;

Renderer-neutral options for a freeform shape.

Name Type Description
path? readonly PathStep[] Ordered points and cubic Bezier segments in the path.
closed? boolean Whether the renderer closes the path.

EllipseOptionstype alias

Section titled “EllipseOptions”
Signature
type EllipseOptions = object & SceneNodeOptions;

Renderer-neutral options for an ellipse.

Name Type Description
width number Horizontal diameter.
height number Vertical diameter.

HemisphereOptionstype alias

Section titled “HemisphereOptions”
Signature
type HemisphereOptions = object & SceneNodeOptions;

Renderer-neutral options for a hemisphere.

Name Type Description
diameter number Diameter of the hemisphere’s base.

CylinderOptionstype alias

Section titled “CylinderOptions”
Signature
type CylinderOptions = object & SceneNodeOptions;

Renderer-neutral options for a cylinder.

Name Type Description
diameter number Diameter of the cylinder’s circular faces.
length number Distance between the cylinder’s faces.

SceneBuildertype alias

Section titled “SceneBuilder”
Signature
type SceneBuilder = object;

The complete renderer-neutral scene authoring surface.

Signature
group(options?): SceneNode;

Create a grouping node.

Parameter Type
options? SceneNodeOptions

SceneNode

Signature
path(options): SceneNode;

Create a freeform path node.

Parameter Type
options PathOptions

SceneNode

Signature
ellipse(options): SceneNode;

Create an ellipse node.

Parameter Type
options EllipseOptions

SceneNode

Signature
hemisphere(options): SceneNode;

Create a hemisphere node.

Parameter Type
options HemisphereOptions

SceneNode

Signature
cylinder(options): SceneNode;

Create a cylinder node.

Parameter Type
options CylinderOptions

SceneNode


MotionSpectype alias

Section titled “MotionSpec”
Signature
type MotionSpec = object;

A named motion applied while presenting a Sprite.

Signature
readonly target: string;

Name of the scene node targeted by the motion.

Signature
readonly optional translate?: Transform;

Authored translation change.

Signature
readonly optional rotate?: Transform;

Authored rotation change.

Signature
readonly optional durationMs?: number;

Duration of one motion pass in milliseconds.

Signature
readonly optional repeat?: "none" | "loop" | "yoyo";

Repetition mode for the motion.


StandardActivitytype alias

Section titled “StandardActivity”
Signature
type StandardActivity =
"idle" | "listening" | "processing" | "speaking" | "thinking" | "error";

The standard presentation activity names accepted by every Sprite.


StateGeometrytype alias

Section titled “StateGeometry”
Signature
type StateGeometry = object;

Variant selections applied to one expression or activity.

Signature
readonly optional expression?: string;

Expression selected by an activity.

Signature
readonly optional eyes?: string;

Value selected from the eyes variant channel.

Signature
readonly optional mouth?: string;

Value selected from the mouth variant channel.

Signature
readonly optional blush?: number;

Normalized blush intensity.


MouthCycleSteptype alias

Section titled “MouthCycleStep”
Signature
type MouthCycleStep = object;

One timed mouth state in a speaking cycle.

Signature
readonly durationMs: number;

Time spent in this mouth state, in milliseconds.

Signature
readonly mouth: "base" | "open";

Mouth state shown during the step.


ActivitySpectype alias

Section titled “ActivitySpec”
Signature
type ActivitySpec = object;

Presentation behavior associated with an activity.

Signature
readonly optional motion?: MotionSpec;

Optional motion authored for the activity.

Signature
readonly optional geometry?: StateGeometry;

Optional geometry selections authored for the activity.

Signature
readonly optional mouseInfluence?: number;

Authored pointer-influence strength.

Signature
readonly optional mouthCycle?: readonly MouthCycleStep[];

Ordered timed mouth states for the activity.


ExpressionSpectype alias

Section titled “ExpressionSpec”
Signature
type ExpressionSpec = object;

Variant and motion behavior associated with an expression.

Signature
readonly optional variants?: Record<string, string>;

Fixed value selected for each variant channel.

Signature
readonly optional variantChoices?: Record<string, readonly string[]>;

Candidate values authored for each variant channel.

Signature
readonly optional blush?: number;

Normalized blush intensity.

Signature
readonly optional motion?: MotionSpec;

Optional motion authored for the expression.


BuildResulttype alias

Section titled “BuildResult”
Signature
type BuildResult = object;

The root and named variants produced by one author build.

Signature
readonly root: SceneNode;

Root node of the rendered scene tree.

Signature
readonly optional variants?: Record<string, Record<string, SceneNode>>;

Definition-local nodes grouped by variant channel and value.


AuthorContexttype alias

Section titled “AuthorContext”
Signature
type AuthorContext = object;

Renderer-neutral capabilities available while authoring a Sprite.

Signature
readonly scene: SceneBuilder;

Scene builder valid only for the duration of build.

Signature
readonly color: (name) => string;

Create an opaque reference to an own palette slot.

Parameter Type
name string

string


SpriteDefinitionInputtype alias

Section titled “SpriteDefinitionInput”
Signature
type SpriteDefinitionInput = object;

Input accepted by the Sprite authoring seam.

Signature
readonly apiVersion: 1;

Version of the authoring contract used by this definition.

Signature
readonly name: string;

Human-readable Sprite definition name.

Signature
readonly palette: Record<string, string>;

Named default paints available to the author callback.

Signature
readonly build: (context) => BuildResult;

Construct the renderer-neutral scene and its named variants.

Parameter Type
context AuthorContext

BuildResult

Signature
readonly expressions: Record<string, ExpressionSpec>;

Named expression specifications; at least one is required.

Signature
readonly optional activities?: Record<string, ActivitySpec>;

Optional custom activity specifications.

Signature
readonly optional defaultPresentation?: object;

Initial activity and expression selected when mounted.

Signature
readonly optional activity?: string;

Standard or custom activity selected initially.

Signature
readonly optional expression?: string;

Declared expression selected initially.


SpriteDefinitiontype alias

Section titled “SpriteDefinition”
Signature
type SpriteDefinition<Input> = Readonly<Input>;

An authored Sprite definition preserving the author’s input shape.

Type Parameter Default type
Input extends SpriteDefinitionInput SpriteDefinitionInput

SpriteCheckResulttype alias

Section titled “SpriteCheckResult”
Signature
type SpriteCheckResult = object;

A compact receipt describing one already-authored Sprite definition.

Signature
readonly valid: true;

Whether the definition has completed author-time validation.

Signature
readonly name: string;

Human-readable name of the checked definition.

Signature
readonly nodeCount: number;

Number of scene nodes reachable from the definition root.

Signature
readonly expressions: readonly string[];

Expression names in author insertion order.

Signature
readonly activities: readonly string[];

Standard activities followed by unique custom activities in author order.

Signature
readonly variants: Readonly<Record<string, readonly string[]>>;

Variant values by channel, preserving author insertion order.

STANDARD_ACTIVITIESconstant

Section titled “STANDARD_ACTIVITIES”
Signature
const STANDARD_ACTIVITIES: readonly [
"idle",
"listening",
"processing",
"speaking",
"thinking",
"error",
];

The standard presentation activities every Sprite understands.

defineSprite()function

Section titled “defineSprite()”
Signature
function defineSprite<Input>(input): SpriteDefinition<Input>;

Validate and freeze one renderer-neutral Sprite definition.

Type Parameter
Input extends SpriteDefinitionInput
Parameter Type
input Input

SpriteDefinition<Input>


Signature
function check(definition): SpriteCheckResult;

Return a compact, machine-readable receipt for an already authored definition.

Parameter Type
definition SpriteDefinition

SpriteCheckResult

Re-exports toCharacter