about summary refs log tree commit diff
path: root/src/griph
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2025-02-25 19:21:59 -0600
committergennyble <gen@nyble.dev>2025-02-25 19:21:59 -0600
commit337b1faeeb414c5dad9a1b2cf80460a5e74eacbe (patch)
tree39c5d8e630672c4ffc51488556184c4fc3f189a4 /src/griph
parentf9df72033b29ed08811ac87d1ef22002eac4b992 (diff)
downloadawake-337b1faeeb414c5dad9a1b2cf80460a5e74eacbe.tar.gz
awake-337b1faeeb414c5dad9a1b2cf80460a5e74eacbe.zip
Make CPU graph better
Diffstat (limited to 'src/griph')
-rw-r--r--src/griph/mod.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/griph/mod.rs b/src/griph/mod.rs
index b1449f5..636ffd9 100644
--- a/src/griph/mod.rs
+++ b/src/griph/mod.rs
@@ -10,6 +10,7 @@ pub const DARK_PALETTE: &[u8] = &[
 	 48, 192,  48, // Secondary 2 Colour - Green
 	 96,  96, 224, // Primary Underfill - Light Blue
 	 48, 128,  48, // Secondary Underfill - Lesser Green
+	144, 144, 144  // Graphline Underfill - 16 * 9 gray
 ];
 
 const BACKGROUND: u8 = 0;
@@ -20,22 +21,40 @@ const LINE1: u8 = 4;
 const LINE2: u8 = 5;
 const LINE1_FILL: u8 = 6;
 const LINE2_FILL: u8 = 7;
+const LINE_FILL: u8 = 8;
 
 const WIDTH: usize = 256;
 const HEIGHT: usize = 160;
 const SIZE: usize = WIDTH * HEIGHT;
 
-pub fn make_1line(min: usize, max: usize, values: &[Option<usize>]) -> Gif {
+pub enum Style {
+	Line,
+	UnderfilledLine,
+}
+
+pub fn make_1line(min: usize, max: usize, values: &[Option<usize>], style: Style) -> Gif {
 	let range = max - min;
 	// this assumes a range of values that is >1 per pixel
 	let vpp = range / HEIGHT;
 
 	let mut raster = vec![0; SIZE];
+	let mut standard = Gif::new(WIDTH as u16, HEIGHT as u16);
+
 	draw_grid(&mut raster);
 	draw_line(&mut raster, values, vpp, LINE);
 
-	let mut standard = Gif::new(WIDTH as u16, HEIGHT as u16);
-	standard.set_palette(Some(DARK_PALETTE[0..12].try_into().unwrap()));
+	let plt = match style {
+		Style::Line => {
+			draw_line(&mut raster, values, vpp, LINE);
+			&DARK_PALETTE[0..12]
+		}
+		Style::UnderfilledLine => {
+			draw_line_underfill(&mut raster, values, vpp, LINE_FILL, LINE);
+			&DARK_PALETTE
+		}
+	};
+
+	standard.set_palette(Some(plt.try_into().unwrap()));
 	standard.push(
 		ImageBuilder::new(WIDTH as u16, HEIGHT as u16)
 			.build(raster)