Struct Color

Source
pub struct Color(/* private fields */);
Expand description

A color with red, green, blue, and alpha channel.

Implementations§

Source§

impl Color

Source

pub fn is_empty(&self) -> bool

Check if the color is opaque.

Source§

impl Color

Source

pub const ALICE_BLUE: Self

#F0F8FF = rgb(240 248 255)

Source

pub const ANTIQUE_WHITE: Self

#FAEBD7 = rgb(250 235 215)

Source

pub const AQUA: Self

#00FFFF = rgb(0 255 255)

Source

pub const AQUA_MARINE: Self

#7FFFD4 = rgb(127 255 212)

Source

pub const AZURE: Self

#F0FFFF = rgb(240 255 255)

Source

pub const BEIGE: Self

#F5F5DC = rgb(245 245 220)

Source

pub const BISQUE: Self

#FFE4C4 = rgb(255 228 196)

Source

pub const BLACK: Self

#000000 = rgb(0 0 0)

Source

pub const BLANCHEDALMOND: Self

#FFEBCD = rgb(255 235 205)

Source

pub const BLUE: Self

#0000FF = rgb(0 0 255)

Source

pub const BLUE_VIOLET: Self

#8A2BE2 = rgb(138 43 226)

Source

pub const BROWN: Self

#A52A2A = rgb(165 42 42)

Source

pub const BURLYWOOD: Self

#DEB887 = rgb(222 184 135)

Source

pub const CADET_BLUE: Self

#5F9EA0 = rgb(95 158 160)

Source

pub const CHARTREUSE: Self

#7FFF00 = rgb(127 255 0)

Source

pub const CHOCOLATE: Self

#D2691E = rgb(210 105 30)

Source

pub const CORAL: Self

#FF7F50 = rgb(255 127 80)

Source

pub const CORNFLOWER_BLUE: Self

#6495ED = rgb(100 149 237)

Source

pub const CORNSILK: Self

#FFF8DC = rgb(255 248 220)

Source

pub const CRIMSON: Self

#DC143C = rgb(220 20 60)

Source

pub const CYAN: Self

#00FFFF = rgb(0 255 255)

Source

pub const DARK_BLUE: Self

#00008B = rgb(0 0 139)

Source

pub const DARK_CYAN: Self

#008B8B = rgb(0 139 139)

Source

pub const DARK_GOLDENROD: Self

#B8860B = rgb(184 134 11)

Source

pub const DARK_GRAY: Self

#A9A9A9 = rgb(169 169 169)

Source

pub const DARK_GREEN: Self

#006400 = rgb(0 100 0)

Source

pub const DARK_GREY: Self

#A9A9A9 = rgb(169 169 169)

Source

pub const DARK_KHAKI: Self

#BDB76B = rgb(189 183 107)

Source

pub const DARK_MAGENTA: Self

#8B008B = rgb(139 0 139)

Source

pub const DARK_OLIVE_GREEN: Self

#556B2F = rgb(85 107 47)

Source

pub const DARK_ORANGE: Self

#FF8C00 = rgb(255 140 0)

Source

pub const DARK_ORCHID: Self

#9932CC = rgb(153 50 204)

Source

pub const DARK_RED: Self

#8B0000 = rgb(139 0 0)

Source

pub const DARK_SALMON: Self

#E9967A = rgb(233 150 122)

Source

pub const DARK_SEAGREEN: Self

#8FBC8F = rgb(143 188 143)

Source

pub const DARK_SLATE_BLUE: Self

#483D8B = rgb(72 61 139)

Source

pub const DARK_SLATEGRAY: Self

#2F4F4F = rgb(47 79 79)

Source

pub const DARK_SLATEGREY: Self

#2F4F4F = rgb(47 79 79)

Source

pub const DARK_TURQUOISE: Self

#00CED1 = rgb(0 206 209)

Source

pub const DARK_VIOLET: Self

#9400D3 = rgb(148 0 211)

Source

pub const DEEP_PINK: Self

#FF1493 = rgb(255 20 147)

Source

pub const DEEP_SKYBLUE: Self

#00BFFF = rgb(0 191 255)

Source

pub const DIMGRAY: Self

#696969 = rgb(105 105 105)

Source

pub const DIMGREY: Self

#696969 = rgb(105 105 105)

Source

pub const DODGER_BLUE: Self

#1E90FF = rgb(30 144 255)

Source

pub const FIREBRICK: Self

#B22222 = rgb(178 34 34)

Source

pub const FLORAL_WHITE: Self

#FFFAF0 = rgb(255 250 240)

Source

pub const FORESTGREEN: Self

#228B22 = rgb(34 139 34)

Source

pub const FUCHSIA: Self

#FF00FF = rgb(255 0 255)

Source

pub const GAINSBORO: Self

#DCDCDC = rgb(220 220 220)

Source

pub const GHOST_WHITE: Self

#F8F8FF = rgb(248 248 255)

Source

pub const GOLDEN_ROD: Self

#DAA520 = rgb(218 165 32)

Source

pub const GOLD: Self

#FFD700 = rgb(255 215 0)

Source

pub const GRAY: Self

#808080 = rgb(128 128 128)

Source

pub const GREEN: Self

#008000 = rgb(0 128 0)

Source

pub const GREEN_YELLOW: Self

#ADFF2F = rgb(173 255 47)

Source

pub const GREY: Self

#808080 = rgb(128 128 128)

Source

pub const HONEYDEW: Self

#F0FFF0 = rgb(240 255 240)

Source

pub const HOTPINK: Self

#FF69B4 = rgb(255 105 180)

Source

pub const INDIANRED: Self

#CD5C5C = rgb(205 92 92)

Source

pub const INDIGO: Self

#4B0082 = rgb(75 0 130)

Source

pub const IVORY: Self

#FFFFF0 = rgb(255 255 240)

Source

pub const KHAKI: Self

#F0E68C = rgb(240 230 140)

Source

pub const LAVENDERBLUSH: Self

#FFF0F5 = rgb(255 240 245)

Source

pub const LAVENDER: Self

#E6E6FA = rgb(230 230 250)

Source

pub const LAWN_GREEN: Self

#7CFC00 = rgb(124 252 0)

Source

pub const LEMON_CHIFFON: Self

#FFFACD = rgb(255 250 205)

Source

pub const LIGHT_BLUE: Self

#ADD8E6 = rgb(173 216 230)

Source

pub const LIGHT_CORAL: Self

#F08080 = rgb(240 128 128)

Source

pub const LIGHT_CYAN: Self

#E0FFFF = rgb(224 255 255)

Source

pub const LIGHT_GOLDEN_ROD_YELLOW: Self

#FAFAD2 = rgb(250 250 210)

Source

pub const LIGHT_GRAY: Self

#D3D3D3 = rgb(211 211 211)

Source

pub const LIGHT_GREEN: Self

#90EE90 = rgb(144 238 144)

Source

pub const LIGHT_GREY: Self

#D3D3D3 = rgb(211 211 211)

Source

pub const LIGHT_PINK: Self

#FFB6C1 = rgb(255 182 193)

Source

pub const LIGHT_SALMON: Self

#FFA07A = rgb(255 160 122)

Source

pub const LIGHT_SEA_GREEN: Self

#20B2AA = rgb(32 178 170)

Source

pub const LIGHT_SKY_BLUE: Self

#87CEFA = rgb(135 206 250)

Source

pub const LIGHT_SLATE_GRAY: Self

#778899 = rgb(119 136 153)

Source

pub const LIGHT_SLATE_GREY: Self

#778899 = rgb(119 136 153)

Source

pub const LIGHT_STEEL_BLUE: Self

#B0C4DE = rgb(176 196 222)

Source

pub const LIGHT_YELLOW: Self

#FFFFE0 = rgb(255 255 224)

Source

pub const LIME: Self

#00FF00 = rgb(0 255 0)

Source

pub const LIME_GREEN: Self

#32CD32 = rgb(50 205 50)

Source

pub const LINEN: Self

#FAF0E6 = rgb(250 240 230)

Source

pub const MAGENTA: Self

#FF00FF = rgb(255 0 255)

Source

pub const MAROON: Self

#800000 = rgb(128 0 0)

Source

pub const MEDIUM_AQUA_MARINE: Self

#66CDAA = rgb(102 205 170)

Source

pub const MEDIUM_BLUE: Self

#0000CD = rgb(0 0 205)

Source

pub const MEDIUM_ORCHID: Self

#BA55D3 = rgb(186 85 211)

Source

pub const MEDIUM_PURPLE: Self

#9370DB = rgb(147 112 219)

Source

pub const MEDIUM_SEA_GREEN: Self

#3CB371 = rgb(60 179 113)

Source

pub const MEDIUM_SLATE_BLUE: Self

#7B68EE = rgb(123 104 238)

Source

pub const MEDIUM_SPRING_GREEN: Self

#00FA9A = rgb(0 250 154)

Source

pub const MEDIUM_TURQUOISE: Self

#48D1CC = rgb(72 209 204)

Source

pub const MEDIUM_VIOLET_RED: Self

#C71585 = rgb(199 21 133)

Source

pub const MIDNIGHT_BLUE: Self

#191970 = rgb(25 25 112)

Source

pub const MINTCREAM: Self

#F5FFFA = rgb(245 255 250)

Source

pub const MISTYROSE: Self

#FFE4E1 = rgb(255 228 225)

Source

pub const MOCCASIN: Self

#FFE4B5 = rgb(255 228 181)

Source

pub const NAVAJO_WHITE: Self

#FFDEAD = rgb(255 222 173)

Source

pub const NAVY: Self

#000080 = rgb(0 0 128)

Source

pub const OLDLACE: Self

#FDF5E6 = rgb(253 245 230)

Source

pub const OLIVE: Self

#808000 = rgb(128 128 0)

Source

pub const OLIVEDRAB: Self

#6B8E23 = rgb(107 142 35)

Source

pub const ORANGE: Self

#FFA500 = rgb(255 165 0)

Source

pub const ORANGERED: Self

#FF4500 = rgb(255 69 0)

Source

pub const ORCHID: Self

#DA70D6 = rgb(218 112 214)

Source

pub const PALE_GOLDEN_ROD: Self

#EEE8AA = rgb(238 232 170)

Source

pub const PALE_GREEN: Self

#98FB98 = rgb(152 251 152)

Source

pub const PALE_TURQUOISE: Self

#AFEEEE = rgb(175 238 238)

Source

pub const PALE_VIOLET_RED: Self

#DB7093 = rgb(219 112 147)

Source

pub const PAPAYAWHIP: Self

#FFEFD5 = rgb(255 239 213)

Source

pub const PEACHPUFF: Self

#FFDAB9 = rgb(255 218 185)

Source

pub const PERU: Self

#CD853F = rgb(205 133 63)

Source

pub const PINK: Self

#FFC0CB = rgb(255 192 203)

Source

pub const PLUM: Self

#DDA0DD = rgb(221 160 221)

Source

pub const POWDER_BLUE: Self

#B0E0E6 = rgb(176 224 230)

Source

pub const PURPLE: Self

#800080 = rgb(128 0 128)

Source

pub const REBECCA_PURPLE: Self

#663399 = rgb(102 51 153)

Source

pub const RED: Self

#FF0000 = rgb(255 0 0)

Source

pub const ROSY_BROWN: Self

#BC8F8F = rgb(188 143 143)

Source

pub const ROYAL_BLUE: Self

#4169E1 = rgb(65 105 225)

Source

pub const SADDLE_BROWN: Self

#8B4513 = rgb(139 69 19)

Source

pub const SALMON: Self

#FA8072 = rgb(250 128 114)

Source

pub const SANDY_BROWN: Self

#F4A460 = rgb(244 164 96)

Source

pub const SEA_GREEN: Self

#2E8B57 = rgb(46 139 87)

Source

pub const SEA_SHELL: Self

#FFF5EE = rgb(255 245 238)

Source

pub const SIENNA: Self

#A0522D = rgb(160 82 45)

Source

pub const SILVER: Self

#C0C0C0 = rgb(192 192 192)

Source

pub const SKY_BLUE: Self

#87CEEB = rgb(135 206 235)

Source

pub const SLATE_BLUE: Self

#6A5ACD = rgb(106 90 205)

Source

pub const SLATE_GRAY: Self

#708090 = rgb(112 128 144)

Source

pub const SLATE_GREY: Self

#708090 = rgb(112 128 144)

Source

pub const SNOW: Self

#FFFAFA = rgb(255 250 250)

Source

pub const SPRING_GREEN: Self

#00FF7F = rgb(0 255 127)

Source

pub const STEEL_BLUE: Self

#4682B4 = rgb(70 130 180)

Source

pub const TAN: Self

#D2B48C = rgb(210 180 140)

Source

pub const TEAL: Self

#008080 = rgb(0 128 128)

Source

pub const THISTLE: Self

#D8BFD8 = rgb(216 191 216)

Source

pub const TOMATO: Self

#FF6347 = rgb(255 99 71)

Source

pub const TURQUOISE: Self

#40E0D0 = rgb(64 224 208)

Source

pub const VIOLET: Self

#EE82EE = rgb(238 130 238)

Source

pub const WHEAT: Self

#F5DEB3 = rgb(245 222 179)

Source

pub const WHITE: Self

#FFFFFF = rgb(255 255 255)

Source

pub const WHITE_SMOKE: Self

#F5F5F5 = rgb(245 245 245)

Source

pub const YELLOW: Self

#FFFF00 = rgb(255 255 0)

Source

pub const YELLOW_GREEN: Self

#9ACD32 = rgb(154 205 50)

Source§

impl Color

Source

pub const fn new(red: u8, green: u8, blue: u8, alpha: u8) -> Self

Creates a new RGBA color.

Source

pub const fn view(&self) -> (u8, u8, u8, u8)

Creates a new RGBA color.

Trait Implementations§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate 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

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

impl Default for Color

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Color

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Color

Source§

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

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

impl From<&Color> for FillStyle

Source§

fn from(c: &Color) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 3]> for Color

Source§

fn from(c: [u8; 3]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 4]> for Color

Source§

fn from(c: [u8; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<(f32, f32, f32)> for Color

Source§

fn from(c: (f32, f32, f32)) -> Self

Converts to this type from the input type.
Source§

impl From<(f32, f32, f32, f32)> for Color

Source§

fn from(c: (f32, f32, f32, f32)) -> Self

Converts to this type from the input type.
Source§

impl From<(u8, u8, u8)> for Color

Source§

fn from(c: (u8, u8, u8)) -> Self

Converts to this type from the input type.
Source§

impl From<(u8, u8, u8, u8)> for Color

Source§

fn from(c: (u8, u8, u8, u8)) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for FillStyle

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Texture

Source§

fn from(color: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for u32

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Color

Source§

fn from(c: u32) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Color

Source§

type Err = GraphicsError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Color

Source§

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

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 LowerHex for Color

Source§

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

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

impl PartialEq for Color

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Color

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl UpperHex for Color

Source§

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

Formats the value using the given formatter. 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<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: FloatComponent, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
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> 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

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

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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>,

Source§

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, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,