use crate::common::*;
use crate::layout::*;
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum LineCap {
Butt,
Square,
Round,
}
pub trait Renderer {
type Font;
fn push(&mut self);
fn pop(&mut self);
fn translate(&mut self, vec: Vector);
fn clip(&mut self, rect: Rect);
fn fill(&mut self, rect: Rect, color: Color, radius: f32);
fn outline(&mut self, rect: Rect, color: Color, radius: f32, thickness: f32);
fn line(&mut self, a: Point, b: Point, color: Color, cap: LineCap, thickness: f32);
fn text(
&mut self,
rect: Rect,
font: &Self::Font,
text: &str,
color: Color,
alignment: Alignment,
) -> f32;
}
pub struct NoRenderer;
pub struct NoRendererFont;
impl Renderer for NoRenderer {
type Font = NoRendererFont;
fn push(&mut self) {}
fn pop(&mut self) {}
fn translate(&mut self, _: Vector) {}
fn clip(&mut self, _: Rect) {}
fn fill(&mut self, _: Rect, _: Color, _: f32) {}
fn outline(&mut self, _: Rect, _: Color, _: f32, _: f32) {}
fn line(&mut self, _: Point, _: Point, _: Color, _: LineCap, _: f32) {}
fn text(&mut self, _: Rect, _: &Self::Font, _: &str, _: Color, _: Alignment) -> f32 {
0.0
}
}