Expand description
Animation export system for ruviz
This module provides animation recording and video export capabilities, modeled after Makie.jl’s proven animation architecture.
§Features
- Tick-based timing: Deterministic frame timing with
Tickstruct - Macro-based recording:
record!for frame count, duration, and config-driven capture - GIF export: deterministic frame capture and GIF encoding
- Observable integration: Reactive animations with
AnimatedObservable - Smooth transitions: Easing functions and plot morphing
- Compatibility wrappers: Deprecated
record_*helpers remain available for older code
§Recommended API
ⓘ
use ruviz::prelude::*;
use ruviz::record;
// Record with frame count and tick interpolation helpers
record!("bounce.gif", 60, |t| {
let y = t.ease_over(easing::ease_out_bounce, 100.0, 0.0, 2.0);
Plot::new().scatter(&[0.0], &[y])
})?;
// Or use duration syntax
record!("wave.gif", 2 secs, |t| {
let x = t.lerp_over(0.0, 10.0, 2.0);
Plot::new().line(&[0.0, x], &[0.0, x])
})?;§Animation Builder API
For multi-value animations with custom easing:
ⓘ
use ruviz::animation::{Animation, easing};
Animation::build()
.value("x", 0.0).to(100.0).duration_secs(2.0)
.value("y", 50.0).to(0.0).ease(easing::ease_out_bounce)
.record("output.gif", |values, tick| {
Plot::new().scatter(&[values["x"]], &[values["y"]])
})?;§Deprecated Compatibility API
ⓘ
use ruviz::prelude::*;
use ruviz::animation::record;
let x: Vec<f64> = (0..100).map(|i| i as f64 * 0.1).collect();
record("wave.gif", 0..60, |frame, tick| {
let phase = tick.time * 2.0 * std::f64::consts::PI;
let y: Vec<f64> = x.iter().map(|&xi| (xi + phase).sin()).collect();
#[allow(deprecated)]
Plot::new()
.line(&x, &y)
.end_series()
.title(format!("t = {:.2}s", tick.time))
}).unwrap();The record() and record_simple() helpers are deprecated in favor of record!
but remain available for older callers.
§Feature Flags
animation- Core animation system with GIF exportanimation-video- compatibility alias foranimation; AV1 video is not currently available
Re-exports§
pub use encoders::Codec;pub use encoders::Encoder;pub use encoders::Quality;pub use crate::data::signal;pub use crate::data::signal::Signal;
Modules§
Structs§
- Animated
Observable - An observable value that can animate smoothly between states
- Animation
- Completed animation ready for recording
- Animation
Builder - Builder for creating multi-value animations
- Animation
Group - A collection of animated observables that can be ticked together
- Animation
Values - Runtime access to animated values during recording
- Frame
Capture - Captures rendered frames from plots
- Record
Config - Configuration for animation recording
- Tick
- Animation timing context for each frame
- Tick
Generator - Generates ticks at a fixed framerate
- Video
Config - Configuration for video output
- Video
Stream - Buffers frames and streams them to an encoder
Enums§
- Tick
State - State of the current tick
Traits§
- Duration
Ext - Extension trait for ergonomic duration creation
- Interpolate
- Trait for types that can be interpolated between two values
- Into
Frame Count - Trait for types that can specify animation duration/frame count
- Tickable
- Trait for types that can be ticked for animation
Functions§
- record
Deprecated - Record an animation by iterating over frames
- record_
animated Deprecated - Record an animation driven by AnimatedObservable changes
- record_
animated_ with_ config Deprecated - Record animated observables with explicit configuration
- record_
duration Deprecated - Record an animation for a specific duration
- record_
duration_ with_ config Deprecated - Record an animation with duration and explicit config
- record_
plot - Record a pre-built plot to an animation file.
- record_
plot_ with_ config - Record a reactive plot with explicit configuration.
- record_
simple Deprecated - Simplified animation recording with minimal boilerplate
- record_
simple_ with_ config Deprecated - Simplified animation recording with configuration
- record_
with_ config Deprecated - Record an animation with explicit configuration