pub trait Draw {
// Required method
fn draw(&self, canvas: &mut Canvas);
}
Expand description
Trait for drawing anything arbitrary onto a Canvas
.
§Examples
use drawing_stuff::canvas::{Canvas, Draw};
use drawing_stuff::color::RGBA;
pub struct Circle {
pub center: (isize, isize),
pub radius: u32,
pub solid: bool,
pub color: RGBA,
}
impl Draw for Circle {
fn draw(&self, canvas: &mut Canvas) {
match self.solid {
true => canvas.draw_circle_solid(self.center.0, self.center.1, self.radius, self.color),
false => canvas.draw_circle(self.center.0, self.center.1, self.radius, self.color),
}
}
}