Canvas

Struct Canvas 

Source
pub struct Canvas { /* private fields */ }
Expand description

A canvas for drawing images.

Implementations§

Source§

impl Canvas

Source

pub fn new(width: f32, height: f32) -> Self

Creates a new canvas with the given size.

Source

pub fn set_transform(&mut self, transform: &Transform)

Sets the transformation matrix for the canvas.

Source

pub fn draw_image(&mut self, image: &ImageRef, dst_rect: Rect)

Draws an image onto the canvas.

Source

pub fn copy_image(&mut self, image: &ImageRef, src_rect: Rect, dst_rect: Rect)

Copies an area of the canvas onto another area.

Source

pub fn fill(&mut self, path: &Path, color: &Color)

Fills a path with a given color.

Source

pub fn stroke(&mut self, path: &Path, style: &StrokeStyle)

Strokes a path with a given style.

Source

pub fn draw_text( &mut self, text: &str, size: f32, pos: &Point, font: &Font, color: &Color, )

Draws text onto the canvas.

Source

pub fn get_image(self) -> ImageRef

Converts the internal canvas into an image.

Trait Implementations§

Source§

impl Debug for Canvas

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Canvas

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Canvas

§

impl RefUnwindSafe for Canvas

§

impl Send for Canvas

§

impl Sync for Canvas

§

impl Unpin for Canvas

§

impl UnwindSafe for Canvas

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.