bly_ac/
lib.rs

1//! Crate for common back-end processing and other variables.
2
3/// Trait for common back-end processing
4pub trait Backend {
5    // Initialize
6    /// Processing to start drawing (initialization, etc.)
7    unsafe fn begin_draw(&mut self);
8    /// Processing to finish drawing
9    unsafe fn flush(&mut self);
10
11    /// Get display size
12    unsafe fn get_display_size(&mut self) -> (u32, u32);
13
14    /// Fills the window background with a specific color
15    unsafe fn clear(&mut self, r: f32, g: f32, b: f32, a: f32);
16
17    // Primitives
18    /// Draws a ellipse
19    unsafe fn draw_ellipse(
20        &mut self,
21        point: Point2<f32>,
22        radius: f32,
23        r: f32,
24        g: f32,
25        b: f32,
26        a: f32,
27    );
28
29    /// Draws a rectangle
30    unsafe fn draw_rect(
31        &mut self,
32        point1: Point2<f32>,
33        point2: Point2<f32>,
34        r: f32,
35        g: f32,
36        b: f32,
37        a: f32,
38    );
39
40    unsafe fn draw_rounded_rect(
41        &mut self,
42        point1: Point2<f32>,
43        point2: Point2<f32>,
44        radius:f32,
45        r: f32,
46        g: f32,
47        b: f32,
48        a: f32,
49    );
50
51    // Draws a line
52    unsafe fn draw_line(
53        &mut self,
54        point1: Point2<f32>,
55        point2: Point2<f32>,
56        stroke: f32,
57        r: f32,
58        g: f32,
59        b: f32,
60        a: f32,
61    );
62}
63
64pub struct Point2<T>(pub T,pub T);
65impl<T> Point2<T> {
66    pub fn new(a:T,b:T) -> Self {
67        Self {
68            0: a,
69            1: b,
70        }
71    }
72}
73pub struct Point3<T>(pub T,pub T,pub T);
74impl<T> Point3<T> {
75    pub fn new(a:T,b:T,c:T) -> Self {
76        Self {
77            0: a,
78            1: b,
79            2: c,
80        }
81    }
82}
83pub struct Point4<T>(pub T,pub T,pub T,pub T);
84impl<T> Point4<T> {
85    pub fn new(a:T,b:T,c:T,d:T) -> Self {
86        Self {
87            0: a,
88            1: b,
89            2: c,
90            3: d
91        }
92    }
93}