Struct andrew::Canvas

source ·
pub struct Canvas<'a> {
    pub buffer: &'a mut [u8],
    pub width: usize,
    pub height: usize,
    pub stride: usize,
    pub pixel_size: usize,
}
Expand description

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

Implementations

Creates a new canvas object

Draws an object that implements the Drawable trait to the buffer

Draws a pixel at the x and y coordinate

Clears the entire canvas buffer by zeroing it

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.