pub struct MotionRuntime { /* private fields */ }Expand description
Stores animations and advances their active values.
§Examples
use aura_anim_core::{MotionRuntime, timing::Timing};
use std::time::Duration;
let mut runtime = MotionRuntime::new();
let opacity = runtime.motion_with(0.0_f32, Timing::new(100.0));
assert!(opacity.transition_to(1.0, &mut runtime));
runtime.tick(Duration::from_millis(50));
assert_eq!(opacity.value(&runtime), 0.5);
assert!(opacity.is_active(&runtime));Implementations§
Source§impl MotionRuntime
impl MotionRuntime
Sourcepub fn motion<T: Animatable>(&mut self, initial: T) -> Motion<T>
pub fn motion<T: Animatable>(&mut self, initial: T) -> Motion<T>
Inserts an idle motion with the default transition timing.
Sourcepub fn motion_with<T: Animatable>(
&mut self,
initial: T,
timing: Timing,
) -> Motion<T>
pub fn motion_with<T: Animatable>( &mut self, initial: T, timing: Timing, ) -> Motion<T>
Inserts an idle motion with the provided transition timing.
Sourcepub fn insert<T: Animatable>(
&mut self,
animation: impl Animation<T>,
transition: Timing,
) -> Motion<T>
pub fn insert<T: Animatable>( &mut self, animation: impl Animation<T>, transition: Timing, ) -> Motion<T>
Inserts an animation that remains stored after it settles.
Sourcepub fn play_once<T: Animatable>(
&mut self,
animation: impl Animation<T>,
) -> Motion<T>
pub fn play_once<T: Animatable>( &mut self, animation: impl Animation<T>, ) -> Motion<T>
Inserts an animation that is removed after it settles.
Sourcepub fn insert_with_policy<T: Animatable>(
&mut self,
animation: impl Animation<T>,
transition: Timing,
retain_policy: RetainPolicy,
) -> Motion<T>
pub fn insert_with_policy<T: Animatable>( &mut self, animation: impl Animation<T>, transition: Timing, retain_policy: RetainPolicy, ) -> Motion<T>
Inserts an animation with transition timing and a retention policy.
Sourcepub fn tick_at(&mut self, now: Instant)
pub fn tick_at(&mut self, now: Instant)
Advances active animations using elapsed wall-clock time.
The first call establishes the clock origin and advances by zero.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Returns the number of animations currently marked active.
Sourcepub fn has_active(&self) -> bool
pub fn has_active(&self) -> bool
Returns whether at least one animation is active.
Sourcepub fn motion_count(&self) -> usize
pub fn motion_count(&self) -> usize
Returns the number of stored animations.
Sourcepub fn slot_capacity(&self) -> usize
pub fn slot_capacity(&self) -> usize
Returns the allocated capacity of the runtime slot storage.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Releases unused slot and queue capacity.
Sourcepub fn value<T: Animatable>(&self, motion: Motion<T>) -> Option<&T>
pub fn value<T: Animatable>(&self, motion: Motion<T>) -> Option<&T>
Returns the current value for a valid motion handle.
Sourcepub fn state<T: Animatable>(&self, motion: Motion<T>) -> Option<AnimationState>
pub fn state<T: Animatable>(&self, motion: Motion<T>) -> Option<AnimationState>
Returns the state for a valid motion handle.
Sourcepub fn is_active<T: Animatable>(&self, motion: Motion<T>) -> bool
pub fn is_active<T: Animatable>(&self, motion: Motion<T>) -> bool
Returns whether the referenced motion is active.
Sourcepub fn transition_to<T: Animatable>(
&mut self,
motion: Motion<T>,
target: T,
) -> bool
pub fn transition_to<T: Animatable>( &mut self, motion: Motion<T>, target: T, ) -> bool
Transitions a valid motion toward target.
Returns false when the handle is no longer valid.
Sourcepub fn play<T: Animatable>(
&mut self,
motion: Motion<T>,
animation: impl Animation<T>,
) -> bool
pub fn play<T: Animatable>( &mut self, motion: Motion<T>, animation: impl Animation<T>, ) -> bool
Replaces the animation associated with a valid motion.
Returns false when the handle is no longer valid.
Sourcepub fn command<T: Animatable>(
&mut self,
motion: Motion<T>,
command: AnimationCommand,
) -> bool
pub fn command<T: Animatable>( &mut self, motion: Motion<T>, command: AnimationCommand, ) -> bool
Applies a command to a valid motion.
Returns false when the handle is no longer valid.
Sourcepub fn remove<T: Animatable>(&mut self, motion: Motion<T>) -> bool
pub fn remove<T: Animatable>(&mut self, motion: Motion<T>) -> bool
Removes the animation referenced by motion.
Returns false when the handle is no longer valid.