use kurbo::BezPath;
use plotine_core::{Point, Rect, Result};
use crate::primitives::{FillStyle, StrokeStyle, TextStyle};
pub trait Renderer {
fn clear(&mut self, color: plotine_core::Color) -> Result<()>;
fn fill_rect(&mut self, rect: Rect, style: &FillStyle) -> Result<()>;
fn stroke_rect(&mut self, rect: Rect, style: &StrokeStyle) -> Result<()>;
fn fill_path(&mut self, path: &BezPath, style: &FillStyle) -> Result<()>;
fn stroke_path(&mut self, path: &BezPath, style: &StrokeStyle) -> Result<()>;
fn draw_line(&mut self, p0: Point, p1: Point, style: &StrokeStyle) -> Result<()> {
let mut path = BezPath::new();
path.move_to(p0.to_kurbo());
path.line_to(p1.to_kurbo());
self.stroke_path(&path, style)
}
fn draw_text(&mut self, text: &str, position: Point, style: &TextStyle) -> Result<()>;
fn draw_rgba_image(
&mut self,
rgba: &[u8],
width: u32,
height: u32,
position: Point,
) -> Result<()>;
fn measure_text(&self, text: &str, size_px: f32) -> Result<(f64, f64)> {
self.measure_text_styled(text, size_px, false)
}
fn measure_text_styled(&self, text: &str, size_px: f32, italic: bool) -> Result<(f64, f64)>;
fn push_clip_rect(&mut self, rect: Rect) -> Result<()>;
fn pop_clip(&mut self) -> Result<()>;
fn width(&self) -> u32;
fn height(&self) -> u32;
}