Skip to content

Sprite

A ::sprite shows one pose of a character: a row of its sprite sheet, played frame by frame. The sheet comes from the character's bible (::sheet{src layout}, see the scenario docs), so a story names the character and the pose, never a file. In v1 it plays in the motion format (a film shot) and in the webstory format (a card, a still).

Syntax

Markdowncharacter.story.md
--- title: Lorem in Nine Poses format: webstory cast: ./cast.md --- --- id=hello ::sprite{character=lorem pose=waving alt="Lorem waves"} Dolor sit amet.

In a film, --- type=sprite cast=lorem pose=waving is the same shot written with the scene attributes of the bible. A scene that holds one ::sprite is a sprite, without type=; the paragraph under it is its caption.

AttributeRole
characterid of a character of the bible named by cast:, which has a sheet
posea row of the layout (default idle)
looploop or once; default, the playback of the row
framea fixed frame of the pose, from 0 (a still)
altwhat the image shows, read by screen readers; a warning when missing, an error with recit validate --strict
srcthe sheet itself, instead of character (a path or a URL)
layoutthe layout of src (default codex-pet-v1)

The layout

codex-pet-v1 is the sheet of the hatch-pet skill: 1536×1872 pixels, cells of 192×208, eight columns on nine rows, one pose per row.

PoseFramesPlayback
idle6loop
running-right8loop
running-left8loop
waving4once
jumping5once
failed8once
waiting6loop
running6loop
review6loop

A pose missing from the layout, a character without a sheet and a story without cast: are errors with their line. A film stays on screen for two plays of a looping pose and one play of a once pose (the last frame is then held).

Rendering

The frame is a pure function of the time: the cumulative durations of the row give the frame, and an SVG shows its cell through its view box over the whole sheet. No decoding and no canvas, so the web player, the MP4 and a PNG show the same image. Under prefers-reduced-motion, and in a story card or a PNG, the sprite is frame 0 of its pose. The sheet is scaled smoothly: a sheet is a rendered picture, not pixel art.

recit inlines the sheet of the bible as a data: URI, so a film or a card needs no file to serve. For a synthetic sheet to try things with, recit pixel sheet draws one from a seed; examples/webstory-character is a Lorem character in its nine poses.

ReactReact
import { SpriteImage } from "@recit/components"; <SpriteImage src="/lorem.sheet.png" pose="waving" frame={0} alt="Lorem waves" width={192} />;
Last modified on