pub struct Tween {
pub from: f32,
pub to: f32,
pub duration: f32,
pub curve: Curve,
}Expand description
Injected-clock tween of a scalar from from→to over duration seconds,
eased by a Curve. The single “animate a value over a duration” primitive the
form facets were missing (hover/selection/expand, drawer slide-ins).
Determinism (FC-7): a Tween holds no egui state and no wall-clock — you
evaluate it at the elapsed seconds you own (the same dt/clock model as
SmoothScroll and focus::motion_progress),
so snapshots stay reproducible. It is a pure value, Copy, cheap to rebuild each frame.
use facett_core::effects::{Tween, Curve};
let t = Tween::new(0.0, 100.0, 0.2, Curve::EaseInOutCubic);
assert_eq!(t.value_at(0.0), 0.0); // start
assert_eq!(t.value_at(0.2), 100.0); // end
assert!(t.is_done(0.2));Fields§
§from: f32Value at elapsed <= 0.
to: f32Value at elapsed >= duration.
duration: f32Tween length in seconds. <= 0 snaps instantly to to (honours Motion::duration == 0,
the reduced-motion / Device setting).
curve: CurveEasing curve.
Implementations§
Source§impl Tween
impl Tween
Sourcepub fn new(from: f32, to: f32, duration: f32, curve: Curve) -> Self
pub fn new(from: f32, to: f32, duration: f32, curve: Curve) -> Self
A tween from→to over duration seconds with curve.
Sourcepub fn from_motion(motion: &Motion, from: f32, to: f32, curve: Curve) -> Self
pub fn from_motion(motion: &Motion, from: f32, to: f32, curve: Curve) -> Self
A standard-duration tween from the theme’s Motion token.
Sourcepub fn from_motion_fast(
motion: &Motion,
from: f32,
to: f32,
curve: Curve,
) -> Self
pub fn from_motion_fast( motion: &Motion, from: f32, to: f32, curve: Curve, ) -> Self
A faster tween using Motion::fast — for small/cheap transitions.
Sourcepub fn value_at(&self, elapsed: f32) -> f32
pub fn value_at(&self, elapsed: f32) -> f32
Eased value at elapsed seconds since the tween started.
value_at(<=0) == from, value_at(>=duration) == to; duration <= 0 ⇒ to.
Sourcepub fn progress_at(&self, elapsed: f32) -> f32
pub fn progress_at(&self, elapsed: f32) -> f32
Eased progress ∈[0,1] (the to-fraction) at elapsed — the lerp factor
to drive geometry/colour interpolation yourself.
Trait Implementations§
impl Copy for Tween
impl StructuralPartialEq for Tween
Auto Trait Implementations§
impl Freeze for Tween
impl RefUnwindSafe for Tween
impl Send for Tween
impl Sync for Tween
impl Unpin for Tween
impl UnsafeUnpin for Tween
impl UnwindSafe for Tween
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more