pub struct Entrance {
pub duration: f32,
pub stagger: f32,
pub ease: Ease,
pub fade: bool,
pub slide: [f32; 2],
pub scale_from: f32,
}Expand description
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.
use ferravex_play::tween::{Entrance, Motion};
let menu = Entrance::fade_up(12.).with_stagger(0.05);
let first = menu.sample(0.1, 0, Motion::Full);
let third = menu.sample(0.1, 2, Motion::Full);
assert!(first.alpha > third.alpha && first.offset[1] < third.offset[1]);
assert_eq!(menu.sample(10., 5, Motion::Full).alpha, 1.);
// Reduced motion keeps the fade but drops movement and stagger.
let calm = menu.sample(0.1, 2, Motion::Reduced);
assert_eq!((calm.offset, calm.scale), ([0., 0.], 1.));Fields§
§duration: f32§stagger: f32Extra delay per item index.
ease: Ease§fade: bool§slide: [f32; 2]Starting offset, eased to zero.
scale_from: f32Starting scale, eased to one.
Implementations§
Source§impl Entrance
impl Entrance
Sourcepub fn fade_up(distance: f32) -> Entrance
pub fn fade_up(distance: f32) -> Entrance
Fades in while rising distance units (0.28 s, cubic out).
Sourcepub fn pop(scale_from: f32) -> Entrance
pub fn pop(scale_from: f32) -> Entrance
Fades in while growing from scale_from with a slight overshoot.
pub fn with_stagger(self, seconds: f32) -> Entrance
pub fn with_duration(self, seconds: f32) -> Entrance
pub fn with_ease(self, ease: Ease) -> Entrance
Sourcepub fn total_duration(&self, count: usize) -> f32
pub fn total_duration(&self, count: usize) -> f32
Seconds until item count - 1 has fully arrived.
Trait Implementations§
impl Copy for Entrance
impl StructuralPartialEq for Entrance
Auto Trait Implementations§
impl Freeze for Entrance
impl RefUnwindSafe for Entrance
impl Send for Entrance
impl Sync for Entrance
impl Unpin for Entrance
impl UnwindSafe for Entrance
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