pub trait Renderer2D {
// Required methods
fn begin_frame(&mut self) -> Result<()>;
fn draw_sprite(&mut self, texture: &str, x: f64, y: f64) -> Result<()>;
fn draw_text(
&mut self,
text: &str,
x: f64,
y: f64,
size: f32,
color: [u8; 4],
) -> Result<()>;
fn draw_rect(
&mut self,
x: f64,
y: f64,
w: f64,
h: f64,
color: [u8; 4],
) -> Result<()>;
fn end_frame(&mut self) -> Result<()>;
// Provided methods
fn draw_sprite_frame(
&mut self,
texture: &str,
frame: Option<&str>,
x: f64,
y: f64,
) -> Result<()> { ... }
fn set_camera(&mut self, _x: f64, _y: f64, _zoom: f64) { ... }
fn reload_asset(&mut self, _path: &str) { ... }
fn clear_asset_cache(&mut self) { ... }
}Required Methods§
fn begin_frame(&mut self) -> Result<()>
fn draw_sprite(&mut self, texture: &str, x: f64, y: f64) -> Result<()>
fn draw_text( &mut self, text: &str, x: f64, y: f64, size: f32, color: [u8; 4], ) -> Result<()>
fn draw_rect( &mut self, x: f64, y: f64, w: f64, h: f64, color: [u8; 4], ) -> Result<()>
fn end_frame(&mut self) -> Result<()>
Provided Methods§
Sourcefn draw_sprite_frame(
&mut self,
texture: &str,
frame: Option<&str>,
x: f64,
y: f64,
) -> Result<()>
fn draw_sprite_frame( &mut self, texture: &str, frame: Option<&str>, x: f64, y: f64, ) -> Result<()>
Draw texture, optionally from one named atlas frame. The default
ignores the frame, so impls without atlas support stay correct.
fn set_camera(&mut self, _x: f64, _y: f64, _zoom: f64)
fn reload_asset(&mut self, _path: &str)
fn clear_asset_cache(&mut self)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".