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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.