summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-01-25 19:16:18 -0500
committerpommicket <pommicket@gmail.com>2023-01-25 19:16:18 -0500
commitbd391f7e52da94c9169643bed73427e49c238d9f (patch)
tree85644d83fe4cdeae449f0b0c5e9ec591c968e35d /src
parent68cf8354fc0c0bcfe9584b84e9ecae21980f0042 (diff)
error flash
Diffstat (limited to 'src')
-rw-r--r--src/fshader_post.glsl2
-rw-r--r--src/main.rs35
2 files changed, 23 insertions, 14 deletions
diff --git a/src/fshader_post.glsl b/src/fshader_post.glsl
index c540f0d..b3df51b 100644
--- a/src/fshader_post.glsl
+++ b/src/fshader_post.glsl
@@ -13,6 +13,7 @@ uniform int u_flash_icon;
#define ICON_PAUSE 3
#define ICON_REWIND 4
#define ICON_SCREENSHOT 5
+#define ICON_ERROR 6
bool play_icon(vec2 pos) {
vec2 a = abs(pos);
@@ -27,6 +28,7 @@ bool get_icon(vec2 pos) {
case 0: break;
case ICON_COPY:
case ICON_SCREENSHOT:
+ case ICON_ERROR:
icon = abs(pos.x) > u_aspect_ratio - 0.1 || abs(pos.y) > 0.9;
break;
case ICON_PLAY:
diff --git a/src/main.rs b/src/main.rs
index 1a7c726..bd3dc74 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,10 +1,9 @@
/*
@TODO:
-- flash error on bad string (see @TODO(error handling))
+- let user go back&forth through past sdfs using scenes.txt file
- RnToRn functions (& add back in RToR)
- also add PerComponent(Box<RToR>,Box<RToR>,Box<RToR>) in R3ToR3
- ProjectX, ProjectY, ProjectZ in R3ToR?
-- let user go back&forth through past sdfs using scenes.txt file
- documentation
- GenRandom integers (just use 0..u32::MAX and add a modulus)
- blender-style rendering the picture in multiple frames
@@ -60,6 +59,18 @@ enum Icon {
Pause = 3,
Rewind = 4,
Screenshot = 5,
+ Error = 6,
+}
+
+impl Icon {
+ fn color(self) -> ColorF32 {
+ match self {
+ Icon::None => ColorF32::BLACK,
+ Icon::Copy | Icon::Screenshot => ColorF32::GREEN,
+ Icon::Error => ColorF32::RED,
+ Icon::Play | Icon::Pause | Icon::Rewind => ColorF32::rgb(1.0, 0.5, 0.0),
+ }
+ }
}
#[derive(Clone)]
@@ -487,11 +498,7 @@ impl State {
}
fn flash(&mut self, icon: Icon) {
- self.flash = match icon {
- Icon::None => ColorF32::BLACK,
- Icon::Copy | Icon::Screenshot => ColorF32::GREEN,
- _ => ColorF32::rgb(1.0, 0.5, 0.0),
- };
+ self.flash = icon.color();
self.flash_icon = icon;
}
@@ -692,8 +699,8 @@ impl State {
match self.window.set_clipboard_text(&self.scene.export_string()) {
Ok(()) => {}
Err(e) => {
- // @TODO(error handling)
- eprintln!("couldn't copy text to clipboard: {e}")
+ eprintln!("couldn't copy text to clipboard: {e}");
+ self.flash(Icon::Error);
}
}
self.flash(Icon::Copy);
@@ -712,13 +719,13 @@ impl State {
self.load_scene(new_scene);
}
None => {
- // @TODO(error handling)
- eprintln!("bad string")
+ eprintln!("bad string");
+ self.flash(Icon::Error);
}
},
Err(e) => {
- // @TODO(error handling)
- eprintln!("couldn't get clipboard text: {e}")
+ eprintln!("couldn't get clipboard text: {e}");
+ self.flash(Icon::Error);
}
}
}
@@ -728,8 +735,8 @@ impl State {
match self.take_screenshot() {
Ok(()) => {}
Err(e) => {
- // @TODO(error handling)
eprintln!("screenshot fail: {e}");
+ self.flash(Icon::Error);
}
}
}