#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(transparent)]
pub struct COLORREF(pub u32);
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
impl Color {
pub fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Self {
Color { r, g, b, a }
}
pub fn from_rgb(r: u8, g: u8, b: u8) -> Self {
Color { r, g, b, a: 255 }
}
pub fn to_colorref(&self) -> COLORREF {
COLORREF((self.r as u32) | ((self.g as u32) << 8) | ((self.b as u32) << 16))
}
pub fn from_colorref(colorref: COLORREF) -> Self {
let value = colorref.0;
Color {
r: (value & 0xFF) as u8,
g: ((value >> 8) & 0xFF) as u8,
b: ((value >> 16) & 0xFF) as u8,
a: 255,
}
}
pub const BLACK: Color = Color { r: 0, g: 0, b: 0, a: 255 };
pub const WHITE: Color = Color { r: 255, g: 255, b: 255, a: 255 };
pub const RED: Color = Color { r: 255, g: 0, b: 0, a: 255 };
pub const GREEN: Color = Color { r: 0, g: 255, b: 0, a: 255 };
pub const BLUE: Color = Color { r: 0, g: 0, b: 255, a: 255 };
pub const TRANSPARENT: Color = Color { r: 0, g: 0, b: 0, a: 0 };
}
#[derive(Clone)]
pub struct Brush {
color: Color,
}
impl Brush {
pub fn new(color: Color) -> Self {
Brush { color }
}
pub fn color(&self) -> Color {
self.color
}
pub fn set_color(&self, _color: Color) {
}
}
pub type SolidColorBrush = Brush;