Struct xilem::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

source

pub const fn rgb8(r: u8, g: u8, b: u8) -> Color

Creates a new RGB color with 255 alpha.

source

pub const fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Color

Creates a new RGBA color.

source

pub fn rgb(r: f64, g: f64, b: f64) -> Color

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.

source

pub fn rgba(r: f64, g: f64, b: f64, a: f64) -> Color

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.

source

pub fn hlc(h: f64, l: f64, c: f64) -> Color

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.

source

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.

source

pub fn parse(s: &str) -> Option<Color>

Parses a color from a string.

Currently accepts CSS style hexadecimal colors of the forms #RGB, #RGBA, #RRGGBB, #RRGGBBAA or the name of an SVG color such as “aliceblue”.

source

pub fn with_alpha_factor(self, alpha: f32) -> Color

Returns the color with the alpha component multiplied by the specified factor.

source

pub fn to_premul_u32(self) -> u32

Returns the color as a packed premultiplied value.

source§

impl Color

Named SVG colors.

source

pub const ALICE_BLUE: Color = _

Alice blue (240, 248, 255, 255)

source

pub const ANTIQUE_WHITE: Color = _

Antique white (250, 235, 215, 255)

source

pub const AQUA: Color = _

Aqua (0, 255, 255, 255)

source

pub const AQUAMARINE: Color = _

Aquamarine (127, 255, 212, 255)

source

pub const AZURE: Color = _

Azure (240, 255, 255, 255)

source

pub const BEIGE: Color = _

Beige (245, 245, 220, 255)

source

pub const BISQUE: Color = _

Bisque (255, 228, 196, 255)

source

pub const BLACK: Color = _

Black (0, 0, 0, 255)

source

pub const BLANCHED_ALMOND: Color = _

Blanched almond (255, 235, 205, 255)

source

pub const BLUE: Color = _

Blue (0, 0, 255, 255)

source

pub const BLUE_VIOLET: Color = _

Blue violet (138, 43, 226, 255)

source

pub const BROWN: Color = _

Brown (165, 42, 42, 255)

source

pub const BURLYWOOD: Color = _

Burlywood (222, 184, 135, 255)

source

pub const CADET_BLUE: Color = _

Cadet blue (95, 158, 160, 255)

source

pub const CHARTREUSE: Color = _

Chartreuse (127, 255, 0, 255)

source

pub const CHOCOLATE: Color = _

Chocolate (210, 105, 30, 255)

source

pub const CORAL: Color = _

Coral (255, 127, 80, 255)

source

pub const CORNFLOWER_BLUE: Color = _

Cornflower blue (100, 149, 237, 255)

source

pub const CORNSILK: Color = _

Cornsilk (255, 248, 220, 255)

source

pub const CRIMSON: Color = _

Crimson (220, 20, 60, 255)

source

pub const CYAN: Color = _

Cyan (0, 255, 255, 255)

source

pub const DARK_BLUE: Color = _

Dark blue (0, 0, 139, 255)

source

pub const DARK_CYAN: Color = _

Dark cyan (0, 139, 139, 255)

source

pub const DARK_GOLDENROD: Color = _

Dark goldenrod (184, 134, 11, 255)

source

pub const DARK_GRAY: Color = _

Dark gray (169, 169, 169, 255)

source

pub const DARK_GREEN: Color = _

Dark green (0, 100, 0, 255)

source

pub const DARK_KHAKI: Color = _

Dark khaki (189, 183, 107, 255)

source

pub const DARK_MAGENTA: Color = _

Dark magenta (139, 0, 139, 255)

source

pub const DARK_OLIVE_GREEN: Color = _

Dark olive green (85, 107, 47, 255)

source

pub const DARK_ORANGE: Color = _

Dark orange (255, 140, 0, 255)

source

pub const DARK_ORCHID: Color = _

Dark orchid (153, 50, 204, 255)

source

pub const DARK_RED: Color = _

Dark red (139, 0, 0, 255)

source

pub const DARK_SALMON: Color = _

Dark salmon (233, 150, 122, 255)

source

pub const DARK_SEA_GREEN: Color = _

Dark sea green (143, 188, 143, 255)

source

pub const DARK_SLATE_BLUE: Color = _

Dark slate blue (72, 61, 139, 255)

source

pub const DARK_SLATE_GRAY: Color = _

Dark slate gray (47, 79, 79, 255)

source

pub const DARK_TURQUOISE: Color = _

Dark turquoise (0, 206, 209, 255)

source

pub const DARK_VIOLET: Color = _

Dark violet (148, 0, 211, 255)

source

pub const DEEP_PINK: Color = _

Deep pink (255, 20, 147, 255)

source

pub const DEEP_SKY_BLUE: Color = _

Deep sky blue (0, 191, 255, 255)

source

pub const DIM_GRAY: Color = _

Dim gray (105, 105, 105, 255)

source

pub const DODGER_BLUE: Color = _

Dodger blue (30, 144, 255, 255)

source

pub const FIREBRICK: Color = _

Firebrick (178, 34, 34, 255)

source

pub const FLORAL_WHITE: Color = _

Floral white (255, 250, 240, 255)

source

pub const FOREST_GREEN: Color = _

Forest green (34, 139, 34, 255)

source

pub const FUCHSIA: Color = _

Fuchsia (255, 0, 255, 255)

source

pub const GAINSBORO: Color = _

Gainsboro (220, 220, 220, 255)

source

pub const GHOST_WHITE: Color = _

Ghost white (248, 248, 255, 255)

source

pub const GOLD: Color = _

Gold (255, 215, 0, 255)

source

pub const GOLDENROD: Color = _

Goldenrod (218, 165, 32, 255)

source

pub const GRAY: Color = _

Gray (128, 128, 128, 255)

source

pub const GREEN: Color = _

Green (0, 128, 0, 255)

source

pub const GREEN_YELLOW: Color = _

Green yellow (173, 255, 47, 255)

source

pub const HONEYDEW: Color = _

Honeydew (240, 255, 240, 255)

source

pub const HOT_PINK: Color = _

Hot pink (255, 105, 180, 255)

source

pub const INDIAN_RED: Color = _

Indian red (205, 92, 92, 255)

source

pub const INDIGO: Color = _

Indigo (75, 0, 130, 255)

source

pub const IVORY: Color = _

Ivory (255, 255, 240, 255)

source

pub const KHAKI: Color = _

Khaki (240, 230, 140, 255)

source

pub const LAVENDER: Color = _

Lavender (230, 230, 250, 255)

source

pub const LAVENDER_BLUSH: Color = _

Lavender blush (255, 240, 245, 255)

source

pub const LAWN_GREEN: Color = _

Lawn green (124, 252, 0, 255)

source

pub const LEMON_CHIFFON: Color = _

Lemon chiffon (255, 250, 205, 255)

source

pub const LIGHT_BLUE: Color = _

Light blue (173, 216, 230, 255)

source

pub const LIGHT_CORAL: Color = _

Light coral (240, 128, 128, 255)

source

pub const LIGHT_CYAN: Color = _

Light cyan (224, 255, 255, 255)

source

pub const LIGHT_GOLDENROD_YELLOW: Color = _

Light goldenrod yellow (250, 250, 210, 255)

source

pub const LIGHT_GRAY: Color = _

Light gray (211, 211, 211, 255)

source

pub const LIGHT_GREEN: Color = _

Light green (144, 238, 144, 255)

source

pub const LIGHT_PINK: Color = _

Light pink (255, 182, 193, 255)

source

pub const LIGHT_SALMON: Color = _

Light salmon (255, 160, 122, 255)

source

pub const LIGHT_SEA_GREEN: Color = _

Light sea green (32, 178, 170, 255)

source

pub const LIGHT_SKY_BLUE: Color = _

Light sky blue (135, 206, 250, 255)

source

pub const LIGHT_SLATE_GRAY: Color = _

Light slate gray (119, 136, 153, 255)

source

pub const LIGHT_STEEL_BLUE: Color = _

Light steel blue (176, 196, 222, 255)

source

pub const LIGHT_YELLOW: Color = _

Light yellow (255, 255, 224, 255)

source

pub const LIME: Color = _

Lime (0, 255, 0, 255)

source

pub const LIME_GREEN: Color = _

Lime green (50, 205, 50, 255)

source

pub const LINEN: Color = _

Linen (250, 240, 230, 255)

source

pub const MAGENTA: Color = _

Magenta (255, 0, 255, 255)

source

pub const MAROON: Color = _

Maroon (128, 0, 0, 255)

source

pub const MEDIUM_AQUAMARINE: Color = _

Medium aquamarine (102, 205, 170, 255)

source

pub const MEDIUM_BLUE: Color = _

Medium blue (0, 0, 205, 255)

source

pub const MEDIUM_ORCHID: Color = _

Medium orchid (186, 85, 211, 255)

source

pub const MEDIUM_PURPLE: Color = _

Medium purple (147, 112, 219, 255)

source

pub const MEDIUM_SEA_GREEN: Color = _

Medium sea green (60, 179, 113, 255)

source

pub const MEDIUM_SLATE_BLUE: Color = _

Medium slate blue (123, 104, 238, 255)

source

pub const MEDIUM_SPRING_GREEN: Color = _

Medium spring green (0, 250, 154, 255)

source

pub const MEDIUM_TURQUOISE: Color = _

Medium turquoise (72, 209, 204, 255)

source

pub const MEDIUM_VIOLET_RED: Color = _

Medium violet red (199, 21, 133, 255)

source

pub const MIDNIGHT_BLUE: Color = _

Midnight blue (25, 25, 112, 255)

source

pub const MINT_CREAM: Color = _

Mint cream (245, 255, 250, 255)

source

pub const MISTY_ROSE: Color = _

Misty rose (255, 228, 225, 255)

source

pub const MOCCASIN: Color = _

Moccasin (255, 228, 181, 255)

source

pub const NAVAJO_WHITE: Color = _

Navajo white (255, 222, 173, 255)

source

pub const NAVY: Color = _

Navy (0, 0, 128, 255)

source

pub const OLD_LACE: Color = _

Old lace (253, 245, 230, 255)

source

pub const OLIVE: Color = _

Olive (128, 128, 0, 255)

source

pub const OLIVE_DRAB: Color = _

Olive drab (107, 142, 35, 255)

source

pub const ORANGE: Color = _

Orange (255, 165, 0, 255)

source

pub const ORANGE_RED: Color = _

Orange red (255, 69, 0, 255)

source

pub const ORCHID: Color = _

Orchid (218, 112, 214, 255)

source

pub const PALE_GOLDENROD: Color = _

Pale goldenrod (238, 232, 170, 255)

source

pub const PALE_GREEN: Color = _

Pale green (152, 251, 152, 255)

source

pub const PALE_TURQUOISE: Color = _

Pale turquoise (175, 238, 238, 255)

source

pub const PALE_VIOLET_RED: Color = _

Pale violet red (219, 112, 147, 255)

source

pub const PAPAYA_WHIP: Color = _

Papaya whip (255, 239, 213, 255)

source

pub const PEACH_PUFF: Color = _

Peach puff (255, 218, 185, 255)

source

pub const PERU: Color = _

Peru (205, 133, 63, 255)

source

pub const PINK: Color = _

Pink (255, 192, 203, 255)

source

pub const PLUM: Color = _

Plum (221, 160, 221, 255)

source

pub const POWDER_BLUE: Color = _

Powder blue (176, 224, 230, 255)

source

pub const PURPLE: Color = _

Purple (128, 0, 128, 255)

source

pub const REBECCA_PURPLE: Color = _

Rebecca purple (102, 51, 153, 255)

source

pub const RED: Color = _

Red (255, 0, 0, 255)

source

pub const ROSY_BROWN: Color = _

Rosy brown (188, 143, 143, 255)

source

pub const ROYAL_BLUE: Color = _

Royal blue (65, 105, 225, 255)

source

pub const SADDLE_BROWN: Color = _

Saddle brown (139, 69, 19, 255)

source

pub const SALMON: Color = _

Salmon (250, 128, 114, 255)

source

pub const SANDY_BROWN: Color = _

Sandy brown (244, 164, 96, 255)

source

pub const SEA_GREEN: Color = _

Sea green (46, 139, 87, 255)

source

pub const SEASHELL: Color = _

Seashell (255, 245, 238, 255)

source

pub const SIENNA: Color = _

Sienna (160, 82, 45, 255)

source

pub const SILVER: Color = _

Silver (192, 192, 192, 255)

source

pub const SKY_BLUE: Color = _

Sky blue (135, 206, 235, 255)

source

pub const SLATE_BLUE: Color = _

Slate blue (106, 90, 205, 255)

source

pub const SLATE_GRAY: Color = _

Slate gray (112, 128, 144, 255)

source

pub const SNOW: Color = _

Snow (255, 250, 250, 255)

source

pub const SPRING_GREEN: Color = _

Spring green (0, 255, 127, 255)

source

pub const STEEL_BLUE: Color = _

Steel blue (70, 130, 180, 255)

source

pub const TAN: Color = _

Tan (210, 180, 140, 255)

source

pub const TEAL: Color = _

Teal (0, 128, 128, 255)

source

pub const THISTLE: Color = _

Thistle (216, 191, 216, 255)

source

pub const TOMATO: Color = _

Tomato (255, 99, 71, 255)

source

pub const TRANSPARENT: Color = _

Transparent (0, 0, 0, 0)

source

pub const TURQUOISE: Color = _

Turquoise (64, 224, 208, 255)

source

pub const VIOLET: Color = _

Violet (238, 130, 238, 255)

source

pub const WHEAT: Color = _

Wheat (245, 222, 179, 255)

source

pub const WHITE: Color = _

White (255, 255, 255, 255)

source

pub const WHITE_SMOKE: Color = _

White smoke (245, 245, 245, 255)

source

pub const YELLOW: Color = _

Yellow (255, 255, 0, 255)

source

pub const YELLOW_GREEN: Color = _

Yellow green (154, 205, 50, 255)

Trait Implementations§

source§

impl Clone for Color

source§

fn clone(&self) -> Color

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Color

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for Color

source§

fn default() -> Color

Returns the “default value” for a type. Read more
source§

impl From<[u8; 3]> for Color

source§

fn from(rgb: [u8; 3]) -> Color

Converts to this type from the input type.
source§

impl From<[u8; 4]> for Color

source§

fn from(rgba: [u8; 4]) -> Color

Converts to this type from the input type.
source§

impl Hash for Color

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Color

source§

fn cmp(&self, other: &Color) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Color

source§

fn eq(&self, other: &Color) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Color

source§

fn partial_cmp(&self, other: &Color) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Color

source§

impl Eq for Color

source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: Any,

source§

fn as_dyn_any(&self) -> &(dyn Any + 'static)

Return self.
source§

fn as_mut_dyn_any(&mut self) -> &mut (dyn Any + 'static)

Return self.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<T> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

source§

fn null_value() -> T

The none-equivalent value.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T

source§

impl<T> WasmNotSend for T
where T: Send,

source§

impl<T> WasmNotSendSync for T

source§

impl<T> WasmNotSync for T
where T: Sync,