pub fn record<P, I, F, R>(path: P, frames: I, frame_fn: F) -> Result<()>👎Deprecated since 0.1.0: Use the record! macro instead:
record!(path, frames, |t| plot)Expand description
Record an animation by iterating over frames
This is the primary API for creating animations. It iterates over the provided frames, calling the frame function for each to generate a plot, then captures and encodes each frame.
§Type Parameters
P- Output path type (implementsAsRef<Path>)I- Iterator type for frame dataF- Frame function type
§Arguments
path- Output file path (format detected from extension)frames- Iterator of frame data (e.g.,0..60for 60 frames)frame_fn- Function that produces a Plot for each frame
§Example
ⓘ
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!("Frame {}", frame))
}).unwrap();