# [−][src]Struct andrew::Canvas

    pub struct Canvas<'a> {
        pub buffer: &'a mut [u8],
        pub width: usize,
        pub height: usize,
        pub stride: usize,
        pub pixel_size: usize,
        pub endianness: Endian,
    }

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

`endianness: Endian`

The endianness of the canvas

## Methods

### `impl<'a> Canvas<'a>`[src]

#### `pub fn new(
buffer: &'a mut [u8],
width: usize,
height: usize,
stride: usize,
endianness: Endian
) -> Canvas<'a>`[src]

Creates a new canvas object

#### `pub fn draw<D: Drawable>(&mut self, drawable: &D)`[src]

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]

Draws a pixel at the x and y coordinate

#### `pub fn clear(&mut self)`[src]

Clears the entire canvas buffer by zeroing it

## Auto Trait Implementations

### `impl<'a> Send for Canvas<'a>`

### `impl<'a> Unpin for Canvas<'a>`

### `impl<'a> Sync for Canvas<'a>`

### `impl<'a> !UnwindSafe for Canvas<'a>`

### `impl<'a> RefUnwindSafe for Canvas<'a>`

## Blanket Implementations

### `impl<T, U> Into<U> for T where
U: From<T>,` [src]

#### `fn into(self) -> U`[src]

Performs the conversion.

### `impl<T> From<T> for T`[src]

#### `fn from(t: T) -> T`[src]

Performs the conversion.

### `impl<T, U> TryFrom<U> for T where
U: Into<T>,` [src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

Performs the conversion.

### `impl<T, U> TryInto<U> for T where
U: TryFrom<T>,` [src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

Performs the conversion.

### `impl<T> BorrowMut<T> for T where
T: ?Sized,` [src]

#### `fn borrow_mut(&mut self) -> &mut T`[src]

Mutably borrows from an owned value. Read more

### `impl<T> Borrow<T> for T where
T: ?Sized,` [src]

#### `fn borrow(&self) -> &T`[src]

Immutably borrows from an owned value. Read more

### `impl<T> Any for T where
T: 'static + ?Sized,` [src]

#### `fn type_id(&self) -> TypeId`[src]

Gets the `TypeId` of `self`. Read more

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)