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 render_point(&mut self, position: DVec2, color: Srgba);
16    fn render_line(&mut self, start: DVec2, end: DVec2, thickness: f64, color: Srgba);
17    fn render_circle(&mut self, position: DVec2, radius: f64, color: Srgba);
18    fn render_circle_lines(&mut self, position: DVec2, radius: f64, thickness: f64, color: Srgba);
19
20    fn render_arc(
21        &mut self,
22        position: DVec2,
23        radius: f64,
24        rotation: f64,
25        sides: u8,
26        arc: f64,
27        color: Srgba,
28    );
29
30    fn render_arc_lines(
31        &mut self,
32        position: DVec2,
33        radius: f64,
34        rotation: f64,
35        sides: u8,
36        arc: f64,
37        thickness: f64,
38        color: Srgba,
39    );
40
41    fn render_text(
42        &mut self,
43        text: &str,
44        position: DVec2,
45        anchor: Anchor2D,
46        size: f64,
47        color: Srgba,
48    );
49
50    fn render_text_outline(
51        &mut self,
52        text: &str,
53        position: DVec2,
54        anchor: Anchor2D,
55        size: f64,
56        outline_thickness: f64,
57        color: Srgba,
58        outline_color: Srgba,
59    );
60
61    fn render_rectangle(
62        &mut self,
63        position: DVec2,
64        width: f64,
65        height: f64,
66        offset: DVec2,
67        rotation: f64,
68        color: Srgba,
69    );
70
71    fn render_rectangle_lines(
72        &mut self,
73        position: DVec2,
74        width: f64,
75        height: f64,
76        offset: DVec2,
77        rotation: f64,
78        thickness: f64,
79        color: Srgba,
80    );
81
82    fn render_equilateral_triangle(
83        &mut self,
84        position: DVec2,
85        radius: f64,
86        rotation: f64,
87        color: Srgba,
88    );
89
90    fn render_equilateral_triangle_lines(
91        &mut self,
92        position: DVec2,
93        radius: f64,
94        rotation: f64,
95        thickness: f64,
96        color: Srgba,
97    );
98
99    fn render_image(
100        &mut self,
101        image_name: &str,
102        position: DVec2,
103        width: f64,
104        height: f64,
105        offset: DVec2,
106        rotation: f64,
107    );
108}
109
110pub trait ImageRegistry {
111    fn register_image();
112}