Expand description
Easing curves, tweens, springs and UI/screen transition timing.
Everything here is Copy, allocation-free and advanced by a caller-supplied
dt in seconds, so presentation stays deterministic for a given sequence of
timesteps (subject to the platform’s exp/sin/powf, as with
crate::motion). Nothing reads a clock. Drive these from the frame delta
for menus and HUD polish; drive them from the fixed tick when the motion is
part of gameplay timing.
Reduced motion is an explicit Motion argument. Build it from the player’s
FeedbackPolicy with Motion::from(policy). Under Motion::Reduced
tweens and springs snap to their targets, entrances only fade, roll counters
show the final number and screen transitions become plain fades.
use ferravex_play::tween::{Ease, Motion, Spring, Tween};
let mut fade = Tween::new(0., 1., 0.25, Ease::CubicOut);
let mut scale = Spring::underdamped(0.8, 6., 0.45);
scale.set_target(1.);
for _ in 0..30 {
let alpha = fade.advance(1. / 60., Motion::Full);
let s = scale.advance(1. / 60., Motion::Full);
assert!((0. ..=1.).contains(&alpha) && s.is_finite());
}
assert!(fade.is_finished() && fade.value() == 1.);Structs§
- Appearance
- How a staggered UI element appears at one instant: multiply its alpha,
translate it by
offsetand scale it about its center byscale. - Entrance
- Fade/slide/scale entrance shared by a list of elements with a per-item
stagger. Sample with the time since the list opened; play it backwards
(decreasing
elapsed) for an exit. - Roll
Counter - An integer display that rolls toward its target, like a score counter.
Every roll takes
durationseconds regardless of size (eased, quick start and gentle landing) and the shown number never passes the target. - Screen
Transition - Cover → swap → reveal timing for scene changes (wipe, iris or fade).
Under reduced motion
ScreenTransition::kindreportsTransitionKind::Fade. - Spring
- A damped harmonic spring toward
target, integrated analytically so anydtis stable and splitting a step gives the same result (up to rounding). - Tween
- A one-shot eased transition from
fromtotooverdurationseconds, optionally after a delay. Non-finite or negative timesteps count as zero; a nonpositive duration finishes immediately.
Enums§
- Ease
- Standard easing curves.
Ease::applymapstin[0, 1](clamped) to eased progress with exact endpoints0 → 0and1 → 1. Back and elastic curves overshoot outside[0, 1]in between; bounce stays inside it. - Motion
- Whether presentation motion is full or reduced for accessibility.
- Transition
Event - Completion edge reported once by
ScreenTransition::advance. - Transition
Kind - Visual style of a
ScreenTransition. Drawing lives in the renderer (ferravex_render::ui::kit::draw_screen_transition). - Transition
Phase - What a
ScreenTransitionis doing.
Functions§
- lerp
- Linear interpolation
a + (b - a) * t(tis not clamped).