Skip to main content

StaggeredAnimation

Struct StaggeredAnimation 

Source
pub struct StaggeredAnimation<T: Interpolate> {
    pub base_delay: f32,
    pub stagger_delay: f32,
    pub duration: f32,
    pub easing: EasingFunction,
    /* private fields */
}
Expand description

Staggered animation system for multiple items

Creates a choreographed animation where items animate in sequence with configurable delays between them.

§Example

use armas_basic::animation::StaggeredAnimation;

// Fade in 5 items, each delayed by 0.1s, taking 0.3s each
let mut anim = StaggeredAnimation::new(0.0_f32, 1.0, 5, 0.1, 0.3);
anim.update(0.2);
let opacity_0 = anim.opacity(0); // mostly visible
let opacity_4 = anim.opacity(4); // not started yet

Fields§

§base_delay: f32

Base delay before first item starts (seconds)

§stagger_delay: f32

Delay between each item (seconds)

§duration: f32

Duration of each item’s animation (seconds)

§easing: EasingFunction

Easing function for each item

Implementations§

Source§

impl<T: Interpolate> StaggeredAnimation<T>

Source

pub const fn new( start: T, end: T, item_count: usize, stagger_delay: f32, duration: f32, ) -> Self

Create a new staggered animation

Source

pub const fn base_delay(self, delay: f32) -> Self

Set the base delay before first item

Source

pub const fn easing(self, easing: EasingFunction) -> Self

Set the easing function

Source

pub fn update(&mut self, dt: f32)

Update the animation

Source

pub const fn reset(&mut self)

Reset the animation

Source

pub fn value(&self, index: usize) -> T

Get the value for a specific item index

Source

pub fn progress(&self, index: usize) -> f32

Get the progress (0.0 to 1.0) for a specific item

Source

pub fn is_complete(&self) -> bool

Check if all items have completed

Source

pub fn opacity(&self, index: usize) -> f32

Get opacity for item (useful for fade-in effects)

Source

pub fn scale(&self, index: usize) -> f32

Get scale for item (useful for scale-in effects)

Source

pub fn y_offset(&self, index: usize, distance: f32) -> f32

Get Y offset for item (useful for slide-in effects)

Trait Implementations§

Source§

impl<T: Clone + Interpolate> Clone for StaggeredAnimation<T>

Source§

fn clone(&self) -> StaggeredAnimation<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Interpolate> Debug for StaggeredAnimation<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for StaggeredAnimation<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for StaggeredAnimation<T>
where T: RefUnwindSafe,

§

impl<T> Send for StaggeredAnimation<T>
where T: Send,

§

impl<T> Sync for StaggeredAnimation<T>
where T: Sync,

§

impl<T> Unpin for StaggeredAnimation<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for StaggeredAnimation<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for StaggeredAnimation<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,