pub fn draw<F>(config: GridConfig, draw_fn: F)
where
    F: Fn(&mut Grid, usize) -> (),
{
    let mut timing: [u128; TIMING_SIZE] = [4; TIMING_SIZE];
    let mut grid = Grid::new(config);
    print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
    for frame in 0.. {
        let now = std::time::Instant::now();

        draw_fn(&mut grid, frame);
        print!("{}[1;1H", 27 as char);
        grid.print();
        grid.clear();

        let spent = now.elapsed().as_millis();
        if grid.print_timing {
            timing[frame % TIMING_SIZE] = spent;
            print_average(frame, &timing);
        }
        print!("                         ");
        sleep_less(spent as usize, 1000 / grid.max_framerate);
    }
}
/// Our core animation function.
///
/// This kicks off an unending drawing, taking two arguments:
///
/// 1. a [`GridConfig`]
/// 2. a drawing closure, which will receive a fresh [`Grid`] (drawings are erased every frame),
///    and the current frame count.
Our core animation function.
This kicks off an unending drawing, taking two arguments.

1.
Our core animation function . This kicks off an unending drawing taking two arguments . 1 .
pub fn draw<F>(config: GridConfig, draw_fn: F)
where
    F: Fn(&mut Grid, usize) -> (),
{
    let mut timing: [u128; TIMING_SIZE] = [4; TIMING_SIZE];
    let mut grid = Grid::new(config);
    print!("{esc}[2J{esc}[1;1H", esc = 27 as char);
    for frame in 0.. {
        let now = std::time::Instant::now();
        draw_fn(&mut grid, frame);
        print!("{}[1;1H", 27 as char);
        grid.print();
        grid.clear();
        let spent = now.elapsed().as_millis();
        if grid.print_timing {
            timing[frame % TIMING_SIZE] = spent;
            print_average(frame, &timing);
        }
        print!("                         ");
        sleep_less(spent as usize, 1000 / grid.max_framerate);
    }
}
pub fn draw < F > ( config : GridConfig , draw_fn : F ) where F : Fn ( & mut Grid , usize ) -> ( ) , { let mut timing : [ u128 ; TIMING_SIZE ] = [ 4 ; TIMING_SIZE ] ; let mut grid = Grid :: new ( config ) ; print ! ( " " esc 27 as char ) ; for frame in 0 .. { let now = std :: time :: Instant :: now ( ) ; draw_fn ( & mut grid , frame ) ; print ! ( " " 27 as char ) ; grid . print ( ) ; grid . clear ( ) ; let spent = now . elapsed ( ) . as_millis ( ) ; if grid . print_timing { timing [ frame % TIMING_SIZE ] = spent ; print_average ( frame , & timing ) ; } print ! ( " " ) ; sleep_less ( spent as usize , 1000 / grid . max_framerate ) ; } }
Our core animation function.
Our core animation function .
config
GridConfig
draw_fn
F