From ec3f36779ccbf1330c49b15ed0fabfca16c3bb6a Mon Sep 17 00:00:00 2001
From: Joe Ardent <code@ardent.nebcorp.com>
Date: Sat, 29 Oct 2022 15:53:49 -0700
Subject: [PATCH] minor cleanup

---
 src/timer/eframe_app.rs | 8 +++++---
 src/timer/mod.rs        | 6 +++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/timer/eframe_app.rs b/src/timer/eframe_app.rs
index 183942d..2a1e486 100644
--- a/src/timer/eframe_app.rs
+++ b/src/timer/eframe_app.rs
@@ -9,15 +9,16 @@ use eframe::{
 use super::{state::*, Timer};
 use crate::{MAX_REPAINT, MIN_REPAINT};
 
-const STARTING_COLOR: &[f32; 3] = &[10.0, 4.0, 4.0];
-const UNIT_COLOR: &[f32; 3] = &[0.986, 0.154, 0.055];
+const STARTING_COLOR: &[f32; 3] = &[10.0, 4.0, 14.0];
+const UNIT_COLOR: &[f32; 3] = &[0.986, 0.154, 0.055]; // [160, 125, 9].normalize()
 
 impl eframe::App for Timer {
     fn update(&mut self, ctx: &egui::Context, frame: &mut EFrame) {
         ctx.request_repaint_after(MAX_REPAINT);
         let height = ctx.input().screen_rect().height();
 
-        let color = get_color(self.done);
+        let t = self.done.powi(3);
+        let color = get_color(t);
 
         egui::CentralPanel::default()
             .frame(Frame::none().fill(color))
@@ -51,5 +52,6 @@ fn get_color(t: f32) -> Color32 {
         (sg + (mag * ug).round()) as u8,
         (sb + (mag * ub).round()) as u8,
     );
+    // when t is 1.0, then the final color is roughly 170, 29, 23.
     Color32::from_rgb(r, g, b)
 }
diff --git a/src/timer/mod.rs b/src/timer/mod.rs
index b74dd99..3db7e74 100644
--- a/src/timer/mod.rs
+++ b/src/timer/mod.rs
@@ -17,7 +17,7 @@ pub enum CountDirection {
     Down,
 }
 
-#[derive(Debug, Clone)]
+#[derive(Clone)]
 pub struct Timer {
     direction: CountDirection,
     duration: Duration,
@@ -84,6 +84,7 @@ impl Timer {
 
             timer.state = TimerState::Running(cs);
         }
+
         timer
     }
 
@@ -125,8 +126,7 @@ impl Timer {
             return;
         }
 
-        self.done =
-            (1.0 - (remaining.as_millis() as f32 / self.duration.as_millis() as f32)).powi(3);
+        self.done = 1.0 - (remaining.as_secs_f32() / self.duration.as_secs_f32());
 
         let (sender, rx) = channel();
         {