Skip to main content

Sequence

Struct Sequence 

Source
pub struct Sequence { /* private fields */ }
Expand description

Sequential timeline that chains multiple animation segments.

Use Sequence::then to append segments. Sampling automatically advances through each segment as ticks increase.

§Example

use slt::anim::{ease_in_cubic, ease_out_quad, LoopMode, Sequence};

let mut seq = Sequence::new()
    .then(0.0, 100.0, 30, ease_out_quad)
    .then(100.0, 50.0, 20, ease_in_cubic)
    .loop_mode(LoopMode::Repeat);

seq.reset(0);
let _ = seq.value(25);

Implementations§

Source§

impl Sequence

Source

pub fn new() -> Self

Create an empty sequence.

Defaults to LoopMode::Once. Add segments with Sequence::then and call Sequence::reset before sampling.

Source

pub fn then( self, from: f64, to: f64, duration_ticks: u64, easing: fn(f64) -> f64, ) -> Self

Append a segment from from to to over duration_ticks ticks.

Source

pub fn loop_mode(self, mode: LoopMode) -> Self

Set loop behavior used after the first full pass.

Source

pub fn on_complete(self, f: impl FnMut() + 'static) -> Self

Register a callback that runs once when the sequence completes.

Source

pub fn value(&mut self, tick: u64) -> f64

Return the sequence value at tick.

Source

pub fn is_done(&self) -> bool

Returns true if the sequence finished in LoopMode::Once.

Source

pub fn reset(&mut self, tick: u64)

Restart the sequence, treating tick as the new start time.

Trait Implementations§

Source§

impl Default for Sequence

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.