#[repr(C)]pub struct RgbColor {
pub r: u8,
pub g: u8,
pub b: u8,
}Expand description
RGB color value.
Fields§
§r: u8Red color component (0-255)
g: u8Green color component (0-255)
b: u8Blue color component (0-255)
Implementations§
Source§impl RgbColor
impl RgbColor
Sourcepub fn parse_x11_color(name: &str) -> Result<Self>
pub fn parse_x11_color(name: &str) -> Result<Self>
Parse an X11 color name.
The color name is resolved from Ghostty’s embedded rgb.txt table. Leading and trailing spaces and tabs are trimmed, and matching is ASCII case-insensitive. Hex values are not accepted by this function.
Sourcepub fn parse(value: &str) -> Result<Self>
pub fn parse(value: &str) -> Result<Self>
Parse a flexible Ghostty color value.
Accepts Ghostty’s terminal color syntax: X11 color names, hex colors in 3-,
6-, 9-, or 12-digit form (the leading # is optional for 3- and 6-digit
values), and rgb:<red>/<green>/<blue> or
rgbi:<red>/<green>/<blue> specifications. Leading and trailing spaces and
tabs are trimmed.
Sourcepub fn luminance(self) -> f64
pub fn luminance(self) -> f64
Calculate W3C relative luminance for an RGB color.
Returns a normalized value from 0.0 for black to 1.0 for white. See https://www.w3.org/TR/WCAG20/#relativeluminancedef.
Sourcepub fn perceived_luminance(self) -> f64
pub fn perceived_luminance(self) -> f64
Calculate perceived luminance for an RGB color.
Returns a normalized value from 0.0 for black to 1.0 for white. Ghostty
treats a background color as light when this exceeds 0.5. This is not the
metric used internally by Palette::generate, which uses CIELAB lightness.