iced-yoda/examples/ggez/renderer.rs

42 lines
919 B
Rust
Raw Normal View History

mod button;
mod checkbox;
mod radio;
mod slider;
2019-07-21 12:35:25 +02:00
mod text;
use ggez::graphics::{self, spritebatch::SpriteBatch, Image};
2019-07-21 12:35:25 +02:00
use ggez::Context;
pub struct Renderer<'a> {
pub context: &'a mut Context,
pub sprites: SpriteBatch,
pub spritesheet: Image,
2019-07-21 12:35:25 +02:00
}
impl Renderer<'_> {
pub fn new(context: &mut Context, spritesheet: Image) -> Renderer {
Renderer {
context,
sprites: SpriteBatch::new(spritesheet.clone()),
spritesheet,
}
}
2019-07-21 12:35:25 +02:00
pub fn flush(&mut self) {
graphics::draw(
self.context,
&self.sprites,
graphics::DrawParam::default(),
)
.expect("Draw sprites");
2019-07-21 12:35:25 +02:00
graphics::draw_queued_text(
self.context,
graphics::DrawParam::default(),
Default::default(),
graphics::FilterMode::Linear,
)
.expect("Draw text");
}
}