Struct andrew::Canvas [−][src]
pub struct Canvas<'a> {
pub buffer: &'a mut [u8],
pub width: usize,
pub height: usize,
pub stride: usize,
pub pixel_size: usize,
}The canvas object acts as a wrapper around a buffer, providing information and functions for drawing
Fields
buffer: &'a mut [u8]
A buffer for the canvas to draw to
width: usize
The width in pixels of the canvas
height: usize
The height in pixels of the canvas
stride: usize
The number of bytes between each line of pixels on the canvas
pixel_size: usize
The number of bytes contained in each pixel
Methods
impl<'a> Canvas<'a>[src]
impl<'a> Canvas<'a>pub fn new(
buffer: &'a mut [u8],
width: usize,
height: usize,
stride: usize
) -> Canvas<'a>[src]
pub fn new(
buffer: &'a mut [u8],
width: usize,
height: usize,
stride: usize
) -> Canvas<'a>Creates a new canvas object
pub fn draw<D: Drawable>(&mut self, drawable: &D)[src]
pub fn draw<D: Drawable>(&mut self, drawable: &D)Draws an object that implements the Drawable trait to the buffer
pub fn draw_point(&mut self, x: usize, y: usize, color: [u8; 4])[src]
pub fn draw_point(&mut self, x: usize, y: usize, color: [u8; 4])Draws a pixel at the x and y coordinate
pub fn clear(&mut self)[src]
pub fn clear(&mut self)Clears the entire canvas buffer by zeroing it