pub struct Tween<T: Lerp + Debug> {
pub from: T,
pub to: T,
pub duration: f32,
pub easing: Easing,
pub delay: f32,
pub repeat: i32,
pub yoyo: bool,
}Expand description
A single interpolation from from to to over duration seconds.
Fields§
§from: T§to: T§duration: f32§easing: Easing§delay: f32§repeat: i32Automatically reverse and repeat (yoyo mode). Negative for infinite.
yoyo: boolWhether to yoyo (ping-pong) on repeat.
Implementations§
Source§impl<T: Lerp + Debug> Tween<T>
impl<T: Lerp + Debug> Tween<T>
pub fn new(from: T, to: T, duration: f32, easing: Easing) -> Self
pub fn with_delay(self, delay: f32) -> Self
pub fn with_repeat(self, repeat: i32, yoyo: bool) -> Self
Sourcepub fn sample(&self, time: f32) -> T
pub fn sample(&self, time: f32) -> T
Sample the tween at time seconds from the start.
Returns the interpolated value. After duration + delay, clamps to to
unless repeat is set.
Sourcepub fn sample_looped(&self, time: f32) -> T
pub fn sample_looped(&self, time: f32) -> T
Sample with repeat/yoyo handling.
Sourcepub fn is_complete(&self, time: f32) -> bool
pub fn is_complete(&self, time: f32) -> bool
Returns true if the tween has finished (after duration + delay, accounting for repeat).
Sourcepub fn total_duration(&self) -> f32
pub fn total_duration(&self) -> f32
Total duration including all repeats and delay.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Tween<T>where
T: Freeze,
impl<T> RefUnwindSafe for Tween<T>where
T: RefUnwindSafe,
impl<T> Send for Tween<T>where
T: Send,
impl<T> Sync for Tween<T>where
T: Sync,
impl<T> Unpin for Tween<T>where
T: Unpin,
impl<T> UnsafeUnpin for Tween<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Tween<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