Struct libbismuth::SpringParams
source · pub struct SpringParams { /* private fields */ }
Expand description
Physical parameters of a spring for SpringAnimation
.
Any spring can be described by three parameters: mass, stiffness and damping.
An undamped spring will produce an oscillatory motion which will go on forever.
The frequency and amplitude of the oscillations will be determined by the stiffness (how “strong” the spring is) and its mass (how much “inertia” it has).
If damping is larger than 0, the amplitude of that oscillating motion will exponientally decrease over time. If that damping is strong enough that the spring can’t complete a full oscillation, it’s called an overdamped spring.
If we the spring can oscillate, it’s called an underdamped spring.
The value between these two behaviors is called critical damping; a critically damped spring will comes to rest in the minimum possible time without producing oscillations.
The damping can be replaced by damping ratio, which produces the following springs:
- 0: an undamped spring.
- Between 0 and 1: an underdamped spring.
- 1: a critically damped spring.
- Larger than 1: an overdamped spring.
As such
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
source§impl SpringParams
impl SpringParams
sourcepub fn as_ptr(&self) -> *mut BisSpringParams
pub fn as_ptr(&self) -> *mut BisSpringParams
Return the inner pointer to the underlying C value.
sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut BisSpringParams) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut BisSpringParams) -> &Self
Borrows the underlying C value.
source§impl SpringParams
impl SpringParams
sourcepub fn new(damping_ratio: f64, mass: f64, stiffness: f64) -> SpringParams
pub fn new(damping_ratio: f64, mass: f64, stiffness: f64) -> SpringParams
Creates a new BisSpringParams
from @mass, @stiffness and @damping_ratio.
The damping value is calculated from @damping_ratio and the other two parameters.
- If @damping_ratio is 0, the spring will not be damped and will oscillate endlessly.
- If @damping_ratio is between 0 and 1, the spring is underdamped and will always overshoot.
- If @damping_ratio is 1, the spring is critically damped and will reach its resting position the quickest way possible.
- If @damping_ratio is larger than 1, the spring is overdamped and will reach its resting position faster than it can complete an oscillation.
SpringParams::new_full()
allows to pass a raw damping value instead.
§damping_ratio
the damping ratio of the spring
§mass
the mass of the spring
§stiffness
the stiffness of the spring
§Returns
the newly created spring parameters
sourcepub fn new_full(damping: f64, mass: f64, stiffness: f64) -> SpringParams
pub fn new_full(damping: f64, mass: f64, stiffness: f64) -> SpringParams
Creates a new BisSpringParams
from @mass, @stiffness and @damping.
See SpringParams::new()
for a simplified constructor using damping ratio
instead of @damping.
§damping
the damping of the spring
§mass
the mass of the spring
§stiffness
the stiffness of the spring
§Returns
the newly created spring parameters
sourcepub fn damping_ratio(&self) -> f64
pub fn damping_ratio(&self) -> f64
Trait Implementations§
source§impl Clone for SpringParams
impl Clone for SpringParams
source§impl Debug for SpringParams
impl Debug for SpringParams
source§impl From<SpringParams> for Value
impl From<SpringParams> for Value
source§fn from(s: SpringParams) -> Self
fn from(s: SpringParams) -> Self
source§impl HasParamSpec for SpringParams
impl HasParamSpec for SpringParams
type ParamSpec = ParamSpecBoxed
§type SetValue = SpringParams
type SetValue = SpringParams
type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, SpringParams>
fn param_spec_builder() -> Self::BuilderFn
source§impl Hash for SpringParams
impl Hash for SpringParams
source§impl Ord for SpringParams
impl Ord for SpringParams
source§fn cmp(&self, other: &SpringParams) -> Ordering
fn cmp(&self, other: &SpringParams) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for SpringParams
impl PartialEq for SpringParams
source§fn eq(&self, other: &SpringParams) -> bool
fn eq(&self, other: &SpringParams) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for SpringParams
impl PartialOrd for SpringParams
source§fn partial_cmp(&self, other: &SpringParams) -> Option<Ordering>
fn partial_cmp(&self, other: &SpringParams) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl StaticType for SpringParams
impl StaticType for SpringParams
source§fn static_type() -> Type
fn static_type() -> Type
Self
.