Skip to main content

Simulation

Trait Simulation 

Source
pub trait Simulation {
    // Required methods
    fn x(&self, time: f64) -> f64;
    fn dx(&self, time: f64) -> f64;
    fn is_done(&self, time: f64) -> bool;
}
Expand description

A ballistic motion curve over time, produced by ScrollPhysics::create_ballistic_simulation and driven by the consuming widget after a gesture release (fling decay, a spring-back, or any other closed-form or iterative curve).

time is in seconds from the simulation’s own start (0.0 at creation) — a scroll surface that ticks in milliseconds (frust’s scroll surfaces do) converts to seconds before calling in. An implementation carries its own Tolerance (typically threaded in at construction from ScrollPhysics::tolerance_for) rather than this trait supplying one.

Required Methods§

Source

fn x(&self, time: f64) -> f64

The position at time seconds.

Source

fn dx(&self, time: f64) -> f64

The velocity at time seconds.

Source

fn is_done(&self, time: f64) -> bool

Whether the simulation has settled (within its own tolerance) by time seconds.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§