[−][src]Struct gravitas::Friction
a position with velocity that slows down due to drag.
This is good for objects that you fling—the scroll simulation uses this model in combination with a spring. It can also be used in combination with a constant velocity for infinite carousels, such as this one: Gravitas JavaScript Friction Example.
Methods
impl Friction
[src]
pub fn new(drag: f32) -> Friction
[src]
Create a new friction simulation with the given drag value. For scrolling interfaces where values are in pixels, a drag value of 0.001 feels quite good.
pub fn set(&mut self, x: f32, v: f32)
[src]
Set the initial (time = 0.0) position and velocity for the friction simulation.
pub fn time_for_position(&self, p: f32) -> f32
[src]
Return the time (in seconds) at which the friction simulation will reach the specified position. This value can be negative (which means the simulation would have reached that position if the velocity had been in the other direction) or not a number (NaN) which means the simulation will never reach that position.
This method is used by the scroll simulation to find out the exact time that the scroll position will go beyond the scroll extent (at which time the velocity is put into a spring simulation which bounces the scroll position back to the extent).
Trait Implementations
impl Simulation for Friction
[src]
fn x(&self, time: f32) -> f32
[src]
fn dx(&self, time: f32) -> f32
[src]
fn is_done(&self, time: f32) -> bool
[src]
impl Clone for Friction
[src]
impl Copy for Friction
[src]
Auto Trait Implementations
impl Send for Friction
impl Sync for Friction
impl Unpin for Friction
impl UnwindSafe for Friction
impl RefUnwindSafe for Friction
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,