Skip to main content

Splash

Struct Splash 

Source
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>

Source

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().

Source

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.

Source

pub fn with_trail_len(self, n: u8) -> Self

Override the trail length (default DEFAULT_TRAIL_LEN).

Source

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.

Source

pub fn reset(&mut self)

Reset the wall-clock anchor to “now”. No-op when fixed-tick.

Source

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.

Source

pub fn tick(&self) -> u64

Current tick — derived from the wall clock or the pinned value.

Source

pub fn trail_len(&self) -> u8

Current trail length.

Source

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:

  1. All art-glyph cells from self.art lines (CellKind::Art).
  2. The trail (oldest → newest), then the cursor cell. Later iterations overwrite earlier, so naive renderers can paint in iteration order.

Auto Trait Implementations§

§

impl<'a> Freeze for Splash<'a>

§

impl<'a> RefUnwindSafe for Splash<'a>

§

impl<'a> Send for Splash<'a>

§

impl<'a> Sync for Splash<'a>

§

impl<'a> Unpin for Splash<'a>

§

impl<'a> UnsafeUnpin for Splash<'a>

§

impl<'a> UnwindSafe for Splash<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.