plushie/prop/color
Color type for widget colors.
Colors are stored as normalized hex strings (#rrggbb or #rrggbbaa). Opaque type prevents construction of invalid hex values.
Types
Values
pub const alice_blue: Color
pub const antique_white: Color
pub const aquamarine: Color
pub const blanched_almond: Color
pub const blue_violet: Color
pub const cadet_blue: Color
pub const chartreuse: Color
pub fn contrast_ratio(
foreground: Color,
background: Color,
) -> Float
Calculate the WCAG contrast ratio between two colours.
Alpha channels are ignored. Contrast depends on the final composited colour, so callers should pass colours that already account for any blending with the real background.
pub const cornflower_blue: Color
pub const dark_goldenrod: Color
pub const dark_green: Color
pub const dark_khaki: Color
pub const dark_magenta: Color
pub const dark_olive_green: Color
pub const dark_orange: Color
pub const dark_orchid: Color
pub const dark_salmon: Color
pub const dark_sea_green: Color
pub const dark_slate_blue: Color
pub const dark_slate_gray: Color
pub const dark_slate_grey: Color
pub const dark_turquoise: Color
pub const dark_violet: Color
pub const deep_sky_blue: Color
pub const dodger_blue: Color
pub const fire_brick: Color
pub const floral_white: Color
pub const forest_green: Color
pub fn from_hex(hex: String) -> Result(Color, Nil)
Create a color from a hex string. Validates and normalizes format. Accepts “#rgb”, “#rgba”, “#rrggbb”, “#rrggbbaa” (with or without #).
pub fn from_rgb(r: Int, g: Int, b: Int) -> Color
Create a color from RGB components (0-255).
pub fn from_rgb_float(r: Float, g: Float, b: Float) -> Color
Create a color from float RGB values in the 0.0-1.0 range. Values are clamped to 0.0-1.0 and converted to the 0-255 range.
pub fn from_rgba(r: Int, g: Int, b: Int, a: Float) -> Color
Create a color from RGBA components (0-255 for RGB, 0.0-1.0 for alpha).
pub fn from_rgba_float(
r: Float,
g: Float,
b: Float,
a: Float,
) -> Color
Create a color from float RGBA values in the 0.0-1.0 range. RGB values are clamped and converted to 0-255. Alpha stays as float (0.0-1.0).
pub const ghost_white: Color
pub const green_yellow: Color
pub const indian_red: Color
pub fn is_accessible(
foreground: Color,
background: Color,
) -> Bool
Alias for meets_aa, the normal text WCAG AA threshold.
pub const lavender_blush: Color
pub const lawn_green: Color
pub const lemon_chiffon: Color
pub const light_blue: Color
pub const light_coral: Color
pub const light_cyan: Color
pub const light_goldenrod_yellow: Color
pub const light_gray: Color
pub const light_green: Color
pub const light_grey: Color
pub const light_pink: Color
pub const light_salmon: Color
pub const light_sea_green: Color
pub const light_sky_blue: Color
pub const light_slate_gray: Color
pub const light_slate_grey: Color
pub const light_steel_blue: Color
pub const light_yellow: Color
pub const lime_green: Color
pub const medium_aquamarine: Color
pub const medium_blue: Color
pub const medium_orchid: Color
pub const medium_purple: Color
pub const medium_sea_green: Color
pub const medium_slate_blue: Color
pub const medium_spring_green: Color
pub const medium_turquoise: Color
pub const medium_violet_red: Color
pub fn meets_aa(foreground: Color, background: Color) -> Bool
True when the colour pair meets WCAG AA contrast for normal text.
pub fn meets_aa_large(
foreground: Color,
background: Color,
) -> Bool
True when the colour pair meets WCAG AA contrast for large text.
pub fn meets_aaa(foreground: Color, background: Color) -> Bool
True when the colour pair meets WCAG AAA contrast for normal text.
pub fn meets_aaa_large(
foreground: Color,
background: Color,
) -> Bool
True when the colour pair meets WCAG AAA contrast for large text.
pub const midnight_blue: Color
pub const mint_cream: Color
pub const misty_rose: Color
pub const navajo_white: Color
pub const olive_drab: Color
pub const orange_red: Color
pub const pale_goldenrod: Color
pub const pale_green: Color
pub const pale_turquoise: Color
pub const pale_violet_red: Color
pub const papaya_whip: Color
pub const peach_puff: Color
pub const powder_blue: Color
pub const rebecca_purple: Color
pub const rosy_brown: Color
pub const royal_blue: Color
pub const saddle_brown: Color
pub const sandy_brown: Color
pub const slate_blue: Color
pub const slate_gray: Color
pub const slate_grey: Color
pub const spring_green: Color
pub const steel_blue: Color
pub fn to_prop_value(color: Color) -> node.PropValue
Encode to wire-format PropValue (hex string).
pub const transparent: Color
pub const white_smoke: Color
pub const yellow_green: Color