Choose colors from official 35C3 range for colored noise.
This commit is contained in:
		@@ -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::<f64>());
 | 
			
		||||
        frame[y][x] = c;
 | 
			
		||||
 | 
			
		||||
        let mut buf = Vec::with_capacity(x_size * y_size * 3);
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user