pub struct SpringConfig {
pub stiffness: f32,
pub damping: f32,
pub mass: f32,
pub epsilon: f32,
}Expand description
Configuration for a damped harmonic oscillator spring.
Use one of the named presets for common feels, or tune the parameters directly.
§Presets
| Preset | Stiffness | Damping | Feel |
|---|---|---|---|
gentle() | 60 | 14 | Slow, soft |
wobbly() | 180 | 12 | Bouncy, playful |
stiff() | 210 | 20 | Fast, firm |
slow() | 37 | 14 | Very slow, lazy |
snappy() | 300 | 30 | Near-instant |
§Example
use animato_spring::SpringConfig;
let cfg = SpringConfig::wobbly();
assert_eq!(cfg.stiffness, 180.0);Fields§
§stiffness: f32Restoring force. Higher = snappier. Default: 100.0.
damping: f32Resistance to motion. Higher = less bouncy. Default: 10.0.
mass: f32Mass of the simulated object. Default: 1.0.
epsilon: f32Settle threshold — spring is considered at rest when both
|position - target| < epsilon and |velocity| < epsilon. Default: 0.001.
Implementations§
Source§impl SpringConfig
impl SpringConfig
Trait Implementations§
Source§impl Clone for SpringConfig
impl Clone for SpringConfig
Source§fn clone(&self) -> SpringConfig
fn clone(&self) -> SpringConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SpringConfig
impl Debug for SpringConfig
Auto Trait Implementations§
impl Freeze for SpringConfig
impl RefUnwindSafe for SpringConfig
impl Send for SpringConfig
impl Sync for SpringConfig
impl Unpin for SpringConfig
impl UnsafeUnpin for SpringConfig
impl UnwindSafe for SpringConfig
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