pub fn display_chip8(ch8display: [[bool; 64]; 32], canvas: &mut Canvas<Window>, pixel_size: u32, white: Color, black: Color) -> Result<(), String>{
    for (y, row) in ch8display.iter().enumerate() {
        for (x, pix) in row.iter().enumerate() {
            canvas.set_draw_color({ // Set draw color
                if *pix { white } else { black }
            });
            canvas.fill_rect(Rect::new( // Draw the pixel
                x as i32 * pixel_size as i32,
                y as i32 * pixel_size as i32,
                pixel_size,
                pixel_size
            ))?;
        }
    }
    Ok(())
}
/// Displays a CHIP-8 onto a canvas (can overflow if pixel_size is too big)
Displays a CHIP-8 onto a canvas (can overflow if pixel_size is too big)
Displays a CHIP - 8 onto a canvas ( can overflow if pixel_size is too big )
pub fn display_chip8(ch8display: [[bool; 64]; 32], canvas: &mut Canvas<Window>, pixel_size: u32, white: Color, black: Color) -> Result<(), String>{
    for (y, row) in ch8display.iter().enumerate() {
        for (x, pix) in row.iter().enumerate() {
            canvas.set_draw_color({ // Set draw color
                if *pix { white } else { black }
            });
            canvas.fill_rect(Rect::new( // Draw the pixel
                x as i32 * pixel_size as i32,
                y as i32 * pixel_size as i32,
                pixel_size,
                pixel_size
            ))?;
        }
    }
    Ok(())
}
pub fn display_chip8 ( ch8display : [ [ bool ; 64 ] ; 32 ] , canvas : & mut Canvas < Window > , pixel_size : u32 , white : Color , black : Color ) -> Result < ( ) , String > { for ( y , row ) in ch8display . iter ( ) . enumerate ( ) { for ( x , pix ) in row . iter ( ) . enumerate ( ) { canvas . set_draw_color ( { // Set draw color if * pix { white } else { black } } ) ; canvas . fill_rect ( Rect :: new ( // Draw the pixel x as i32 * pixel_size as i32 , y as i32 * pixel_size as i32 , pixel_size , pixel_size ) ) ? ; } } Ok ( ( ) ) }
Displays a CHIP-8 onto a canvas (can overflow if pixel_size is too big)
Displays a CHIP - 8 onto a canvas ( can overflow if pixel_size is too big )
ch8display
[[bool; 64]; 32]
canvas
&mut Canvas<Window>
pixel_size
u32
white
Color
black
Color
ch8display
[[bool; 64]; 32]
canvas
&mut Canvas<Window>
pixel_size
u32
white
Color
black
Color