pub struct Animation<T: Interpolate> {
pub start: T,
pub end: T,
pub duration: f32,
pub elapsed: f32,
pub easing: EasingFunction,
pub state: AnimationState,
}Expand description
A generic animation that interpolates between two values over time
§Example
use armas_basic::animation::{Animation, EasingFunction};
let mut anim = Animation::new(0.0_f32, 1.0, 0.3)
.easing(EasingFunction::EaseOut);
anim.start();
anim.update(0.15);
let value = anim.value(); // interpolated between 0.0 and 1.0Fields§
§start: TStarting value
end: TTarget value
duration: f32Duration of the animation in seconds
elapsed: f32Elapsed time in seconds
easing: EasingFunctionEasing function to apply
state: AnimationStateCurrent state of the animation
Implementations§
Source§impl<T: Interpolate> Animation<T>
impl<T: Interpolate> Animation<T>
Sourcepub const fn new(start: T, end: T, duration: f32) -> Self
pub const fn new(start: T, end: T, duration: f32) -> Self
Create a new animation from start to end over duration
Sourcepub const fn easing(self, easing: EasingFunction) -> Self
pub const fn easing(self, easing: EasingFunction) -> Self
Set the easing function
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the animation is complete
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the animation is running
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Animation<T>where
T: Freeze,
impl<T> RefUnwindSafe for Animation<T>where
T: RefUnwindSafe,
impl<T> Send for Animation<T>where
T: Send,
impl<T> Sync for Animation<T>where
T: Sync,
impl<T> Unpin for Animation<T>where
T: Unpin,
impl<T> UnsafeUnpin for Animation<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Animation<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more