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