Cellophane
A terminal animation framework for Rust. Implement one trait, get a complete rendering pipeline with frame diffing, resize handling, and input forwarding.
Features
- One trait — implement
Animationand you're done - Frame diffing — only changed cells are redrawn each frame
- ANSI parsing —
FrameBuilderparses ansi-styled text (including 24-bit color) into a cell grid via VTE - Resize handling — terminal resize events are detected and forwarded automatically
- Input forwarding — key and mouse events are passed to your animation for interactive use
- Terminal lifecycle — alternate screen, raw mode, cursor visibility, and cleanup on drop
- Unicode support —
Graphemetype handles multi-codepoint characters with stack allocation viaSmallVec
Quick start
Add cellophane to your project:
Implement the Animation trait and let Animator handle the rest:
use Duration;
use ;
use Color;
Core types
| Type | Description |
|---|---|
Animation |
The trait you implement to define an animation |
Animator |
Drives your animation with a frame-rate-limited render loop |
Frame |
A grid of styled Cells representing one frame of output |
FrameBuilder |
Parses ANSI-escaped text into a Frame |
Cell |
A single terminal cell with character, colors, and attributes |
CellFlags |
Bitflags for text attributes (bold, italic, underline, etc.) |
Grapheme |
A unicode grapheme cluster backed by SmallVec<[char; 4]> |
How it works
The Animator manages the full terminal lifecycle:
- Enters the alternate screen, enables raw mode, hides the cursor
- Each
tick()polls for events, calls yourupdate(), and renders the frame - Only cells that differ from the previous frame are written to the terminal
- Resize events call your
resize(), input events call youron_event() - Ctrl+C returns
Err(ErrorKind::Interrupted)for clean shutdown - Terminal state is restored automatically on drop
Built with cellophane
- whoa — a terminal screensaver featuring EarthBound battle backgrounds, procedural simulations, cellular automata, and more