use crate::widget::{Color, Rect};
pub trait Renderer {
fn fill_rect(&mut self, rect: Rect, color: Color);
fn draw_text(&mut self, position: (i32, i32), text: &str, color: Color);
fn blend_rect(&mut self, rect: Rect, color: Color) {
self.fill_rect(rect, color);
}
fn draw_pixels(&mut self, position: (i32, i32), pixels: &[Color], width: u32, height: u32) {
for y in 0..height as i32 {
for x in 0..width as i32 {
let idx = (y as u32 * width + x as u32) as usize;
if let Some(&c) = pixels.get(idx) {
self.fill_rect(
Rect {
x: position.0 + x,
y: position.1 + y,
width: 1,
height: 1,
},
c,
);
}
}
}
}
}