From 005292adfc63bb62dc8fd3528d6c93f1476c7a4f Mon Sep 17 00:00:00 2001 From: devdesk Date: Tue, 20 Feb 2024 21:02:14 +0200 Subject: [PATCH] tweaking the color --- examples/live.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/live.rs b/examples/live.rs index dfa374c..02e9e59 100644 --- a/examples/live.rs +++ b/examples/live.rs @@ -119,13 +119,15 @@ fn main() -> anyhow::Result<()> { } else { pixel = pixel_to_celcius(pixel); let cutoff = args.red_cutoff.unwrap(); - let r = if pixel > (256.0 * cutoff) as u16 { - 255 + let (r, g, b) = if pixel > (256.0 * cutoff) as u16 { + let p = pixel - (256.0 * cutoff) as u16; + let p = (p / 256).max(127); + ((128 + p) as u8, 0, 0) } else { - 0 + let g = frame[i * 2]; + let b = frame[i * 2 + 1]; + (0, g, b) }; - let g = frame[i * 2]; - let b = frame[i * 2 + 1]; let out_i = ((HEIGHT - 1 - y) + (WIDTH - 1 - x) * HEIGHT) * 4; swapped[out_i..out_i + 4].copy_from_slice(&[0, r, g, b]); }