pub struct Tween<T: Lerp + Copy> { /* private fields */ }Expand description
A tween that interpolates a value from start to end over duration.
The tweened value is stored internally and accessible via value().
You can also use callbacks to react to updates and completion.
§Example
let mut tween = Tween::new(0.0, 100.0, 1.0, Ease::CubicOut);
// In update loop:
tween.update(dt);
let current = tween.value(); // 0.0 → 100.0 over 1 secondImplementations§
Source§impl<T: Lerp + Copy> Tween<T>
impl<T: Lerp + Copy> Tween<T>
Sourcepub fn new(start: T, end: T, duration: f32, ease: Ease) -> Self
pub fn new(start: T, end: T, duration: f32, ease: Ease) -> Self
Create a new tween from start to end over duration seconds.
Sourcepub fn with_delay(self, delay: f32) -> Self
pub fn with_delay(self, delay: f32) -> Self
Set a delay before the tween starts.
Sourcepub fn with_ping_pong(self) -> Self
pub fn with_ping_pong(self) -> Self
Set ping-pong mode (tween goes back and forth).
Sourcepub fn with_loops(self, loops: u32) -> Self
pub fn with_loops(self, loops: u32) -> Self
Set loop count (u32::MAX for infinite).
Sourcepub fn with_speed(self, speed: f32) -> Self
pub fn with_speed(self, speed: f32) -> Self
Set speed multiplier.
Sourcepub fn status(&self) -> TweenStatus
pub fn status(&self) -> TweenStatus
Get the current status.
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