pub struct SpringF32 {
pub value: f32,
pub velocity: f32,
pub stiffness: f32,
pub damping: f32,
}Expand description
A spring that follows a moving target, stepped by elapsed time. Use it for
physics-driven motion, such as a dragged handle that springs home carrying
the velocity of the fling; for transitions between states prefer
MotionValue with an AnimationSpec::Spring.
Fields§
§value: f32§velocity: f32§stiffness: f32§damping: f32Implementations§
Source§impl SpringF32
impl SpringF32
Sourcepub const REST_EPSILON: f32 = 1.0e-3
pub const REST_EPSILON: f32 = 1.0e-3
Distance from the target below which SpringF32::is_settled reports
the spring at rest; the speed limit is ten times this per second.
pub fn new(value: f32) -> SpringF32
Sourcepub fn from_spec(value: f32, spec: SpringSpec) -> SpringF32
pub fn from_spec(value: f32, spec: SpringSpec) -> SpringF32
A spring at rest at value with the stiffness and damping of spec.
pub fn with_config(self, stiffness: f32, damping: f32) -> SpringF32
pub fn with_spec(self, spec: SpringSpec) -> SpringF32
pub fn with_velocity(self, velocity: f32) -> SpringF32
Sourcepub fn step(&mut self, target: f32, delta: f64) -> f32
pub fn step(&mut self, target: f32, delta: f64) -> f32
Advance the spring by delta seconds toward target and return the
new value. The step is exact, so large or uneven deltas neither
destabilize the spring nor change its path.
Sourcepub fn is_settled(&self, target: f32) -> bool
pub fn is_settled(&self, target: f32) -> bool
Whether the spring rests at target.
Trait Implementations§
impl Copy for SpringF32
impl StructuralPartialEq for SpringF32
Auto Trait Implementations§
impl Forget for SpringF32
impl Freeze for SpringF32
impl Move for SpringF32
impl RefUnwindSafe for SpringF32
impl Send for SpringF32
impl Sync for SpringF32
impl Unpin for SpringF32
impl UnsafeUnpin for SpringF32
impl UnwindSafe for SpringF32
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.