Expand description
Animation and frame management for flicker-free terminal graphics.
This module provides the core infrastructure for building smooth, professional-quality
terminal animations. The key component is FrameBuffer, which implements double buffering
to eliminate visual tearing and flickering during frame updates.
§Double Buffering Explained
Double buffering is a technique where two buffers are maintained:
- Front buffer: Currently displayed on screen (read-only during drawing)
- Back buffer: Being prepared for the next frame (where you draw)
The workflow is:
- Clear the back buffer
- Draw the next frame to the back buffer
- Instantly swap front and back buffers (O(1) pointer swap)
- Render the new front buffer to the terminal
- Repeat
This eliminates flickering because the user only sees complete frames - never partially drawn content.
§Example
use dotmax::animation::FrameBuffer;
use dotmax::TerminalRenderer;
// Create a double-buffered frame system
let mut buffer = FrameBuffer::new(80, 24);
// Get mutable access to the back buffer for drawing
let back = buffer.get_back_buffer();
back.clear();
back.set_dot(10, 10).unwrap(); // Draw something
// Swap buffers - instant O(1) operation
buffer.swap_buffers();
// Render the front buffer to terminal
// let mut renderer = TerminalRenderer::new().unwrap();
// buffer.render(&mut renderer).unwrap();§Performance
- Buffer swap time: <1ms (pointer swap, not data copy)
- Designed for 60+ fps animations
- Memory efficient: buffers are reused, not reallocated
Structs§
- Animation
Loop - High-level animation loop abstraction.
- Animation
Loop Builder - Builder for constructing
AnimationLoopinstances. - Differential
Renderer - Optimized renderer that only outputs changed cells.
- Frame
Buffer - Double-buffered frame management for flicker-free animation.
- Frame
Timer - Frame timing control for consistent animation speeds.
- Prerendered
Animation - Pre-rendered animation for optimal playback performance.