A programmatic mathematical-animation engine in Rust, built on Bevy, inspired by manim.
Its distinguishing feature: transforms between equations, text, code and groups of shapes are planned with Myers' diff, so unchanged parts stay put or slide, moved parts travel, and only real changes fade or morph.
pip install fastanimfastanim on PyPI has wheels for Linux (x86_64), macOS
(Apple Silicon) and Windows (x86_64), for CPython 3.10+ and free-threaded 3.14t. Video export also needs ffmpeg on your PATH. Or try it with no install in the
browser playground, which runs Python scenes on
Pyodide.
Scenes are written in Python (or in Rust, or as Rhai scripts, with the same API):
from fastanim import *
@scene
def parity(s: Scene) -> None:
title = s.add(text("Classic manim parity").to_edge(UP))
s.play(write(title))
ring = s.add(circle(1.5, stroke=BLUE, stroke_width=0.06))
s.play(create(ring), run_time=1.5)
formula = s.add(math_tex("y = sin(x)").scale(1.5).fill(GREEN).to_edge(DOWN))
s.play(write(formula))python -m fastanim preview fastanim-py/scenes/parity.py # reloads on save
python -m fastanim render fastanim-py/scenes/parity.py -q 720p30 -o parity.mp4
python -m fastanim still fastanim-py/scenes/parity.py --at 3s -o frame.svgThe scripting docs cover the Python API
(source in docs/book, just docs to serve locally).
What's planned next for manim parity is in docs/ROADMAP.md.
- Diff engine: Myers (greedy and linear-space) and patience diff, with move detection, replace pairing and semantic cleanup.
- Core model: cubic-Bézier paths and shapes, path alignment, Oklab colors, a
Scenebuilder baked into a seekableBakedTimeline, and SVG export of stills or whole animations. - Animations:
create,write,fade_in/fade_out(optionally shifting or scaling),transform,replacement_transform,grow_from_center,spin_in,draw_border_then_fill,uncreate,unwrite,shrink_to_center,move_to,apply_function,indicate,wiggle,circumscribe,flash; composed withParallel,Sequenceandlagged_start; eased with quad, cubic, expo, back and spring rate functions. - Styles: solid or linear-gradient fills and outlines with separate opacities,
set_color_by_gradientacross groups and texts, dashed outlines anddashed_line, line caps and joins, and a scene background colour. - Shader fills:
shader(wgsl)paints a shape's fill with a WGSL fragment shader (fn shade(uv: vec2<f32>) -> vec4<f32>, readingshape.color,shape.sizeandshape.time) on the GPU in preview and export; SVG and the web player draw the solid fill. - Layout:
next_to,align_to,to_edge,arrange,scale_to_fit_height/width. - Graphs: manim-style
axes(with arrow tips and labels) andfit_axes, which picks the y range;plotgraphs a function,c2pmaps graph to scene coordinates. - Text & math: Typst (bundled fonts, no LaTeX) laid out into
per-glyph shapes and diffable tokens via
text,math_texandcode.latextakes LaTeX math instead, converted to Typst by MiTeX.load_fontadds TTF/OTF fonts from files, chosen per text with afontoption. - Images: PNG and JPEG files, or pixel arrays (NumPy or nested lists), as shapes that move, scale, rotate, fade and group like any other; smooth or pixelated.
- Video: any file
ffmpegreads, as an image shape whose framesplay_videoplays, with its sound, while it moves, rotates and distorts like any other shape. - Lottie: Lottie (Bodymovin JSON) files evaluated frame by frame into shapes, so they
render everywhere and move, fade and group like any other mobject;
play_lottieplays all or part of one, looped or backwards. TransformDiff: token diffs choreographed into slides, arcing moves, morphs and fades, withDiffStylephasing, highlights and a debug tint. Code diffs line by line, then token by token;listcells swap with two arcing moves.- Preview:
FastanimPluginrenders with Vello, with a scene clock and scrubber (Space play/pause, ←/→ step,[/]markers, drag the bar). - Export: headless rendering piped to ffmpeg as MP4, WebM or GIF, or PNG/SVG frames, with
quality presets,
--sectionand stills. Frames are evaluated in parallel across cores. - Sound: WAV clips played whole or in part, as animations that
playwaits for or in the background withadd_sound; heard in the preview and mixed into MP4 and WebM exports. - Python: the
fastanimpackage (built with maturin) records@scenefunctions and bakes them to the same timelines as Rust and Rhai.python -m fastanim previewre-runs a scene on save;renderandstillexport it. Typeset text is memoized, so a re-run only typesets what changed. - Rhai, locally: the
fastanimCLI plays Rhai scripts withpreview,renderandstill;fastanim profileshows where bake time goes,fastanim script-apilists every script function, andfastanim lspgives editors errors, completion and hover. - Browser playground:
fastanim-webruns Python scenes on Pyodide in a Web Worker and draws them onto a Canvas 2D.
| Crate | Purpose |
|---|---|
fastanim |
Facade crate and prelude |
fastanim-diff |
Generic sequence diffing |
fastanim-core |
Geometry, mobjects, animations and timeline |
fastanim-text |
Text, math and code layout into diffable tokens |
fastanim-bevy |
Bevy plugin: rendering, preview and export |
fastanim-script |
Rhai scenes, and the bindings Python shares |
fastanim-cli |
The fastanim command-line tool |
fastanim-py |
The fastanim Python package |
fastanim-web |
Browser player and playground, for Python scenes |
From a checkout, build the package into a virtualenv with maturin:
pip install maturin
maturin develop -m fastanim-py/pyproject.toml
python -m fastanim preview fastanim-py/scenes/diff.py # equations, code refactor, bubble sort, morph
python -m fastanim preview fastanim-py/scenes/sin_and_cos.py # axes and plots
python -m fastanim render fastanim-py/scenes/diff.py -q 720p30 -o diff.mp4
just web # browser playground on http://localhost:8080, rebuilt on changeThe playground needs Trunk (cargo binstall trunk) and
the Pyodide wheel from just pyodide-wheel, which needs uv.
The Rust side, and Rhai scripts with the fastanim CLI (Rust 1.92+; on Linux, building needs
libudev-dev, libwayland-dev and libxkbcommon-dev, plus libasound2-dev for sound):
cargo install --locked --git https://github.com/simonhdickson/fastanim fastanim-cli
fastanim preview fastanim-script/scenes/parity.rhai # the same scene as a Rhai script
cargo run -p fastanim-cli -- diff "a + b = c" "b + a = c"
# ↷b =+ ↷a == =c
cargo run -p fastanim-cli -- diff "a^2 + b^2 = c^2" "a^2 = c^2 - b^2" --math
# =𝑎 =2' == =𝑐 =2' ~(+→−) ↷𝑏 ↷2'
cargo run -p fastanim --example shapes -- frames # writes frames/000.svg …
cargo run -p fastanim-bevy --example parity # live preview window
cargo run -p fastanim-bevy --example parity -- render -q 720p30 -o parity.mp4
cargo run -p fastanim-cli -- profile fastanim-script/scenes/diff.rhai # bake timingsPrebuilt fastanim binaries for Linux (x86_64), macOS (Apple Silicon) and Windows (x86_64) are
attached to each GitHub release, and
install with cargo binstall --git https://github.com/simonhdickson/fastanim fastanim-cli.
MIT