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,
}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: usizeThe width in pixels of the canvas
height: usizeThe height in pixels of the canvas
stride: usizeThe number of bytes between each line of pixels on the canvas
pixel_size: usizeThe number of bytes contained in each pixel
endianness: EndianThe endianness of the canvas
Implementations§
Source§impl<'a> Canvas<'a>
impl<'a> Canvas<'a>
Sourcepub fn new(
buffer: &'a mut [u8],
width: usize,
height: usize,
stride: usize,
endianness: Endian,
) -> Canvas<'a>
pub fn new( buffer: &'a mut [u8], width: usize, height: usize, stride: usize, endianness: Endian, ) -> Canvas<'a>
Creates a new canvas object
Sourcepub fn draw<D: Drawable>(&mut self, drawable: &D)
pub fn draw<D: Drawable>(&mut self, drawable: &D)
Draws an object that implements the Drawable trait to the buffer
Auto Trait Implementations§
impl<'a> Freeze for Canvas<'a>
impl<'a> RefUnwindSafe for Canvas<'a>
impl<'a> Send for Canvas<'a>
impl<'a> Sync for Canvas<'a>
impl<'a> Unpin for Canvas<'a>
impl<'a> !UnwindSafe for Canvas<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more