fn frac_draw_col<T: sdl2::render::RenderTarget>(canvas : &mut sdl2::render::Canvas<T>, col : i32, window_size : (u32, u32)) {
    let start_lambda = 3.5;
    let end_lambda = 4.0;

    let lambda = col as f64 * (end_lambda - start_lambda) / window_size.0 as f64 + start_lambda;
    let mut x : f64 = 0.5; // initial condition

    // draw up to this many points
    let mut points_drawn = 0;
    let max_points_drawn = 1000;

    // iterate this many times, maximum
    let iters : i32 = 1000000;
    for _i in 0 .. iters {
        x = x * lambda * (1.0 - x);

        /*
        // discard first few generations
        if _i < 1000 {
            continue;
        }
        */

        // compute the integer row position
        let row = ((1.0 - x) * window_size.1 as f64) as i32;

        // compute the color (few different algorithms)

        //let color = (i as f64 / iters as f64) * 256.0;
        //let color = points_drawn as f64 / max_points_drawn as f64;

        // compute based on number of iterations, clamped to 1.0
        let color = (_i as f64 * 0.001).min(1.0);

        let color_r = 0.0;
        let color_g = 1.0 - color;
        let color_b = color;
        //println!("color {} r {} g {} b {}", color, color_r, color_g, color_b);

        let color_r = (color_r * 256.0) as u8;
        let color_g = (color_g * 256.0) as u8;
        let color_b = (color_b * 256.0) as u8;
        canvas.set_draw_color(Color::RGB(color_r, color_g, color_b));

        // draw a point
        use sdl2::rect::Point;
        let p = Point::new(col, row);
        canvas.draw_point(p).unwrap();
        //println!("lambda {} col {} x {}", lambda, col, x);

        // stop drawing after we've plotted enough points
        points_drawn += 1;
        if points_drawn >= max_points_drawn {
            break;
        }
    }

    canvas.present();
}
// render one column of the fractcal
render one column of the fractcal
render one column of the fractcal
fn frac_draw_col<T: sdl2::render::RenderTarget>(canvas : &mut sdl2::render::Canvas<T>, col : i32, window_size : (u32, u32)) {
    let start_lambda = 3.5;
    let end_lambda = 4.0;
    let lambda = col as f64 * (end_lambda - start_lambda) / window_size.0 as f64 + start_lambda;
    let mut x : f64 = 0.5; // initial condition
    // draw up to this many points
    let mut points_drawn = 0;
    let max_points_drawn = 1000;
    // iterate this many times, maximum
    let iters : i32 = 1000000;
    for _i in 0 .. iters {
        x = x * lambda * (1.0 - x);
        /*
        // discard first few generations
        if _i < 1000 {
            continue;
        }
        */
        // compute the integer row position
        let row = ((1.0 - x) * window_size.1 as f64) as i32;
        // compute the color (few different algorithms)
        //let color = (i as f64 / iters as f64) * 256.0;
        //let color = points_drawn as f64 / max_points_drawn as f64;
        // compute based on number of iterations, clamped to 1.0
        let color = (_i as f64 * 0.001).min(1.0);
        let color_r = 0.0;
        let color_g = 1.0 - color;
        let color_b = color;
        //println!("color {} r {} g {} b {}", color, color_r, color_g, color_b);
        let color_r = (color_r * 256.0) as u8;
        let color_g = (color_g * 256.0) as u8;
        let color_b = (color_b * 256.0) as u8;
        canvas.set_draw_color(Color::RGB(color_r, color_g, color_b));
        // draw a point
        use sdl2::rect::Point;
        let p = Point::new(col, row);
        canvas.draw_point(p).unwrap();
        //println!("lambda {} col {} x {}", lambda, col, x);
        // stop drawing after we've plotted enough points
        points_drawn += 1;
        if points_drawn >= max_points_drawn {
            break;
        }
    }
    canvas.present();
}
fn frac_draw_col < T : sdl2 :: render :: RenderTarget > ( canvas : & mut sdl2 :: render :: Canvas < T > , col : i32 , window_size : ( u32 , u32 ) ) { let start_lambda = 3.5 ; let end_lambda = 4.0 ; let lambda = col as f64 * ( end_lambda - start_lambda ) / window_size . 0 as f64 + start_lambda ; let mut x : f64 = 0.5 ; // initial condition // draw up to this many points let mut points_drawn = 0 ; let max_points_drawn = 1000 ; // iterate this many times, maximum let iters : i32 = 1000000 ; for _i in 0 .. iters { x = x * lambda * ( 1.0 - x ) ; /*
        // discard first few generations
        if _i < 1000 {
            continue;
        }
        */ // compute the integer row position let row = ( ( 1.0 - x ) * window_size . 1 as f64 ) as i32 ; // compute the color (few different algorithms) //let color = (i as f64 / iters as f64) * 256.0; //let color = points_drawn as f64 / max_points_drawn as f64; // compute based on number of iterations, clamped to 1.0 let color = ( _i as f64 * 0.001 ) . min ( 1.0 ) ; let color_r = 0.0 ; let color_g = 1.0 - color ; let color_b = color ; //println!("color {} r {} g {} b {}", color, color_r, color_g, color_b); let color_r = ( color_r * 256.0 ) as u8 ; let color_g = ( color_g * 256.0 ) as u8 ; let color_b = ( color_b * 256.0 ) as u8 ; canvas . set_draw_color ( Color :: RGB ( color_r , color_g , color_b ) ) ; // draw a point use sdl2 :: rect :: Point ; let p = Point :: new ( col , row ) ; canvas . draw_point ( p ) . unwrap ( ) ; //println!("lambda {} col {} x {}", lambda, col, x); // stop drawing after we've plotted enough points points_drawn += 1 ; if points_drawn >= max_points_drawn { break ; } } canvas . present ( ) ; }
render one column of the fractcal
render one column of the fractcal
canvas
&mut sdl2::render::Canvas<T>
col
i32
window_size
(u32, u32)
canvas
&mut sdl2::render::Canvas<T>
col
i32
window_size
(u32, u32)