Download kernel/src/graphics/color.rs from Jaswanth-2008/AeroOS: direct link, hf CLI and curl.
- Browser
- Download file 2.58 kB
-
https://huggingface.co/Jaswanth-2008/AeroOS/resolve/main/kernel/src/graphics/color.rs
- Command line
-
hf download hf://Jaswanth-2008/AeroOS/kernel/src/graphics/color.rs
-
curl -L -o color.rs https://huggingface.co/Jaswanth-2008/AeroOS/resolve/main/kernel/src/graphics/color.rs
2.58 kB
| 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 fn to_u32_argb(self) -> u32 { | |
| ((self.a as u32) << 24) | ((self.r as u32) << 16) | ((self.g as u32) << 8) | (self.b as u32) | |
| } | |
| pub fn to_u32_bgr(self) -> u32 { | |
| ((self.b as u32) << 16) | ((self.g as u32) << 8) | (self.r as u32) | |
| } | |
| pub fn to_u32_rgb(self) -> u32 { | |
| ((self.r as u32) << 16) | ((self.g as u32) << 8) | (self.b as u32) | |
| } | |
| pub fn blend(self, background: Color) -> Color { | |
| if self.a == 255 { | |
| return self; | |
| } | |
| if self.a == 0 { | |
| return background; | |
| } | |
| let alpha = self.a as u32; | |
| let inv_alpha = 255 - alpha; | |
| let r = ((self.r as u32 * alpha + background.r as u32 * inv_alpha) / 255) as u8; | |
| let g = ((self.g as u32 * alpha + background.g as u32 * inv_alpha) / 255) as u8; | |
| let b = ((self.b as u32 * alpha + background.b as u32 * inv_alpha) / 255) as u8; | |
| Color { r, g, b, a: 255 } | |
| } | |
| // Windows 11 & macOS Theme Colors | |
| pub const BLACK: Color = Color::rgb(0, 0, 0); | |
| pub const WHITE: Color = Color::rgb(255, 255, 255); | |
| pub const TRANSPARENT: Color = Color::rgba(0, 0, 0, 0); | |
| // Dark Mode Acrylic Surface (Windows 11 Mica / macOS Dark Glass) | |
| pub const MICA_BACKGROUND: Color = Color::rgba(28, 30, 38, 220); | |
| pub const MICA_SURFACE: Color = Color::rgba(36, 39, 48, 230); | |
| pub const MICA_SURFACE_LIGHT: Color = Color::rgba(50, 54, 66, 240); | |
| pub const MICA_BORDER: Color = Color::rgba(255, 255, 255, 28); | |
| pub const MICA_BORDER_HIGHLIGHT: Color = Color::rgba(255, 255, 255, 55); | |
| // Accent Colors | |
| pub const ACCENT_BLUE: Color = Color::rgb(0, 122, 255); // macOS Blue | |
| pub const ACCENT_CYAN: Color = Color::rgb(0, 198, 255); // Windows 11 Cyan | |
| pub const ACCENT_PURPLE: Color = Color::rgb(142, 68, 239); | |
| // Traffic Lights (macOS) | |
| pub const TRAFFIC_CLOSE: Color = Color::rgb(255, 95, 87); | |
| pub const TRAFFIC_MIN: Color = Color::rgb(254, 188, 46); | |
| pub const TRAFFIC_MAX: Color = Color::rgb(40, 201, 64); | |
| // Text Colors | |
| pub const TEXT_PRIMARY: Color = Color::rgb(245, 245, 250); | |
| pub const TEXT_SECONDARY: Color = Color::rgb(160, 165, 185); | |
| pub const TEXT_MUTED: Color = Color::rgb(110, 115, 130); | |
| } | |