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]]
|
[[package]]
|
||||||
name = "katabastird"
|
name = "katabastird"
|
||||||
version = "1.6.0"
|
version = "1.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui",
|
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
"rodio",
|
"rodio",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "katabastird"
|
name = "katabastird"
|
||||||
version = "1.6.0"
|
version = "1.6.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.61"
|
rust-version = "1.61"
|
||||||
|
|
||||||
|
@ -13,8 +13,7 @@ license-file = "LICENSE.md"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4", features = ["derive", "env", "unicode", "suggestions", "usage"] }
|
clap = { version = "4", features = ["derive", "env", "unicode", "suggestions", "usage"] }
|
||||||
eframe = { version = "0.19", features = ["wgpu"] }
|
eframe = { version = "0.19", features = ["wgpu"] }
|
||||||
egui = { version = "0.19", features = ["default"] }
|
|
||||||
egui_extras = "0.19"
|
egui_extras = "0.19"
|
||||||
# naga = { version = "0.10", features = ["spv-out", "wgsl-out", "wgsl-in"] }
|
|
||||||
rodio = { version = "0.16" }
|
rodio = { version = "0.16" }
|
||||||
|
# naga = { version = "0.10", features = ["spv-out", "wgsl-out", "wgsl-in"] }
|
||||||
# wgpu = { version = "0.14", features = ["naga", "spirv"] }
|
# wgpu = { version = "0.14", features = ["naga", "spirv"] }
|
||||||
|
|
|
@ -18,7 +18,7 @@ Options:
|
||||||
-V, --version Print version information
|
-V, --version Print version information
|
||||||
```
|
```
|
||||||
|
|
||||||

|

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