Motion Canvas in Rust
A high-performance vector animation engine inspired by Motion Canvas, built on Vello and Typst.
[!IMPORTANT] Prototype Status: This project is a functional prototype and proof-of-concept. It is not a 1:1 implementation of the original Motion Canvas API or features.
Installation
Add the library to your Cargo.toml. To enable all features (math, code blocks, images, export), use the full flag:
# Enable everything
# Or pick only what you need (e.g., just math, images, and audio)
Features
| Feature | Description | Enables |
|---|---|---|
math |
Typst-powered LaTeX math rendering. | MathNode |
code |
Syntax-highlighted code blocks via Syntect. | CodeNode |
image |
Bitmap (PNG, JPEG) and Vector (SVG) support. | ImageNode |
audio |
Independent audio timeline and MP3 playback. | play!, AudioNode |
export |
Headless frame rendering and video generation. | project.export() |
full |
Meta-feature that enables all of the above. | Everything |
Key Capabilities
- High-performance: GPU-accelerated vector rendering via Vello.
- Arc-length Sampling: Accurate path animations and offsets.
- Easing Library: 30+ standardized easing functions.
- FFmpeg Integration: Direct streaming of animation frames or merging with audio.
- Audio Support: Synchronized MP3 playback and independent audio timelines.
- Clean API: Streamlined prelude for high-speed prototyping.
- Node Primitives: Built-in support for Circles, Rects, Polygons, Lines, and Groups.
Supported Nodes
| Node | Description | Features |
|---|---|---|
Circle |
Basic circle primitive. | radius, color, transform |
Rect |
Rectangle with optional corner radius. | size, radius, color |
Polygon |
Regular and custom polygon shapes. | points, fill, stroke |
Line |
Simple line between two points. | start, end, width |
PathNode |
Complex path sampling and animation. | arc-length, sample |
TextNode |
High-quality text rendering (skrifa). | text, font_size, family |
MathNode |
Typst-powered mathematical formulas. | LaTeX, smooth-transitions |
CodeNode |
Syntax-highlighted code with transitions. | syntect, magic-move |
ImageNode |
Bitmap and SVG image display. | png, jpeg, svg |
AudioNode |
Independent audio clip playback. | mp3, volume, crop |
GroupNode |
Hierarchical grouping of any nodes. | children, inherited-opacity |
Project Structure
The engine is organized into a modular structure:
src/lib.rs: Library entry point with clean module re-exports.src/engine/nodes/: Individual node implementations.src/engine/animation/: Core animation traits and flow controls.src/engine/easings.rs: Comprehensive easing function library.examples/: Ready-to-run demonstration scripts.
Quick Start
use *;
use Duration;
Running Examples
The project includes 14 examples that can be found in the examples directory.
https://github.com/user-attachments/assets/510d8aac-67ba-42d8-882a-b3c0ad969437
https://github.com/user-attachments/assets/efc1e214-4297-47a2-b6e4-1eae0840b0c9
https://github.com/user-attachments/assets/967e0b47-a8de-4ab7-9b21-8758a2c7f508
https://github.com/user-attachments/assets/7b1fa63a-8500-41e9-a611-0a4ca0a90967
https://github.com/user-attachments/assets/25248e66-ccc7-4422-9f2f-7b9ef361d8d9
https://github.com/user-attachments/assets/d283b03a-ae50-4011-9fab-77ced70a2632
https://github.com/user-attachments/assets/f875086e-d927-42a4-9f21-e57afbdaaaa4
https://github.com/user-attachments/assets/f3d8e774-31f4-4e96-b7b7-9e6bda0ec16f
https://github.com/user-attachments/assets/cd002797-84ec-4bcb-af1f-0ab6e7c20433
https://github.com/user-attachments/assets/96135e70-b5d5-471f-9107-cc70f2b416fa
https://github.com/user-attachments/assets/23ad4662-e499-42f0-8468-3e1666e33d84
https://github.com/user-attachments/assets/75f078ba-51c2-4d26-8993-25e6b77372a9
https://github.com/user-attachments/assets/c01897a9-e744-43af-bfee-045f44549ba9
https://github.com/user-attachments/assets/02670f39-8499-4202-8b22-c160d35f9031
Requirements
- Rust 1.75+
- FFmpeg (optional, for direct video streaming)
- System fonts (Inter, Fira Code, etc. for specific examples)
Credits
This project is heavily inspired by the original Motion Canvas by aarthificial.
Special thanks to:
- easings.net for the standardized easing function library.
- shiki-magic-move for the inspiration behind the token-based code transition logic.