pub trait Drawer {
// Required methods
fn draw<T: Drawable>(&mut self, drawable: &T);
fn get_center(&self) -> Vector2<f32>;
fn get_sizes(&self) -> Vector2<f32>;
fn projection(&self) -> &Matrix4<f32>;
// Provided methods
fn draw_with_context_mut<T: DrawableMut>(
&mut self,
drawable: &mut T,
context: &mut Context<'_>,
) { ... }
fn draw_mut<T: DrawableMut>(&mut self, drawable: &mut T) { ... }
fn draw_with_context<T: Drawable>(
&mut self,
drawable: &mut T,
context: &mut Context<'_>,
) { ... }
}Expand description
Trait defining a drawer
Required Methods§
Sourcefn draw<T: Drawable>(&mut self, drawable: &T)
fn draw<T: Drawable>(&mut self, drawable: &T)
Function that draw on itself needed by everything that can be draw.
fn get_center(&self) -> Vector2<f32>
fn get_sizes(&self) -> Vector2<f32>
fn projection(&self) -> &Matrix4<f32>
Provided Methods§
Sourcefn draw_with_context_mut<T: DrawableMut>(
&mut self,
drawable: &mut T,
context: &mut Context<'_>,
)
fn draw_with_context_mut<T: DrawableMut>( &mut self, drawable: &mut T, context: &mut Context<'_>, )
Draw with context fonction if you want to define you own fonction
Sourcefn draw_mut<T: DrawableMut>(&mut self, drawable: &mut T)
fn draw_mut<T: DrawableMut>(&mut self, drawable: &mut T)
Function that can draw a DrawableMut.
Examples found in repository?
examples/batch.rs (line 37)
15fn main() -> Result<(), Box<Error>> {
16 let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
17
18 let texture = Rc::new(Texture::from_path("examples/texture/Dirt.png").unwrap());
19 let mut batch = SpriteBatch::from(&texture);
20 for i in 0..1_000_000 {
21 let mut data = SpriteData::new(Vector::new(i as f32 * 1.0, i as f32 * 10.0));
22 data.set_texture_raw([Vector::new(0.0, 0.0), Vector::new(1.0, 1.0)]);
23 batch.push_sprite(data);
24 }
25
26 let event_handler = EventHandler::new(&window);
27
28 window.set_clear_color(Color::new(0.45, 0.0, 1.0));
29 window.enable_cursor();
30 window.poll(None);
31 while window.is_open() {
32 window.poll_events();
33 for event in event_handler.fetch() {
34 event_process(event, &mut window, &mut batch);
35 }
36 window.clear();
37 window.draw_mut(&mut batch);
38 window.display();
39 }
40
41 Ok(())
42}Sourcefn draw_with_context<T: Drawable>(
&mut self,
drawable: &mut T,
context: &mut Context<'_>,
)
fn draw_with_context<T: Drawable>( &mut self, drawable: &mut T, context: &mut Context<'_>, )
Draw with context a Drawable.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".