fn draw_fb(gop: &mut GraphicsOutput) {
    let mi = gop.current_mode_info();
    let stride = mi.stride();
    let (width, height) = mi.resolution();

    let mut fb = gop.frame_buffer();

    type PixelWriter = unsafe fn(&mut FrameBuffer, usize, [u8; 3]);
    fn write_pixel_rgb(fb: &mut FrameBuffer, pixel_base: usize, rgb: [u8; 3]) {
        unsafe {
            fb.write_value(pixel_base, rgb);
        }
    }
    fn write_pixel_bgr(fb: &mut FrameBuffer, pixel_base: usize, rgb: [u8; 3]) {
        unsafe {
            fb.write_value(pixel_base, [rgb[2], rgb[1], rgb[0]]);
        }
    }
    let write_pixel: PixelWriter = match mi.pixel_format() {
        PixelFormat::Rgb => write_pixel_rgb,
        PixelFormat::Bgr => write_pixel_bgr,
        _ => {
            info!("This pixel format is not supported by the drawing demo");
            return;
        }
    };

    let mut fill_rectangle = |(x1, y1), (x2, y2), color| {
        assert!((x1 < width) && (x2 < width), "Bad X coordinate");
        assert!((y1 < height) && (y2 < height), "Bad Y coordinate");
        for row in y1..y2 {
            for column in x1..x2 {
                unsafe {
                    let pixel_index = (row * stride) + column;
                    let pixel_base = 4 * pixel_index;
                    write_pixel(&mut fb, pixel_base, color);
                }
            }
        }
    };

    fill_rectangle((50, 30), (150, 600), [250, 128, 64]);
    fill_rectangle((400, 120), (750, 450), [16, 128, 255]);
}
// Draw directly to the frame buffer.
Draw directly to the frame buffer.
Draw directly to the frame buffer .
fn draw_fb(gop: &mut GraphicsOutput) {
    let mi = gop.current_mode_info();
    let stride = mi.stride();
    let (width, height) = mi.resolution();
    let mut fb = gop.frame_buffer();
    type PixelWriter = unsafe fn(&mut FrameBuffer, usize, [u8; 3]);
    fn write_pixel_rgb(fb: &mut FrameBuffer, pixel_base: usize, rgb: [u8; 3]) {
        unsafe {
            fb.write_value(pixel_base, rgb);
        }
    }
    fn write_pixel_bgr(fb: &mut FrameBuffer, pixel_base: usize, rgb: [u8; 3]) {
        unsafe {
            fb.write_value(pixel_base, [rgb[2], rgb[1], rgb[0]]);
        }
    }
    let write_pixel: PixelWriter = match mi.pixel_format() {
        PixelFormat::Rgb => write_pixel_rgb,
        PixelFormat::Bgr => write_pixel_bgr,
        _ => {
            info!("This pixel format is not supported by the drawing demo");
            return;
        }
    };
    let mut fill_rectangle = |(x1, y1), (x2, y2), color| {
        assert!((x1 < width) && (x2 < width), "Bad X coordinate");
        assert!((y1 < height) && (y2 < height), "Bad Y coordinate");
        for row in y1..y2 {
            for column in x1..x2 {
                unsafe {
                    let pixel_index = (row * stride) + column;
                    let pixel_base = 4 * pixel_index;
                    write_pixel(&mut fb, pixel_base, color);
                }
            }
        }
    };
    fill_rectangle((50, 30), (150, 600), [250, 128, 64]);
    fill_rectangle((400, 120), (750, 450), [16, 128, 255]);
}
fn draw_fb ( gop : & mut GraphicsOutput ) { let mi = gop . current_mode_info ( ) ; let stride = mi . stride ( ) ; let ( width , height ) = mi . resolution ( ) ; let mut fb = gop . frame_buffer ( ) ; type PixelWriter = unsafe fn ( & mut FrameBuffer , usize , [ u8 ; 3 ] ) ; fn write_pixel_rgb ( fb : & mut FrameBuffer , pixel_base : usize , rgb : [ u8 ; 3 ] ) { unsafe { fb . write_value ( pixel_base , rgb ) ; } } fn write_pixel_bgr ( fb : & mut FrameBuffer , pixel_base : usize , rgb : [ u8 ; 3 ] ) { unsafe { fb . write_value ( pixel_base , [ rgb [ 2 ] , rgb [ 1 ] , rgb [ 0 ] ] ) ; } } let write_pixel : PixelWriter = match mi . pixel_format ( ) { PixelFormat :: Rgb => write_pixel_rgb , PixelFormat :: Bgr => write_pixel_bgr , _ => { info ! ( " " ) ; return ; } } ; let mut fill_rectangle = | ( x1 , y1 ) , ( x2 , y2 ) , color | { assert ! ( ( x1 width ) ( x2 width ) " " ) ; assert ! ( ( y1 height ) ( y2 height ) " " ) ; for row in y1 .. y2 { for column in x1 .. x2 { unsafe { let pixel_index = ( row * stride ) + column ; let pixel_base = 4 * pixel_index ; write_pixel ( & mut fb , pixel_base , color ) ; } } } } ; fill_rectangle ( ( 50 , 30 ) , ( 150 , 600 ) , [ 250 , 128 , 64 ] ) ; fill_rectangle ( ( 400 , 120 ) , ( 750 , 450 ) , [ 16 , 128 , 255 ] ) ; }
Draw directly to the frame buffer.
Draw directly to the frame buffer .
gop
&mut GraphicsOutput