Struct floem_peniko::Color
source · pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
Expand description
32-bit RGBA color.
Fields§
§r: u8
Red component.
g: u8
Green component.
b: u8
Blue component.
a: u8
Alpha component.
Implementations§
source§impl Color
impl Color
sourcepub fn rgb(r: f64, g: f64, b: f64) -> Self
pub fn rgb(r: f64, g: f64, b: f64) -> Self
Create a color from three floating point values, each in the range 0.0 to 1.0.
The interpretation is the same as rgb8, and no greater precision is (currently) assumed.
sourcepub fn rgba(r: f64, g: f64, b: f64, a: f64) -> Self
pub fn rgba(r: f64, g: f64, b: f64, a: f64) -> Self
Create a color from four floating point values, each in the range 0.0 to 1.0.
The interpretation is the same as rgba32, and no greater precision is (currently) assumed.
sourcepub fn hlc(h: f64, l: f64, c: f64) -> Self
pub fn hlc(h: f64, l: f64, c: f64) -> Self
Create a color from a CIEL*a*b* polar (also known as CIE HCL) specification.
The h
parameter is an angle in degrees, with 0 roughly magenta, 90
roughly yellow, 180 roughly cyan, and 270 roughly blue. The l
parameter is perceptual luminance, with 0 black and 100 white.
The c
parameter is a chrominance concentration, with 0 grayscale
and a nominal maximum of 127 (in the future, higher values might
be useful, for high gamut contexts).
Currently this is just converted into sRGB, but in the future as we support high-gamut colorspaces, it can be used to specify more colors or existing colors with a higher accuracy.
Currently out-of-gamut values are clipped to the nearest sRGB color, which is perhaps not ideal (the clipping might change the hue). See https://github.com/d3/d3-color/issues/33 for discussion.
sourcepub fn hlca(h: f64, l: f64, c: f64, a: f64) -> Color
pub fn hlca(h: f64, l: f64, c: f64, a: f64) -> Color
Create a color from a CIEL*a*b* polar specification and alpha.
The a
value represents alpha in the range 0.0 to 1.0.
sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Parses a color from a string.
Currently accepts CSS style hexidecimal colors of the forms #RGB, #RGBA, #RRGGBB, #RRGGBBAA or the name of an SVG color such as “aliceblue”.
sourcepub fn with_alpha_factor(self, alpha: f32) -> Self
pub fn with_alpha_factor(self, alpha: f32) -> Self
Returns the color with the alpha component multiplied by the specified factor.
sourcepub fn to_premul_u32(self) -> u32
pub fn to_premul_u32(self) -> u32
Returns the color as a packed premultiplied value.
source§impl Color
impl Color
Named SVG colors.
sourcepub const ALICE_BLUE: Color = _
pub const ALICE_BLUE: Color = _
Alice blue (240, 248, 255, 255)
sourcepub const ANTIQUE_WHITE: Color = _
pub const ANTIQUE_WHITE: Color = _
Antique white (250, 235, 215, 255)
sourcepub const AQUAMARINE: Color = _
pub const AQUAMARINE: Color = _
Aquamarine (127, 255, 212, 255)
sourcepub const BLANCHED_ALMOND: Color = _
pub const BLANCHED_ALMOND: Color = _
Blanched almond (255, 235, 205, 255)
sourcepub const BLUE_VIOLET: Color = _
pub const BLUE_VIOLET: Color = _
Blue violet (138, 43, 226, 255)
sourcepub const CADET_BLUE: Color = _
pub const CADET_BLUE: Color = _
Cadet blue (95, 158, 160, 255)
sourcepub const CHARTREUSE: Color = _
pub const CHARTREUSE: Color = _
Chartreuse (127, 255, 0, 255)
sourcepub const CORNFLOWER_BLUE: Color = _
pub const CORNFLOWER_BLUE: Color = _
Cornflower blue (100, 149, 237, 255)
sourcepub const DARK_GOLDENROD: Color = _
pub const DARK_GOLDENROD: Color = _
Dark goldenrod (184, 134, 11, 255)
sourcepub const DARK_GREEN: Color = _
pub const DARK_GREEN: Color = _
Dark green (0, 100, 0, 255)
sourcepub const DARK_KHAKI: Color = _
pub const DARK_KHAKI: Color = _
Dark khaki (189, 183, 107, 255)
sourcepub const DARK_MAGENTA: Color = _
pub const DARK_MAGENTA: Color = _
Dark magenta (139, 0, 139, 255)
sourcepub const DARK_OLIVE_GREEN: Color = _
pub const DARK_OLIVE_GREEN: Color = _
Dark olive green (85, 107, 47, 255)
sourcepub const DARK_ORANGE: Color = _
pub const DARK_ORANGE: Color = _
Dark orange (255, 140, 0, 255)
sourcepub const DARK_ORCHID: Color = _
pub const DARK_ORCHID: Color = _
Dark orchid (153, 50, 204, 255)
sourcepub const DARK_SALMON: Color = _
pub const DARK_SALMON: Color = _
Dark salmon (233, 150, 122, 255)
sourcepub const DARK_SEA_GREEN: Color = _
pub const DARK_SEA_GREEN: Color = _
Dark sea green (143, 188, 143, 255)
sourcepub const DARK_SLATE_BLUE: Color = _
pub const DARK_SLATE_BLUE: Color = _
Dark slate blue (72, 61, 139, 255)
sourcepub const DARK_SLATE_GRAY: Color = _
pub const DARK_SLATE_GRAY: Color = _
Dark slate gray (47, 79, 79, 255)
sourcepub const DARK_TURQUOISE: Color = _
pub const DARK_TURQUOISE: Color = _
Dark turquoise (0, 206, 209, 255)
sourcepub const DARK_VIOLET: Color = _
pub const DARK_VIOLET: Color = _
Dark violet (148, 0, 211, 255)
sourcepub const DEEP_SKY_BLUE: Color = _
pub const DEEP_SKY_BLUE: Color = _
Deep sky blue (0, 191, 255, 255)
sourcepub const DODGER_BLUE: Color = _
pub const DODGER_BLUE: Color = _
Dodger blue (30, 144, 255, 255)
sourcepub const FLORAL_WHITE: Color = _
pub const FLORAL_WHITE: Color = _
Floral white (255, 250, 240, 255)
sourcepub const FOREST_GREEN: Color = _
pub const FOREST_GREEN: Color = _
Forest green (34, 139, 34, 255)
sourcepub const GHOST_WHITE: Color = _
pub const GHOST_WHITE: Color = _
Ghost white (248, 248, 255, 255)
sourcepub const GREEN_YELLOW: Color = _
pub const GREEN_YELLOW: Color = _
Green yellow (173, 255, 47, 255)
sourcepub const INDIAN_RED: Color = _
pub const INDIAN_RED: Color = _
Indian red (205, 92, 92, 255)
sourcepub const LAVENDER_BLUSH: Color = _
pub const LAVENDER_BLUSH: Color = _
Lavender blush (255, 240, 245, 255)
sourcepub const LAWN_GREEN: Color = _
pub const LAWN_GREEN: Color = _
Lawn green (124, 252, 0, 255)
sourcepub const LEMON_CHIFFON: Color = _
pub const LEMON_CHIFFON: Color = _
Lemon chiffon (255, 250, 205, 255)
sourcepub const LIGHT_BLUE: Color = _
pub const LIGHT_BLUE: Color = _
Light blue (173, 216, 230, 255)
sourcepub const LIGHT_CORAL: Color = _
pub const LIGHT_CORAL: Color = _
Light coral (240, 128, 128, 255)
sourcepub const LIGHT_CYAN: Color = _
pub const LIGHT_CYAN: Color = _
Light cyan (224, 255, 255, 255)
sourcepub const LIGHT_GOLDENROD_YELLOW: Color = _
pub const LIGHT_GOLDENROD_YELLOW: Color = _
Light goldenrod yellow (250, 250, 210, 255)
sourcepub const LIGHT_GRAY: Color = _
pub const LIGHT_GRAY: Color = _
Light gray (211, 211, 211, 255)
sourcepub const LIGHT_GREEN: Color = _
pub const LIGHT_GREEN: Color = _
Light green (144, 238, 144, 255)
sourcepub const LIGHT_PINK: Color = _
pub const LIGHT_PINK: Color = _
Light pink (255, 182, 193, 255)
sourcepub const LIGHT_SALMON: Color = _
pub const LIGHT_SALMON: Color = _
Light salmon (255, 160, 122, 255)
sourcepub const LIGHT_SEA_GREEN: Color = _
pub const LIGHT_SEA_GREEN: Color = _
Light sea green (32, 178, 170, 255)
sourcepub const LIGHT_SKY_BLUE: Color = _
pub const LIGHT_SKY_BLUE: Color = _
Light sky blue (135, 206, 250, 255)
sourcepub const LIGHT_SLATE_GRAY: Color = _
pub const LIGHT_SLATE_GRAY: Color = _
Light slate gray (119, 136, 153, 255)
sourcepub const LIGHT_STEEL_BLUE: Color = _
pub const LIGHT_STEEL_BLUE: Color = _
Light steel blue (176, 196, 222, 255)
sourcepub const LIGHT_YELLOW: Color = _
pub const LIGHT_YELLOW: Color = _
Light yellow (255, 255, 224, 255)
sourcepub const LIME_GREEN: Color = _
pub const LIME_GREEN: Color = _
Lime green (50, 205, 50, 255)
sourcepub const MEDIUM_AQUAMARINE: Color = _
pub const MEDIUM_AQUAMARINE: Color = _
Medium aquamarine (102, 205, 170, 255)
sourcepub const MEDIUM_BLUE: Color = _
pub const MEDIUM_BLUE: Color = _
Medium blue (0, 0, 205, 255)
sourcepub const MEDIUM_ORCHID: Color = _
pub const MEDIUM_ORCHID: Color = _
Medium orchid (186, 85, 211, 255)
sourcepub const MEDIUM_PURPLE: Color = _
pub const MEDIUM_PURPLE: Color = _
Medium purple (147, 112, 219, 255)
sourcepub const MEDIUM_SEA_GREEN: Color = _
pub const MEDIUM_SEA_GREEN: Color = _
Medium sea green (60, 179, 113, 255)
sourcepub const MEDIUM_SLATE_BLUE: Color = _
pub const MEDIUM_SLATE_BLUE: Color = _
Medium slate blue (123, 104, 238, 255)
sourcepub const MEDIUM_SPRING_GREEN: Color = _
pub const MEDIUM_SPRING_GREEN: Color = _
Medium spring green (0, 250, 154, 255)
sourcepub const MEDIUM_TURQUOISE: Color = _
pub const MEDIUM_TURQUOISE: Color = _
Medium turquoise (72, 209, 204, 255)
sourcepub const MEDIUM_VIOLET_RED: Color = _
pub const MEDIUM_VIOLET_RED: Color = _
Medium violet red (199, 21, 133, 255)
sourcepub const MIDNIGHT_BLUE: Color = _
pub const MIDNIGHT_BLUE: Color = _
Midnight blue (25, 25, 112, 255)
sourcepub const MINT_CREAM: Color = _
pub const MINT_CREAM: Color = _
Mint cream (245, 255, 250, 255)
sourcepub const MISTY_ROSE: Color = _
pub const MISTY_ROSE: Color = _
Misty rose (255, 228, 225, 255)
sourcepub const NAVAJO_WHITE: Color = _
pub const NAVAJO_WHITE: Color = _
Navajo white (255, 222, 173, 255)
sourcepub const OLIVE_DRAB: Color = _
pub const OLIVE_DRAB: Color = _
Olive drab (107, 142, 35, 255)
sourcepub const ORANGE_RED: Color = _
pub const ORANGE_RED: Color = _
Orange red (255, 69, 0, 255)
sourcepub const PALE_GOLDENROD: Color = _
pub const PALE_GOLDENROD: Color = _
Pale goldenrod (238, 232, 170, 255)
sourcepub const PALE_GREEN: Color = _
pub const PALE_GREEN: Color = _
Pale green (152, 251, 152, 255)
sourcepub const PALE_TURQUOISE: Color = _
pub const PALE_TURQUOISE: Color = _
Pale turquoise (175, 238, 238, 255)
sourcepub const PALE_VIOLET_RED: Color = _
pub const PALE_VIOLET_RED: Color = _
Pale violet red (219, 112, 147, 255)
sourcepub const PAPAYA_WHIP: Color = _
pub const PAPAYA_WHIP: Color = _
Papaya whip (255, 239, 213, 255)
sourcepub const PEACH_PUFF: Color = _
pub const PEACH_PUFF: Color = _
Peach puff (255, 218, 185, 255)
sourcepub const POWDER_BLUE: Color = _
pub const POWDER_BLUE: Color = _
Powder blue (176, 224, 230, 255)
sourcepub const REBECCA_PURPLE: Color = _
pub const REBECCA_PURPLE: Color = _
Rebecca purple (102, 51, 153, 255)
sourcepub const ROSY_BROWN: Color = _
pub const ROSY_BROWN: Color = _
Rosy brown (188, 143, 143, 255)
sourcepub const ROYAL_BLUE: Color = _
pub const ROYAL_BLUE: Color = _
Royal blue (65, 105, 225, 255)
sourcepub const SADDLE_BROWN: Color = _
pub const SADDLE_BROWN: Color = _
Saddle brown (139, 69, 19, 255)
sourcepub const SANDY_BROWN: Color = _
pub const SANDY_BROWN: Color = _
Sandy brown (244, 164, 96, 255)
sourcepub const SLATE_BLUE: Color = _
pub const SLATE_BLUE: Color = _
Slate blue (106, 90, 205, 255)
sourcepub const SLATE_GRAY: Color = _
pub const SLATE_GRAY: Color = _
Slate gray (112, 128, 144, 255)
sourcepub const SPRING_GREEN: Color = _
pub const SPRING_GREEN: Color = _
Spring green (0, 255, 127, 255)
sourcepub const STEEL_BLUE: Color = _
pub const STEEL_BLUE: Color = _
Steel blue (70, 130, 180, 255)
sourcepub const TRANSPARENT: Color = _
pub const TRANSPARENT: Color = _
Transparent (0, 0, 0, 0)
sourcepub const WHITE_SMOKE: Color = _
pub const WHITE_SMOKE: Color = _
White smoke (245, 245, 245, 255)
sourcepub const YELLOW_GREEN: Color = _
pub const YELLOW_GREEN: Color = _
Yellow green (154, 205, 50, 255)
Trait Implementations§
source§impl Ord for Color
impl Ord for Color
source§impl PartialEq for Color
impl PartialEq for Color
source§impl PartialOrd for Color
impl PartialOrd for Color
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more