1#[cfg(debug_assertions)]
3mod null;
4
5use crate::{
6 Background, Border, Color, Rectangle, Shadow, Size, Transformation, Vector,
7};
8
9pub trait Renderer {
11 fn start_layer(&mut self, bounds: Rectangle);
13
14 fn end_layer(&mut self);
18
19 fn with_layer(&mut self, bounds: Rectangle, f: impl FnOnce(&mut Self)) {
23 self.start_layer(bounds);
24 f(self);
25 self.end_layer();
26 }
27
28 fn start_transformation(&mut self, transformation: Transformation);
30
31 fn end_transformation(&mut self);
35
36 fn with_transformation(
38 &mut self,
39 transformation: Transformation,
40 f: impl FnOnce(&mut Self),
41 ) {
42 self.start_transformation(transformation);
43 f(self);
44 self.end_transformation();
45 }
46
47 fn with_translation(
49 &mut self,
50 translation: Vector,
51 f: impl FnOnce(&mut Self),
52 ) {
53 self.with_transformation(
54 Transformation::translate(translation.x, translation.y),
55 f,
56 );
57 }
58
59 fn fill_quad(&mut self, quad: Quad, background: impl Into<Background>);
61
62 fn clear(&mut self);
64}
65
66#[derive(Debug, Clone, Copy, PartialEq)]
68pub struct Quad {
69 pub bounds: Rectangle,
71
72 pub border: Border,
74
75 pub shadow: Shadow,
77}
78
79impl Default for Quad {
80 fn default() -> Self {
81 Self {
82 bounds: Rectangle::with_size(Size::ZERO),
83 border: Border::default(),
84 shadow: Shadow::default(),
85 }
86 }
87}
88
89#[derive(Debug, Clone, Copy, PartialEq)]
91pub struct Style {
92 pub icon_color: Color,
94 pub text_color: Color,
96 pub scale_factor: f64,
98}
99
100impl Default for Style {
101 fn default() -> Self {
102 Style {
103 icon_color: Color::BLACK,
104 text_color: Color::BLACK,
105 scale_factor: 1.0,
106 }
107 }
108}