pub struct SpringSpec {
pub duration: f32,
pub bounce: f32,
}Expand description
A spring described the way designers tune one: how long it takes to settle, and how much it bounces.
duration is the period of the undamped spring in seconds, which is
close to how long the motion reads as taking. bounce runs from -1 to
1: 0 settles as fast as possible without overshooting, positive values
overshoot and oscillate, and negative values approach more gently.
Fields§
§duration: f32§bounce: f32Implementations§
Source§impl SpringSpec
impl SpringSpec
Sourcepub const SMOOTH: SpringSpec
pub const SMOOTH: SpringSpec
Settles without overshoot.
Sourcepub const SNAPPY: SpringSpec
pub const SNAPPY: SpringSpec
Quick, with a hint of overshoot.
Sourcepub const BOUNCY: SpringSpec
pub const BOUNCY: SpringSpec
Visibly overshoots and settles back.
Sourcepub const REST_THRESHOLD: f64 = 1.0e-3
pub const REST_THRESHOLD: f64 = 1.0e-3
How far from rest, as a share of the distance travelled, a spring counts as settled.
pub const fn new(duration: f32, bounce: f32) -> SpringSpec
Sourcepub fn from_physics(stiffness: f32, damping: f32) -> SpringSpec
pub fn from_physics(stiffness: f32, damping: f32) -> SpringSpec
The spec matching a unit-mass spring with this stiffness and
damping.
Sourcepub fn damping_ratio(self) -> f32
pub fn damping_ratio(self) -> f32
The damping ratio: below 1 oscillates, 1 is critically damped.
Sourcepub fn progress(self, elapsed: f64) -> f32
pub fn progress(self, elapsed: f64) -> f32
Progress from 0 to 1 after elapsed seconds of a spring released
from rest. Bouncy springs overshoot past 1 before settling.
Sourcepub fn settling_duration(self) -> f64
pub fn settling_duration(self) -> f64
Seconds until a spring released from rest stays within
SpringSpec::REST_THRESHOLD of its target.
Trait Implementations§
Source§impl Clone for SpringSpec
impl Clone for SpringSpec
Source§fn clone(&self) -> SpringSpec
fn clone(&self) -> SpringSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SpringSpec
Source§impl Debug for SpringSpec
impl Debug for SpringSpec
Source§impl Default for SpringSpec
impl Default for SpringSpec
Source§fn default() -> SpringSpec
fn default() -> SpringSpec
Source§impl From<SpringSpec> for AnimationSpec
impl From<SpringSpec> for AnimationSpec
Source§fn from(spring: SpringSpec) -> AnimationSpec
fn from(spring: SpringSpec) -> AnimationSpec
Source§impl PartialEq for SpringSpec
impl PartialEq for SpringSpec
impl StructuralPartialEq for SpringSpec
Auto Trait Implementations§
impl Forget for SpringSpec
impl Freeze for SpringSpec
impl Move for SpringSpec
impl RefUnwindSafe for SpringSpec
impl Send for SpringSpec
impl Sync for SpringSpec
impl Unpin for SpringSpec
impl UnsafeUnpin for SpringSpec
impl UnwindSafe for SpringSpec
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.