pub struct Canvas { /* private fields */ }
Expand description
Canvas that can be drawn to and gets displayed on the screen
Implementations§
source§impl Canvas
impl Canvas
pub fn new(config: &CanvasConfiguration) -> Self
pub fn draw_to_buffer(&mut self, frame: &mut [u8])
source§impl Canvas
impl Canvas
sourcepub fn draw_shape(&mut self, shape: &(impl Drawable + Clone + 'static))
pub fn draw_shape(&mut self, shape: &(impl Drawable + Clone + 'static))
Draws an arbitrary shape to the canvas
See Drawable
for examples
sourcepub fn draw_square(
&mut self,
x: i16,
y: i16,
size: i16,
fill: Color,
border: Option<(Color, i16)>
)
pub fn draw_square( &mut self, x: i16, y: i16, size: i16, fill: Color, border: Option<(Color, i16)> )
Draws a square with the specified position, size, and color
§Examples
use waow::*;
struct App {}
impl Run for App {
fn start(&mut self, _canvas: &mut Canvas) {}
fn draw(&mut self, canvas: &mut Canvas, _input: &Input) {
canvas.draw_square(10, 10, 30, Color::from_rgba(0.0, 1.0, 0.5, 1.0), None);
}
}
use waow::*;
struct App {}
impl Run for App {
fn start(&mut self, _canvas: &mut Canvas) {}
fn draw(&mut self, canvas: &mut Canvas, _input: &Input) {
canvas.draw_square(
10,
10,
30,
Color::from_rgba(0.0, 1.0, 0.5, 1.0),
Some((Color::from_rgba(1.0, 1.0, 1.0, 1.0), 3)),
);
}
}
sourcepub fn draw_rect(
&mut self,
x: i16,
y: i16,
width: i16,
height: i16,
fill: Color,
border: Option<(Color, i16)>
)
pub fn draw_rect( &mut self, x: i16, y: i16, width: i16, height: i16, fill: Color, border: Option<(Color, i16)> )
Draws a rectangle with the specified position, width, height, and color
§Examples
use waow::*;
struct App {}
impl Run for App {
fn start(&mut self, _canvas: &mut Canvas) {}
fn draw(&mut self, canvas: &mut Canvas, _input: &Input) {
canvas.draw_rect(50, 10, 20, 50, Color::from_rgba(0.0, 0.5, 1.0, 1.0), None);
}
}
use waow::*;
struct App {}
impl Run for App {
fn start(&mut self, _canvas: &mut Canvas) {}
fn draw(&mut self, canvas: &mut Canvas, _input: &Input) {
canvas.draw_rect(
10, 10, 30, 50,
Color::from_rgba(0.0, 1.0, 0.5, 1.0),
Some((Color::from_rgba(1.0, 1.0, 1.0, 1.0), 3)),
);
}
}
sourcepub fn draw_image(&mut self, image: &Image)
pub fn draw_image(&mut self, image: &Image)
Draws an image object to the canvas
§Examples
use waow::*;
struct App {}
impl Run for App {
fn start(&mut self, _canvas: &mut Canvas) {}
fn draw(&mut self, canvas: &mut Canvas, _input: &Input) {
let img = shapes::Image::new(30, 30, 100, 100);
canvas.draw_image(&img);
}
}
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> 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