pub trait Drawable {
// Required methods
fn draw(&self, canvas: &mut Canvas, param: impl Into<DrawParam>);
fn dimensions(&self, gfx: &impl Has<GraphicsContext>) -> Option<Rect>;
}
Expand description
All types that can be drawn onto a canvas implement the Drawable
trait.
Required Methods§
sourcefn draw(&self, canvas: &mut Canvas, param: impl Into<DrawParam>)
fn draw(&self, canvas: &mut Canvas, param: impl Into<DrawParam>)
Draws the drawable onto the canvas.
sourcefn dimensions(&self, gfx: &impl Has<GraphicsContext>) -> Option<Rect>
fn dimensions(&self, gfx: &impl Has<GraphicsContext>) -> Option<Rect>
Returns a bounding box in the form of a Rect
.
It returns Option
because some Drawable
s may have no bounding box,
namely InstanceArray
(as there is no true bounds for the instances given the instanced mesh can differ).