pub trait Drawable {
fn draw(&self, ctx: &mut Context, param: DrawParam) -> GameResult;
fn dimensions(&self, ctx: &mut Context) -> Option<Rect>;
fn set_blend_mode(&mut self, mode: Option<BlendMode>);
fn blend_mode(&self) -> Option<BlendMode>;
}
Expand description
All types that can be drawn on the screen implement the Drawable
trait.
Required Methods
sourcefn draw(&self, ctx: &mut Context, param: DrawParam) -> GameResult
fn draw(&self, ctx: &mut Context, param: DrawParam) -> GameResult
Draws the drawable onto the rendering target.
sourcefn dimensions(&self, ctx: &mut Context) -> Option<Rect>
fn dimensions(&self, ctx: &mut Context) -> Option<Rect>
Returns a bounding box in the form of a Rect
.
It returns Option
because some Drawable
s may have no bounding box
(an empty SpriteBatch
for example).
sourcefn set_blend_mode(&mut self, mode: Option<BlendMode>)
fn set_blend_mode(&mut self, mode: Option<BlendMode>)
Sets the blend mode to be used when drawing this drawable.
This overrides the general graphics::set_blend_mode()
.
If None
is set, defers to the blend mode set by
graphics::set_blend_mode()
.
sourcefn blend_mode(&self) -> Option<BlendMode>
fn blend_mode(&self) -> Option<BlendMode>
Gets the blend mode to be used when drawing this drawable.