diff --git a/src/bin/cnoise/main.rs b/src/bin/cnoise/main.rs index 1199404..0170ae7 100644 --- a/src/bin/cnoise/main.rs +++ b/src/bin/cnoise/main.rs @@ -32,9 +32,8 @@ fn main() -> std::io::Result<()> { let t_frame = 0.040; // s let delay = Duration::new(0, (1_000_000_000.0 * t_frame) as u32); - let colors = vec![Color::black(), Color::cyan(), Color::blue()]; - - // time to interpolate from one color to the next + let c0 = Color::new(0, 160, 95); + let c1 = Color::new(0, 138, 170); let mut rng = thread_rng(); @@ -44,7 +43,7 @@ fn main() -> std::io::Result<()> { loop { let x = rng.gen_range(0, x_size); let y = rng.gen_range(0, y_size); - let c = colors[rng.gen_range(0, colors.len())]; + let c = c0.interpolate(c1, rng.gen::()); frame[y][x] = c; let mut buf = Vec::with_capacity(x_size * y_size * 3); diff --git a/src/color.rs b/src/color.rs index 46188c1..94c76d3 100644 --- a/src/color.rs +++ b/src/color.rs @@ -3,6 +3,9 @@ pub struct Color(u8, u8, u8); #[allow(unused)] impl Color { + pub fn new(r: u8, g: u8, b: u8) -> Color { + Color(r, g, b) + } pub fn black() -> Color { Color(0, 0, 0) }