From 753a90430abbdf166a86b95c5c69aa1e68b3c412 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 7 Feb 2024 16:32:38 +0400 Subject: animation: Accept ms as u32 Less boilerplate elsewhere. --- src/animation.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/animation.rs') diff --git a/src/animation.rs b/src/animation.rs index bf0536e2..404c3d85 100644 --- a/src/animation.rs +++ b/src/animation.rs @@ -25,15 +25,17 @@ pub enum Curve { } impl Animation { - pub fn new(from: f64, to: f64, over: Duration) -> Self { + pub fn new(from: f64, to: f64, over_ms: u32) -> Self { // FIXME: ideally we shouldn't use current time here because animations started within the // same frame cycle should have the same start time to be synchronized. let now = get_monotonic_time(); + let duration = Duration::from_millis(u64::from(over_ms)) + .mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)); Self { from, to, - duration: over.mul_f64(ANIMATION_SLOWDOWN.load(Ordering::Relaxed)), + duration, start_time: now, current_time: now, curve: Curve::EaseOutCubic, -- cgit