Struct MotionValue
pub struct MotionValue<T>where
T: Animatable,{ /* private fields */ }Expand description
A value following its target on a spring, in closed form.
Self::setstarts a new segment from the value and velocity the current one has atnow, so a reversal or a new target mid-flight never jumps and never stalls; repeated changes are one motion, never a queue.Self::getis exact at anynow: the curve does not depend on how often, or whether, frames were drawn.- Once within tolerance the value is the target, and
Self::is_movingis false: a settled value asks for no frames.
Implementations§
§impl<T> MotionValue<T>where
T: Animatable,
impl<T> MotionValue<T>where
T: Animatable,
pub fn new(value: T) -> MotionValue<T>
pub fn new(value: T) -> MotionValue<T>
A value at rest.
pub fn with_tolerance(self, tolerance: f64) -> MotionValue<T>
pub fn with_tolerance(self, tolerance: f64) -> MotionValue<T>
The same value, arriving within tolerance per channel instead of the
type’s default (a scalar carrying pixels rather than a fraction).
pub fn target(&self) -> T
pub fn target(&self) -> T
Where the value is going (or is, at rest).
pub fn get(&self, now: Instant) -> T
pub fn settles_at(&self) -> Option<Instant>
pub fn settles_at(&self) -> Option<Instant>
When the current motion arrives; None at rest. A host that sleeps
until then instead of drawing frames has nothing to draw anyway.
pub fn defer(&mut self, by: Duration)
pub fn defer(&mut self, by: Duration)
Hold the motion for by: time spent waiting (on a full presenter)
is not progress, so the curve resumes where it stood.
pub fn shift_by(&mut self, by: T)
pub fn shift_by(&mut self, by: T)
Move the whole motion by by: where it is going and every point of
its way there, keeping its pace. For a value measured in a frame that
moved under it (a pan whose canvas lost a window before the view):
what it shows on screen goes on unchanged.
pub fn sampled_after(&self, elapsed: Duration) -> (T, T)
pub fn sampled_after(&self, elapsed: Duration) -> (T, T)
The value and its velocity elapsed into the current segment,
whatever the clock says: a capture posing a motion at a chosen point
of its run, since an offscreen frame costs more wall time than the
whole motion lasts. Never for a live frame, which reads Self::get
at its instant.
pub fn snap(&mut self, value: T)
pub fn snap(&mut self, value: T)
Jump to value and rest there. A motion that was on its way takes
back its wish for frames: whoever landed it draws the change.
Trait Implementations§
§impl<T> Clone for MotionValue<T>where
T: Clone + Animatable,
impl<T> Clone for MotionValue<T>where
T: Clone + Animatable,
§fn clone(&self) -> MotionValue<T>
fn clone(&self) -> MotionValue<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<T> Debug for MotionValue<T>where
T: Debug + Animatable,
impl<T> Debug for MotionValue<T>where
T: Debug + Animatable,
§impl<T> Default for MotionValue<T>where
T: Animatable + Default,
impl<T> Default for MotionValue<T>where
T: Animatable + Default,
§fn default() -> MotionValue<T>
fn default() -> MotionValue<T>
impl<T> Copy for MotionValue<T>where
T: Copy + Animatable,
Auto Trait Implementations§
impl<T> Freeze for MotionValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for MotionValue<T>where
T: RefUnwindSafe,
impl<T> Send for MotionValue<T>where
T: Send,
impl<T> Sync for MotionValue<T>where
T: Sync,
impl<T> Unpin for MotionValue<T>where
T: Unpin,
impl<T> UnsafeUnpin for MotionValue<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for MotionValue<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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