Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Running scenes

The fastanim CLI runs scripts in six ways.

CommandWhat it does
fastanim preview <script>Opens a window with a timeline, re-baking on save
fastanim render <script>Exports video or frames
fastanim still <script>Exports one frame
fastanim check <script>...Runs scripts without a window and reports their errors
fastanim bundle <script>Writes the scene’s typeset text to a .bundle for the web player
fastanim profile <script> [--runs N]Bakes the scene cold, then N times warm, and prints time spent typesetting, planning animations, copying keyframes and running the script

Preview

fastanim preview scene.rhai
KeyAction
SpacePlay / pause
← / →Step a frame
[ / ]Jump to the previous / next marker
Drag along the timelineScrub
Click a blockJump to its start and box the shapes it affects
Click it again / EscDeselect

The timeline under the scene has a block per play, labelled with the animation’s kind or its .named title, and rows below for updaters and sounds. The web player has the same timeline.

Typeset text is cached, so a re-bake only typesets text that changed.

Render

fastanim render scene.rhai -q 720p30 -o scene.mp4
fastanim render scene.rhai --section intro -o intro.webm
  • -q, --quality: 480p15, 720p30, 1080p60 (default) or 4k60.
  • -o, --output: the extension picks the format: mp4, webm, gif, png or svg. png and svg write one file per frame. mp4 and webm include the scene’s sounds.
  • --section <marker>: render only from that marker to the next one.

Still

fastanim still scene.rhai --at 2.5s -o frame.png
fastanim still scene.rhai --frame 120 -o frame.svg

--at takes seconds (3.5 or 3.5s); --frame takes a frame index at the chosen quality.

Bundle

The web player typesets text slowly. fastanim bundle scene.rhai runs the script without a window and writes scene.bundle beside it, holding the pre-typeset text.

Check

fastanim check scene.rhai
fastanim check scenes/*.rhai --fps 60

Runs each script without a window, then samples its timeline --fps times a second (30 by default, 0 to skip), running every updater and animation closure along the way. A script only tries an updater when it is added and an animation’s closure at its end, so sampling finds closures that fail part way through. Good scripts print path: ok and their duration; errors go to stderr in the format below, and the exit status is non-zero if any script failed, so it suits CI and an editor’s :make. Errors found while sampling are prefixed with the time, as in scene.rhai: at 0.50s: ....

Editors

fastanim lsp is a language server on stdin and stdout. Point your editor’s LSP client for .rhai files at it. It bakes each open script as you type and marks the error, if any, at its line and column. It also completes function and constant names, and the variables, functions and parameters the script declares. Hover shows a function’s signatures or the line declaring a name. Output from a script’s print and debug goes to stderr.

Both setups below expect fastanim on your PATH (see Install).

Neovim

Neovim 0.11 or later. Add to your init.lua:

vim.filetype.add({ extension = { rhai = "rhai" } })
vim.lsp.config("fastanim", {
  cmd = { "fastanim", "lsp" },
  filetypes = { "rhai" },
  root_markers = { ".git" },
})
vim.lsp.enable("fastanim")

Errors show as diagnostics. Completion comes through <C-x><C-o> or your completion plugin. Hover is K. :checkhealth vim.lsp shows whether the server started.

Zed

Zed starts a language server only when an extension declares it, so fastanim ships one in editors/zed. Zed compiles it to WebAssembly itself, which needs Rust installed through rustup.

  1. Install the rhai extension from the extensions page (zed: extensions). It gives Zed the Rhai language that the server attaches to.
  2. Clone the fastanim repository. Run zed: install dev extension and pick its editors/zed directory.
  3. Open a .rhai file. dev: open language server logs shows the server’s output and any error starting it.

Errors

Errors are reported as path:line:col: message, for example:

scene.rhai:3:14: Function not found: point (i64, i64)