Dopesheets

dopesheet plays a range of frames from a sprite sheet at a set fps. Like tilemap it's a placeable SVG block — a legal child of any diagram or container — and like other animated blocks it's special-cased in Rust because the geometry comes from cropping an external image. The sheet is referenced by URL, so frames resolve when the site is served, not when the page is opened directly from disk.

A looping animation

Name the sheet (an @inline(0) source, like image), describe its frame grid, and pick an fps. Here the whole sheet — six 12×12 frames — plays at 12 fps, looped (both defaults). scale enlarges the tiny pixel art, and columns defaults to as many frames as fit across the sheet (72 / 12 = 6).

diagram { width = 96  height = 96
  dopesheet "assets/pixel-coin.png" {
    frame_width  = 12
    frame_height = 12
    scale        = 6.0
    fps          = 12.0
    x            = 12.0
    y            = 12.0
  }
}

Autoplay and loop are on by default — click the coin to pause or resume. The centred play glyph appears whenever it's stopped.

Frame range + speed

from / to pick an inclusive sub-range, and autoplay = false leaves the animation stopped until clicked. offset_x / offset_y and stride_x / stride_y are spelled out below to show how a sheet with padding or gaps is sliced — for this flush-packed strip they're just the defaults.

diagram { width = 96  height = 96
  dopesheet "assets/pixel-coin.png" {
    frame_width  = 12
    frame_height = 12
    stride_x     = 12
    stride_y     = 12
    columns      = 6
    from         = 0
    to           = 2
    fps          = 6.0
    autoplay     = false
    scale        = 6.0
    x            = 12.0
    y            = 12.0
  }
}

Frame geometry

PropertyTypeRequiredDescription
sourceutf8yesSpritesheet image path (the inline label), relative to the build entry file.
frame_widthi64yesSize of one frame in the sheet (pixel width).
frame_heighti64yesSize of one frame in the sheet (pixel height).
offset_xi64noPixel offset to the first frame's left edge (default 0).
offset_yi64noPixel offset to the first frame's top edge (default 0).
stride_xi64noOrigin-to-origin x step between frames (default = frame_width).
stride_yi64noOrigin-to-origin y step between frames (default = frame_height).
columnsi64noFrames per sheet row (default: fit from the sheet width).
fromi64noFirst frame index to play (default 0).
toi64noLast frame index to play, inclusive (default: the last frame).
fpsf64noPlayback rate in frames/second (default 12).
loopboolnoRestart at the end (default true).
autoplayboolnoStart playing on load (default true).
controlsboolnoClick play/pause toggle (default true).
smoothboolnoAnti-alias instead of the default image-rendering: pixelated.
scalef64noDisplay scale (default 1.0).
xf64noPosition x within the enclosing diagram / container.
yf64noPosition y within the enclosing diagram / container.
ididentifiernoOptional explicit HTML id.
classlist<utf8>noOptional style classes.
anchor_leftf64noDiagram anchor insets (left/right/top/bottom), like any SvgBlock.
connect_pointslist<AnchorSide>noDiagram edge-attach sides, like any SvgBlock.

Playback

By default, dopesheets are autoplay, loop, and controls = true. Click the centred play / pause glyph to toggle. With loop = false, playback stops at the last frame and the glyph flips to a replay arrow.

Smooth or pixelated

image-rendering: pixelated is the default, so retro pixel art stays crisp. Set smooth = true on the dopesheet to opt into the browser's smoothing for non-pixel sources.

Asset credit

The sample sheet is truezipp's "Pixel Coins Asset", released under CC0 (public domain). Get it at opengameart.org.