1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7pub struct Color {
8 pub r: u8,
9 pub g: u8,
10 pub b: u8,
11 pub a: u8,
12}
13
14impl Color {
15 pub const fn rgb(r: u8, g: u8, b: u8) -> Self {
17 Self { r, g, b, a: 255 }
18 }
19
20 pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self {
22 Self { r, g, b, a }
23 }
24
25 pub const BLACK: Color = Color::rgb(0, 0, 0);
27
28 pub const WHITE: Color = Color::rgb(255, 255, 255);
30
31 pub const RED: Color = Color::rgb(255, 0, 0);
33
34 pub const GREEN: Color = Color::rgb(0, 255, 0);
36
37 pub const BLUE: Color = Color::rgb(0, 0, 255);
39
40 pub const GRAY: Color = Color::rgb(128, 128, 128);
42
43 pub const LIGHT_GRAY: Color = Color::rgb(192, 192, 192);
45
46 pub const DARK_GRAY: Color = Color::rgb(64, 64, 64);
48}
49
50#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
52pub struct Point {
53 pub x: u32,
54 pub y: u32,
55}
56
57impl Point {
58 pub const fn new(x: u32, y: u32) -> Self {
59 Self { x, y }
60 }
61}
62
63#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
65pub struct Rect {
66 pub x: u32,
67 pub y: u32,
68 pub width: u32,
69 pub height: u32,
70}
71
72impl Rect {
73 pub const fn new(x: u32, y: u32, width: u32, height: u32) -> Self {
74 Self {
75 x,
76 y,
77 width,
78 height,
79 }
80 }
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize)]
85pub enum DisplayCommand {
86 RenderAsciiArt {
88 text: String,
89 font_size: u32,
90 fg_color: Color,
91 bg_color: Color,
92 },
93
94 DrawRectangle {
96 x: u32,
97 y: u32,
98 width: u32,
99 height: u32,
100 color: Color,
101 filled: bool,
102 },
103
104 DrawText {
106 x: u32,
107 y: u32,
108 text: String,
109 font_size: u32,
110 color: Color,
111 },
112
113 DrawLine {
115 x1: u32,
116 y1: u32,
117 x2: u32,
118 y2: u32,
119 color: Color,
120 width: u32,
121 },
122
123 DrawCircle {
125 x: u32,
126 y: u32,
127 radius: u32,
128 color: Color,
129 filled: bool,
130 },
131
132 DrawWindow {
134 x: u32,
135 y: u32,
136 width: u32,
137 height: u32,
138 title: String,
139 content: Vec<DisplayCommand>,
140 },
141
142 DrawButton {
144 x: u32,
145 y: u32,
146 width: u32,
147 height: u32,
148 label: String,
149 },
150
151 DrawTextBox {
153 x: u32,
154 y: u32,
155 width: u32,
156 height: u32,
157 text: String,
158 placeholder: Option<String>,
159 },
160
161 SetBackground { color: Color },
163
164 Clear,
166}