Trait pix_engine::draw::Draw

source ·
pub trait Draw {
    fn draw(&self, s: &mut PixState) -> PixResult<()>;
}
Expand description

Trait for objects that can be drawn to the screen.

Required Methods§

Draw object to the current PixState canvas.

Errors

If the renderer fails to draw to the current render target, then an error is returned.

Example
fn on_update(&mut self, s: &mut PixState) -> PixResult<()> {
    let rect = rect![0, 0, 100, 100];
    // The following two lines are equivalent.
    s.rect(rect)?;
    rect.draw(s)?;
    Ok(())
}

Implementors§