pub struct Splash<'a> { /* private fields */ }Expand description
The animation state machine.
Default time source is the wall clock at 30 Hz; consumers call
Splash::cells every redraw and the animation marches at the configured
period regardless of redraw rate. For deterministic frame stepping (snapshot
tests, recorded playback) construct via Splash::fixed_tick or pin an
existing splash with Splash::set_fixed_tick.
Implementations§
Source§impl<'a> Splash<'a>
impl<'a> Splash<'a>
Sourcepub fn new(art: &'a str, path: &'a [(u8, u8, char)]) -> Self
pub fn new(art: &'a str, path: &'a [(u8, u8, char)]) -> Self
Wall-clock-driven splash with the default ~8 Hz tick rate and 6-cell
trail. The clock anchor is Instant::now().
Sourcepub fn fixed_tick(art: &'a str, path: &'a [(u8, u8, char)], tick: u64) -> Self
pub fn fixed_tick(art: &'a str, path: &'a [(u8, u8, char)], tick: u64) -> Self
Deterministic splash pinned to a fixed tick. Useful for snapshot tests
and recorded playback. The tick value is what Splash::cells sees.
Sourcepub fn with_trail_len(self, n: u8) -> Self
pub fn with_trail_len(self, n: u8) -> Self
Override the trail length (default DEFAULT_TRAIL_LEN).
Sourcepub fn with_period(self, period: Duration) -> Self
pub fn with_period(self, period: Duration) -> Self
Override the wall-clock tick period (default DEFAULT_PERIOD).
No-op when the splash is in fixed-tick mode.
Sourcepub fn set_fixed_tick(&mut self, tick: u64)
pub fn set_fixed_tick(&mut self, tick: u64)
Pin the splash to tick, switching it into fixed-tick mode.
Subsequent calls to Splash::cells return frames for that tick.
Sourcepub fn cells(&self, layout: Layout) -> impl Iterator<Item = SplashCell> + '_
pub fn cells(&self, layout: Layout) -> impl Iterator<Item = SplashCell> + '_
Yield every cell to paint for the current frame. Idempotent within a tick window — calling it 1× or 100× per period produces the same cells.
Order:
- All art-glyph cells from
self.artlines (CellKind::Art). - The trail (oldest → newest), then the cursor cell. Later iterations overwrite earlier, so naive renderers can paint in iteration order.