CanvasWidget

Struct CanvasWidget 

Source
pub struct CanvasWidget { /* private fields */ }
Expand description
§Description

A widget for drawing on a 2d canvas

Currently there is minimal functionality for this, it might be expanded upon in the future

Implementations§

Source§

impl CanvasWidget

Source

pub fn new(x: i32, y: i32, width: u32, height: u32) -> Rc<RefCell<Self>>

§Description

Creates a new canvas widget

§Arguments
  • x: i32 - The x position of the widget
  • y: i32 - The y position of the widget
  • width: u32 - The width of the widget
  • height: u32 - The height of the widget
Source

pub fn get_width(&self) -> u32

§Description

Retrieves the width of the canvas

§Returns

u32 - The width of the canvas

Source

pub fn get_height(&self) -> u32

§Description

Retrieves the height of the display buffer

§Returns

u32 - The height of the display buffer

Source

pub fn set_char(&mut self, c: char, x: i32, y: i32)

§Description

Draws a character to the canvas

If the coordinates are out of the bounds of the canvas it ignores the write

§Arguments
  • c: char - The character to insert
  • x: u32 - The x position to write to
  • y: u32 - The y position to write to
Source

pub fn clear(&mut self, c: char)

§Description

Clears the canvas to a specified character

§Arguments
  • c: char - The character to clear with

Trait Implementations§

Source§

impl Widget for CanvasWidget

Source§

fn draw( &mut self, positioning_algorithm: &Box<dyn PositioningAlgorithm>, display_buffer: &mut DisplayBuffer, )

Description Read more
Source§

fn get_bounding_box(&self) -> BoundingBox

Description Read more

Auto Trait Implementations§

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.