make the background get redder as it progresses
This commit is contained in:
parent
7a8b950fbd
commit
7a8097d035
9 changed files with 66 additions and 28 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -1162,11 +1162,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "katabastird"
|
||||
version = "1.6.0"
|
||||
version = "1.6.1"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"eframe",
|
||||
"egui",
|
||||
"egui_extras",
|
||||
"rodio",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "katabastird"
|
||||
version = "1.6.0"
|
||||
version = "1.6.1"
|
||||
edition = "2021"
|
||||
rust-version = "1.61"
|
||||
|
||||
|
@ -13,8 +13,7 @@ license-file = "LICENSE.md"
|
|||
[dependencies]
|
||||
clap = { version = "4", features = ["derive", "env", "unicode", "suggestions", "usage"] }
|
||||
eframe = { version = "0.19", features = ["wgpu"] }
|
||||
egui = { version = "0.19", features = ["default"] }
|
||||
egui_extras = "0.19"
|
||||
# naga = { version = "0.10", features = ["spv-out", "wgsl-out", "wgsl-in"] }
|
||||
rodio = { version = "0.16" }
|
||||
# naga = { version = "0.10", features = ["spv-out", "wgsl-out", "wgsl-in"] }
|
||||
# wgpu = { version = "0.14", features = ["naga", "spirv"] }
|
||||
|
|
|
@ -18,7 +18,7 @@ Options:
|
|||
-V, --version Print version information
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
"[Katabasis](https://en.wikipedia.org/wiki/Katabasis)" is the descent into the Underworld.
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.6
|
||||
1.61
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use egui::Vec2;
|
||||
use eframe::egui::Vec2;
|
||||
use katabastird::timer::Timer;
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,28 +1,61 @@
|
|||
use std::time::Instant;
|
||||
|
||||
use eframe::{
|
||||
egui::{self, Frame},
|
||||
epaint::Color32,
|
||||
Frame as 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];
|
||||
|
||||
impl eframe::App for Timer {
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut EFrame) {
|
||||
ctx.request_repaint_after(MAX_REPAINT);
|
||||
let height = ctx.input().screen_rect().height();
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
match self.state {
|
||||
TimerState::Unstarted => self.unstarted(ui, height),
|
||||
TimerState::Running(cs) => {
|
||||
let dur = Instant::now() - cs.updated;
|
||||
let dur = MIN_REPAINT.saturating_sub(dur);
|
||||
ctx.request_repaint_after(dur);
|
||||
self.running(ui, height, cs);
|
||||
|
||||
let color = get_color(self.done);
|
||||
|
||||
egui::CentralPanel::default()
|
||||
.frame(Frame::none().fill(color))
|
||||
.show(ctx, |ui| {
|
||||
match self.state {
|
||||
TimerState::Unstarted => self.unstarted(ui, height),
|
||||
TimerState::Running(cs) => {
|
||||
let dur = Instant::now() - cs.updated;
|
||||
let dur = MIN_REPAINT.saturating_sub(dur);
|
||||
ctx.request_repaint_after(dur);
|
||||
self.running(ui, height, cs);
|
||||
}
|
||||
TimerState::Paused(cs) => self.paused(ui, height, cs),
|
||||
TimerState::Finished => self.finished(ui, height),
|
||||
}
|
||||
TimerState::Paused(cs) => self.paused(ui, height, cs),
|
||||
TimerState::Finished => self.finished(ui, height),
|
||||
}
|
||||
// check for quit key
|
||||
if ui.input().key_pressed(egui::Key::Q) || ui.input().key_pressed(egui::Key::Escape) {
|
||||
frame.close();
|
||||
}
|
||||
});
|
||||
// check for quit key
|
||||
if ui.input().key_pressed(egui::Key::Q) || ui.input().key_pressed(egui::Key::Escape)
|
||||
{
|
||||
frame.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn get_color(t: f32) -> Color32 {
|
||||
let sr = STARTING_COLOR[0];
|
||||
let sg = STARTING_COLOR[1];
|
||||
let sb = STARTING_COLOR[2];
|
||||
|
||||
let ur = UNIT_COLOR[0];
|
||||
let ug = UNIT_COLOR[1];
|
||||
let ub = UNIT_COLOR[2];
|
||||
|
||||
let mag = t * 162.0;
|
||||
let (r, g, b) = (
|
||||
(sr + (mag * ur).round()) as u8,
|
||||
(sg + (mag * ug).round()) as u8,
|
||||
(sb + (mag * ub).round()) as u8,
|
||||
);
|
||||
Color32::from_rgb(r, g, b)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{sync::mpsc::Sender, time::Duration};
|
||||
|
||||
use egui::{Color32, Direction, Layout, RichText, Ui};
|
||||
use eframe::egui::{Color32, Direction, Layout, RichText, Ui};
|
||||
use egui_extras::{Size, StripBuilder};
|
||||
|
||||
use super::state::NextTimerState;
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::sync::mpsc::channel;
|
|||
use std::time::{Duration, Instant};
|
||||
|
||||
use clap::Parser;
|
||||
use egui::{Color32, FontId, RichText, Ui};
|
||||
use eframe::egui::{self, Color32, FontId, RichText, Ui};
|
||||
|
||||
use crate::{cli::Cli, util::*, AIRHORN, DIGIT_FACTOR, MAX_REPAINT, PREDATOR_FONT, TEXT_FACTOR};
|
||||
|
||||
|
@ -25,6 +25,7 @@ pub struct Timer {
|
|||
state: TimerState,
|
||||
tstart: Instant, // so we can blink
|
||||
alarm: Option<Vec<u8>>,
|
||||
done: f32,
|
||||
}
|
||||
|
||||
impl Timer {
|
||||
|
@ -74,6 +75,7 @@ impl Timer {
|
|||
state: TimerState::Unstarted,
|
||||
tstart: updated,
|
||||
alarm,
|
||||
done: 0.0,
|
||||
};
|
||||
if cli.running {
|
||||
let cs = ChronoState {
|
||||
|
@ -92,6 +94,7 @@ impl Timer {
|
|||
.font(FontId::monospace(tsize))
|
||||
.color(Color32::WHITE)
|
||||
.background_color(Color32::LIGHT_GREEN);
|
||||
self.done = 0.0;
|
||||
|
||||
let (sender, rx) = channel();
|
||||
one_row(ui, &[(start, NextTimerState::Running)], sender);
|
||||
|
@ -119,9 +122,13 @@ impl Timer {
|
|||
std::thread::spawn(move || alarm(alarm_sound));
|
||||
}
|
||||
self.state = TimerState::Finished;
|
||||
self.done = 1.0;
|
||||
return;
|
||||
}
|
||||
|
||||
self.done =
|
||||
(1.0 - (remaining.as_millis() as f32) / (self.duration.as_millis() as f32)).powf(3.1);
|
||||
|
||||
let (sender, rx) = channel();
|
||||
{
|
||||
// if we're counting up, do the right thing
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{io::Cursor, time::Duration};
|
||||
|
||||
use egui::{Color32, Direction, FontId, Layout, RichText};
|
||||
use eframe::egui::{Color32, Direction, FontId, Layout, RichText};
|
||||
use egui_extras::{Size, Strip};
|
||||
use rodio::{source::Source, Decoder, OutputStream};
|
||||
|
||||
|
|
Loading…
Reference in a new issue