pub struct MotionSpring { /* private fields */ }Expand description
A deterministic scalar spring transition.
Implementations§
Source§impl MotionSpring
impl MotionSpring
Sourcepub fn new(
spec: MotionSpringSpec,
from: f32,
target: f32,
initial_velocity: f32,
started_at: Instant,
) -> Self
pub fn new( spec: MotionSpringSpec, from: f32, target: f32, initial_velocity: f32, started_at: Instant, ) -> Self
Creates a scalar spring transition.
Sourcepub fn retarget_from_sample(
spec: MotionSpringSpec,
sample: MotionScalarSample,
target: f32,
started_at: Instant,
) -> Self
pub fn retarget_from_sample( spec: MotionSpringSpec, sample: MotionScalarSample, target: f32, started_at: Instant, ) -> Self
Creates a new spring whose source and velocity come from an interrupted sample.
Sourcepub const fn spec(self) -> MotionSpringSpec
pub const fn spec(self) -> MotionSpringSpec
Returns the spring specification.
Sourcepub const fn initial_velocity(self) -> f32
pub const fn initial_velocity(self) -> f32
Returns the initial velocity.
Sourcepub const fn started_at(self) -> Instant
pub const fn started_at(self) -> Instant
Returns the instant at which the spring started.
Sourcepub const fn cancelled_at(self) -> Option<Instant>
pub const fn cancelled_at(self) -> Option<Instant>
Returns the instant at which the spring was cancelled.
Sourcepub fn cancel_at(&mut self, cancelled_at: Instant)
pub fn cancel_at(&mut self, cancelled_at: Instant)
Marks the spring as cancelled at the provided instant.
Sourcepub fn sample(self, now: Instant) -> MotionScalarSample
pub fn sample(self, now: Instant) -> MotionScalarSample
Samples the spring at the provided instant.
Sourcepub fn sample_elapsed(
spec: MotionSpringSpec,
from: f32,
target: f32,
initial_velocity: f32,
elapsed: Duration,
) -> MotionScalarSample
pub fn sample_elapsed( spec: MotionSpringSpec, from: f32, target: f32, initial_velocity: f32, elapsed: Duration, ) -> MotionScalarSample
Samples a spring using an explicit elapsed duration.
Trait Implementations§
Source§impl Clone for MotionSpring
impl Clone for MotionSpring
impl Copy for MotionSpring
Source§impl Debug for MotionSpring
impl Debug for MotionSpring
Source§impl PartialEq for MotionSpring
impl PartialEq for MotionSpring
impl StructuralPartialEq for MotionSpring
Auto Trait Implementations§
impl Freeze for MotionSpring
impl RefUnwindSafe for MotionSpring
impl Send for MotionSpring
impl Sync for MotionSpring
impl Unpin for MotionSpring
impl UnsafeUnpin for MotionSpring
impl UnwindSafe for MotionSpring
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