pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}Expand description
A colour, 8 bits per channel.
Fields§
§r: u8Red, 0-255.
g: u8Green, 0-255.
b: u8Blue, 0-255.
a: u8Alpha, 0-255. 0xff is opaque; the auth screen’s defaults are
deliberately all opaque, because a transparent background or text
colour there renders nothing at all.
Implementations§
Source§impl Color
impl Color
Sourcepub const BLACK: Color
pub const BLACK: Color
Opaque black. The fallback a caller reaches for when a colour fails to parse and something must still be drawn — see the module doc’s note on leniency living at the call site, not in here.
Sourcepub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color
Builds a colour directly from its channels, bypassing
parse. const fn so it can build the default
palette’s constants at compile time.
Sourcepub fn parse(s: &str) -> Result<Color, ColorError>
pub fn parse(s: &str) -> Result<Color, ColorError>
Parses rgba(rrggbbaa) or rgb(rrggbb), strictly.
The digit count is tied to the prefix: rgba() takes eight and
rgb() six. Accepting eight digits inside rgb( would draw a
confident swatch beside a value Hyprland is about to refuse.
Sourcepub fn from_argb_hex(s: &str) -> Option<Color>
pub fn from_argb_hex(s: &str) -> Option<Color>
Reads hyprctl’s gradient spelling, which is AARRGGBB — the
alpha leading rather than trailing. Copying that string into a
config would be a different colour.
Sourcepub fn from_argb_u32(v: u32) -> Color
pub fn from_argb_u32(v: u32) -> Color
Reads hyprctl’s plain-colour spelling, a packed 0xAARRGGBB
integer. rgba(112233ff) comes back as 4279312947.