pub struct VelocityTracker { /* private fields */ }Expand description
Release velocity of a drag along one axis, from a fixed number of recent
pointer samples (no allocation). Used by the chart’s kinetic panning and
by ferrochart-plot.
use ferrochart_core::interaction::VelocityTracker;
let mut v = VelocityTracker::default();
for i in 0..10 {
v.record(f64::from(i) * 10.0, i as f32 * 5.0); // 5 px every 10 ms
}
assert!((v.release_velocity(95.0) - 0.5).abs() < 1e-9);
assert_eq!(v.release_velocity(200.0), 0.0); // paused before releaseImplementations§
Source§impl VelocityTracker
impl VelocityTracker
Sourcepub fn release_velocity(&self, now: f64) -> f64
pub fn release_velocity(&self, now: f64) -> f64
Release velocity in px/ms from the samples of the last 100 ms; 0 if
the pointer paused for more than 50 ms before now.
Trait Implementations§
Source§impl Clone for VelocityTracker
impl Clone for VelocityTracker
impl Copy for VelocityTracker
Source§impl Debug for VelocityTracker
impl Debug for VelocityTracker
Auto Trait Implementations§
impl Forget for VelocityTracker
impl Freeze for VelocityTracker
impl Move for VelocityTracker
impl RefUnwindSafe for VelocityTracker
impl Send for VelocityTracker
impl Sync for VelocityTracker
impl Unpin for VelocityTracker
impl UnsafeUnpin for VelocityTracker
impl UnwindSafe for VelocityTracker
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