Skip to main content

render_agnostic/
lib.rs

1use anchor2d::Anchor2D;
2use glam::DVec2;
3use palette::Srgba;
4
5pub mod image_registries;
6pub mod renderers;
7
8#[cfg(feature = "image")]
9pub use renderers::image::ImageRenderer;
10
11#[cfg(feature = "macroquad")]
12pub use renderers::macroquad::MacroquadRenderer;
13
14pub trait Renderer {
15    fn width(&self) -> f64;
16    fn height(&self) -> f64;
17
18    fn render_point(&mut self, position: DVec2, color: Srgba);
19    fn render_line(&mut self, start: DVec2, end: DVec2, thickness: f64, color: Srgba);
20    fn render_circle(&mut self, position: DVec2, radius: f64, color: Srgba);
21    fn render_circle_lines(&mut self, position: DVec2, radius: f64, thickness: f64, color: Srgba);
22
23    fn render_arc(
24        &mut self,
25        position: DVec2,
26        radius: f64,
27        rotation: f64,
28        sides: u8,
29        arc: f64,
30        color: Srgba,
31    );
32
33    fn render_arc_lines(
34        &mut self,
35        position: DVec2,
36        radius: f64,
37        rotation: f64,
38        sides: u8,
39        arc: f64,
40        thickness: f64,
41        color: Srgba,
42    );
43
44    fn render_text(
45        &mut self,
46        text: &str,
47        position: DVec2,
48        anchor: Anchor2D,
49        size: f64,
50        color: Srgba,
51    );
52
53    fn render_text_outline(
54        &mut self,
55        text: &str,
56        position: DVec2,
57        anchor: Anchor2D,
58        size: f64,
59        outline_thickness: f64,
60        color: Srgba,
61        outline_color: Srgba,
62    );
63
64    fn render_rectangle(
65        &mut self,
66        position: DVec2,
67        width: f64,
68        height: f64,
69        offset: DVec2,
70        rotation: f64,
71        color: Srgba,
72    );
73
74    fn render_rectangle_lines(
75        &mut self,
76        position: DVec2,
77        width: f64,
78        height: f64,
79        offset: DVec2,
80        rotation: f64,
81        thickness: f64,
82        color: Srgba,
83    );
84
85    fn render_equilateral_triangle(
86        &mut self,
87        position: DVec2,
88        radius: f64,
89        rotation: f64,
90        color: Srgba,
91    );
92
93    fn render_equilateral_triangle_lines(
94        &mut self,
95        position: DVec2,
96        radius: f64,
97        rotation: f64,
98        thickness: f64,
99        color: Srgba,
100    );
101
102    fn render_image(
103        &mut self,
104        image_name: &str,
105        position: DVec2,
106        width: f64,
107        height: f64,
108        offset: DVec2,
109        rotation: f64,
110    );
111}
112
113pub trait ImageRegistry {
114    fn register_image();
115}