minor cleanup
This commit is contained in:
parent
4957f3f30b
commit
ec3f36779c
2 changed files with 8 additions and 6 deletions
src/timer
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue