pub struct Tween<T: Interpolable + Copy> { /* private fields */ }Expand description
A generic tween interpolating a value of type T from a start to an end
value over a fixed duration, driven by an Easing curve.
Works with any type implementing Interpolable — the engine provides
implementations for f64, Vector2D, Vector3D, and Color.
§Why hand-written accessors
Lombok’s Data derive is intentionally not applied here for the same
reason as EngineCell: the derive does not propagate generic bounds, so
deriving on Tween<T> would force T: Default-style bounds that
Interpolable types do not carry. The accessor pairs below follow the
same naming contract as the Lombok-generated ones (get_* / set_*).
Implementations§
Source§impl<T: Interpolable + Copy> Tween<T>
Implements creation, playback control, and value sampling for Tween.
impl<T: Interpolable + Copy> Tween<T>
Implements creation, playback control, and value sampling for Tween.
Sourcepub fn create(from: T, to: T, duration: f64) -> Tween<T>
pub fn create(from: T, to: T, duration: f64) -> Tween<T>
Creates a new linear tween from from to to over duration seconds.
The tween starts in the Delayed state only when a delay is later
attached via Tween::with_delay; by default it starts Running.
§Arguments
T- The start value.T- The end value.f64- The interpolation duration in seconds.
§Returns
Tween<T>- The new tween.
Sourcepub fn with_easing(self, easing: Easing) -> Tween<T>
pub fn with_easing(self, easing: Easing) -> Tween<T>
Sourcepub fn with_delay(self, delay: f64) -> Tween<T>
pub fn with_delay(self, delay: f64) -> Tween<T>
Sourcepub fn with_mode(self, mode: AnimationMode) -> Tween<T>
pub fn with_mode(self, mode: AnimationMode) -> Tween<T>
Sourcepub fn with_on_complete(self, on_complete: Rc<dyn Fn()>) -> Tween<T>
pub fn with_on_complete(self, on_complete: Rc<dyn Fn()>) -> Tween<T>
Sourcepub fn value(&self) -> T
pub fn value(&self) -> T
Returns the current interpolated value without advancing time.
§Returns
T- The current eased value.
Sourcepub fn eased_progress(&self) -> f64
pub fn eased_progress(&self) -> f64
Returns the eased progress of the current cycle in the range 0.0 to 1.0.
§Returns
f64- The eased progress.
Sourcepub fn raw_progress(&self) -> f64
pub fn raw_progress(&self) -> f64
Returns the raw (uneased) progress of the current cycle.
§Returns
f64- The raw progress in the range 0.0 to 1.0.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns whether the tween has finished (AnimationMode::Once only).
§Returns
bool- True if the tween is finished.