use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
impl Color {
pub const fn rgb(r: u8, g: u8, b: u8) -> Self {
Self { r, g, b, a: 255 }
}
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self {
Self { r, g, b, a }
}
pub const BLACK: Color = Color::rgb(0, 0, 0);
pub const WHITE: Color = Color::rgb(255, 255, 255);
pub const RED: Color = Color::rgb(255, 0, 0);
pub const GREEN: Color = Color::rgb(0, 255, 0);
pub const BLUE: Color = Color::rgb(0, 0, 255);
pub const GRAY: Color = Color::rgb(128, 128, 128);
pub const LIGHT_GRAY: Color = Color::rgb(192, 192, 192);
pub const DARK_GRAY: Color = Color::rgb(64, 64, 64);
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct Point {
pub x: u32,
pub y: u32,
}
impl Point {
pub const fn new(x: u32, y: u32) -> Self {
Self { x, y }
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct Rect {
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}
impl Rect {
pub const fn new(x: u32, y: u32, width: u32, height: u32) -> Self {
Self {
x,
y,
width,
height,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DisplayCommand {
RenderAsciiArt {
text: String,
font_size: u32,
fg_color: Color,
bg_color: Color,
},
DrawRectangle {
x: u32,
y: u32,
width: u32,
height: u32,
color: Color,
filled: bool,
},
DrawText {
x: u32,
y: u32,
text: String,
font_size: u32,
color: Color,
},
DrawLine {
x1: u32,
y1: u32,
x2: u32,
y2: u32,
color: Color,
width: u32,
},
DrawCircle {
x: u32,
y: u32,
radius: u32,
color: Color,
filled: bool,
},
DrawWindow {
x: u32,
y: u32,
width: u32,
height: u32,
title: String,
content: Vec<DisplayCommand>,
},
DrawButton {
x: u32,
y: u32,
width: u32,
height: u32,
label: String,
},
DrawTextBox {
x: u32,
y: u32,
width: u32,
height: u32,
text: String,
placeholder: Option<String>,
},
SetBackground { color: Color },
Clear,
}