Color

Struct Color 

Source
pub struct Color { /* private fields */ }
Expand description

A color in a color-space with an associated alpha channel.

Implementations§

Source§

impl Color

Source

pub fn rgba(red: u8, green: u8, blue: u8, alpha: f32) -> Color

This function returns a new translucent color in the sRGB color space with the given coordinates and alpha channel.

Source

pub fn rgb(red: u8, green: u8, blue: u8) -> Color

This function returns a new opaque color in the sRGB color space with the given coordinates.

Source

pub fn hexa(hex: u32, alpha: f32) -> Color

This function returns a new translucent color in the sRGB color space with the given hex-encoded coordinates.

Source

pub fn hex(hex: u32) -> Color

This function returns a new opaque color in the sRGB color space with the given hex-encoded coordinates.

Source

pub fn hsla(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> Color

This function returns a new translucent color in the sRGB color space with the given coordinates after converting from the alternative HSL representation to RGB.

Source

pub fn hsl(hue: f32, saturation: f32, lightness: f32) -> Color

This function returns a new opaque color in the sRGB color space with the given coordinates after converting from the alternative HSL representation to RGB.

Source

pub fn display_p3_rgba(red: u8, green: u8, blue: u8, alpha: f32) -> Color

This function returns a new translucent color in the Display-P3 color space with the given coordinates and alpha channel.

Source

pub fn display_p3_rgb(red: u8, green: u8, blue: u8) -> Color

This functions returns a new opaque color in the Display-P3 color space with the given coordinates.

Source

pub fn transparent() -> Color

This function returns an unbiased transparent color. Specifically, when blending a non-transparent color with a transparent color, the resulting color will have the same color space and coordinate as the non-transparent color, and only the alpha channel will be blended.

Source

pub fn alpha(&self) -> f32

This function returns the additional alpha-component of this color.

Source

pub fn mix(self, other: Color, factor: f32) -> Color

Blends the given color with another color using the given factor (between 0.0 and 1.0).

Source

pub fn to_display_p3(&self) -> Alpha<Rgb<DisplayP3>, f32>

This function converts the color to the Display-P3 color space (if necessary) and returns the result.

Source

pub fn to_srgb(&self) -> Alpha<Rgb, f32>

This function converts the color to the sRGB color space (if necessary) and returns the result.

Source

pub fn to_hex(&self) -> u32

Converts this color to sRGB and returns the resulting hex code.

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

Source§

fn convert(self, _env: &Env<'_>) -> Color

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

Source§

type Err = Error

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

fn from_str(s: &str) -> Result<Color, <Color as FromStr>::Err>

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

impl NamedColor for Color

Source§

fn aliceblue() -> Color

Returns a CSS-compliant named color for aliceblue in the sRGB color space.
Source§

fn antiquewhite() -> Color

Returns a CSS-compliant named color for antiquewhite in the sRGB color space.
Source§

fn aqua() -> Color

Returns a CSS-compliant named color for aqua in the sRGB color space.
Source§

fn aquamarine() -> Color

Returns a CSS-compliant named color for aquamarine in the sRGB color space.
Source§

fn azure() -> Color

Returns a CSS-compliant named color for azure in the sRGB color space.
Source§

fn beige() -> Color

Returns a CSS-compliant named color for beige in the sRGB color space.
Source§

fn bisque() -> Color

Returns a CSS-compliant named color for bisque in the sRGB color space.
Source§

fn black() -> Color

Returns a CSS-compliant named color for black in the sRGB color space.
Source§

fn blanchedalmond() -> Color

Returns a CSS-compliant named color for blanchedalmond in the sRGB color space.
Source§

fn blue() -> Color

Returns a CSS-compliant named color for blue in the sRGB color space.
Source§

fn blueviolet() -> Color

Returns a CSS-compliant named color for blueviolet in the sRGB color space.
Source§

fn brown() -> Color

Returns a CSS-compliant named color for brown in the sRGB color space.
Source§

fn burlywood() -> Color

Returns a CSS-compliant named color for burlywood in the sRGB color space.
Source§

fn cadetblue() -> Color

Returns a CSS-compliant named color for cadetblue in the sRGB color space.
Source§

fn chartreuse() -> Color

Returns a CSS-compliant named color for chartreuse in the sRGB color space.
Source§

fn chocolate() -> Color

Returns a CSS-compliant named color for chocolate in the sRGB color space.
Source§

fn coral() -> Color

Returns a CSS-compliant named color for coral in the sRGB color space.
Source§

fn cornflowerblue() -> Color

Returns a CSS-compliant named color for cornflowerblue in the sRGB color space.
Source§

fn cornsilk() -> Color

Returns a CSS-compliant named color for cornsilk in the sRGB color space.
Source§

fn crimson() -> Color

Returns a CSS-compliant named color for crimson in the sRGB color space.
Source§

fn cyan() -> Color

Returns a CSS-compliant named color for cyan in the sRGB color space.
Source§

fn darkblue() -> Color

Returns a CSS-compliant named color for darkblue in the sRGB color space.
Source§

fn darkcyan() -> Color

Returns a CSS-compliant named color for darkcyan in the sRGB color space.
Source§

fn darkgoldenrod() -> Color

Returns a CSS-compliant named color for darkgoldenrod in the sRGB color space.
Source§

fn darkgray() -> Color

Returns a CSS-compliant named color for darkgray in the sRGB color space.
Source§

fn darkgreen() -> Color

Returns a CSS-compliant named color for darkgreen in the sRGB color space.
Source§

fn darkgrey() -> Color

Returns a CSS-compliant named color for darkgrey in the sRGB color space.
Source§

fn darkkhaki() -> Color

Returns a CSS-compliant named color for darkkhaki in the sRGB color space.
Source§

fn darkmagenta() -> Color

Returns a CSS-compliant named color for darkmagenta in the sRGB color space.
Source§

fn darkolivegreen() -> Color

Returns a CSS-compliant named color for darkolivegreen in the sRGB color space.
Source§

fn darkorange() -> Color

Returns a CSS-compliant named color for darkorange in the sRGB color space.
Source§

fn darkorchid() -> Color

Returns a CSS-compliant named color for darkorchid in the sRGB color space.
Source§

fn darkred() -> Color

Returns a CSS-compliant named color for darkred in the sRGB color space.
Source§

fn darksalmon() -> Color

Returns a CSS-compliant named color for darksalmon in the sRGB color space.
Source§

fn darkseagreen() -> Color

Returns a CSS-compliant named color for darkseagreen in the sRGB color space.
Source§

fn darkslateblue() -> Color

Returns a CSS-compliant named color for darkslateblue in the sRGB color space.
Source§

fn darkslategray() -> Color

Returns a CSS-compliant named color for darkslategray in the sRGB color space.
Source§

fn darkslategrey() -> Color

Returns a CSS-compliant named color for darkslategrey in the sRGB color space.
Source§

fn darkturquoise() -> Color

Returns a CSS-compliant named color for darkturquoise in the sRGB color space.
Source§

fn darkviolet() -> Color

Returns a CSS-compliant named color for darkviolet in the sRGB color space.
Source§

fn deeppink() -> Color

Returns a CSS-compliant named color for deeppink in the sRGB color space.
Source§

fn deepskyblue() -> Color

Returns a CSS-compliant named color for deepskyblue in the sRGB color space.
Source§

fn dimgray() -> Color

Returns a CSS-compliant named color for dimgray in the sRGB color space.
Source§

fn dimgrey() -> Color

Returns a CSS-compliant named color for dimgrey in the sRGB color space.
Source§

fn dodgerblue() -> Color

Returns a CSS-compliant named color for dodgerblue in the sRGB color space.
Source§

fn firebrick() -> Color

Returns a CSS-compliant named color for firebrick in the sRGB color space.
Source§

fn floralwhite() -> Color

Returns a CSS-compliant named color for floralwhite in the sRGB color space.
Source§

fn forestgreen() -> Color

Returns a CSS-compliant named color for forestgreen in the sRGB color space.
Source§

fn fuchsia() -> Color

Returns a CSS-compliant named color for fuchsia in the sRGB color space.
Source§

fn gainsboro() -> Color

Returns a CSS-compliant named color for gainsboro in the sRGB color space.
Source§

fn ghostwhite() -> Color

Returns a CSS-compliant named color for ghostwhite in the sRGB color space.
Source§

fn gold() -> Color

Returns a CSS-compliant named color for gold in the sRGB color space.
Source§

fn goldenrod() -> Color

Returns a CSS-compliant named color for goldenrod in the sRGB color space.
Source§

fn gray() -> Color

Returns a CSS-compliant named color for gray in the sRGB color space.
Source§

fn green() -> Color

Returns a CSS-compliant named color for green in the sRGB color space.
Source§

fn greenyellow() -> Color

Returns a CSS-compliant named color for greenyellow in the sRGB color space.
Source§

fn grey() -> Color

Returns a CSS-compliant named color for grey in the sRGB color space.
Source§

fn honeydew() -> Color

Returns a CSS-compliant named color for honeydew in the sRGB color space.
Source§

fn hotpink() -> Color

Returns a CSS-compliant named color for hotpink in the sRGB color space.
Source§

fn indianred() -> Color

Returns a CSS-compliant named color for indianred in the sRGB color space.
Source§

fn indigo() -> Color

Returns a CSS-compliant named color for indigo in the sRGB color space.
Source§

fn ivory() -> Color

Returns a CSS-compliant named color for ivory in the sRGB color space.
Source§

fn khaki() -> Color

Returns a CSS-compliant named color for khaki in the sRGB color space.
Source§

fn lavender() -> Color

Returns a CSS-compliant named color for lavender in the sRGB color space.
Source§

fn lavenderblush() -> Color

Returns a CSS-compliant named color for lavenderblush in the sRGB color space.
Source§

fn lawngreen() -> Color

Returns a CSS-compliant named color for lawngreen in the sRGB color space.
Source§

fn lemonchiffon() -> Color

Returns a CSS-compliant named color for lemonchiffon in the sRGB color space.
Source§

fn lightblue() -> Color

Returns a CSS-compliant named color for lightblue in the sRGB color space.
Source§

fn lightcoral() -> Color

Returns a CSS-compliant named color for lightcoral in the sRGB color space.
Source§

fn lightcyan() -> Color

Returns a CSS-compliant named color for lightcyan in the sRGB color space.
Source§

fn lightgoldenrodyellow() -> Color

Returns a CSS-compliant named color for lightgoldenrodyellow in the sRGB color space.
Source§

fn lightgray() -> Color

Returns a CSS-compliant named color for lightgray in the sRGB color space.
Source§

fn lightgreen() -> Color

Returns a CSS-compliant named color for lightgreen in the sRGB color space.
Source§

fn lightgrey() -> Color

Returns a CSS-compliant named color for lightgrey in the sRGB color space.
Source§

fn lightpink() -> Color

Returns a CSS-compliant named color for lightpink in the sRGB color space.
Source§

fn lightsalmon() -> Color

Returns a CSS-compliant named color for lightsalmon in the sRGB color space.
Source§

fn lightseagreen() -> Color

Returns a CSS-compliant named color for lightseagreen in the sRGB color space.
Source§

fn lightskyblue() -> Color

Returns a CSS-compliant named color for lightskyblue in the sRGB color space.
Source§

fn lightslategray() -> Color

Returns a CSS-compliant named color for lightslategray in the sRGB color space.
Source§

fn lightslategrey() -> Color

Returns a CSS-compliant named color for lightslategrey in the sRGB color space.
Source§

fn lightsteelblue() -> Color

Returns a CSS-compliant named color for lightsteelblue in the sRGB color space.
Source§

fn lightyellow() -> Color

Returns a CSS-compliant named color for lightyellow in the sRGB color space.
Source§

fn lime() -> Color

Returns a CSS-compliant named color for lime in the sRGB color space.
Source§

fn limegreen() -> Color

Returns a CSS-compliant named color for limegreen in the sRGB color space.
Source§

fn linen() -> Color

Returns a CSS-compliant named color for linen in the sRGB color space.
Source§

fn magenta() -> Color

Returns a CSS-compliant named color for magenta in the sRGB color space.
Source§

fn maroon() -> Color

Returns a CSS-compliant named color for maroon in the sRGB color space.
Source§

fn mediumaquamarine() -> Color

Returns a CSS-compliant named color for mediumaquamarine in the sRGB color space.
Source§

fn mediumblue() -> Color

Returns a CSS-compliant named color for mediumblue in the sRGB color space.
Source§

fn mediumorchid() -> Color

Returns a CSS-compliant named color for mediumorchid in the sRGB color space.
Source§

fn mediumpurple() -> Color

Returns a CSS-compliant named color for mediumpurple in the sRGB color space.
Source§

fn mediumseagreen() -> Color

Returns a CSS-compliant named color for mediumseagreen in the sRGB color space.
Source§

fn mediumslateblue() -> Color

Returns a CSS-compliant named color for mediumslateblue in the sRGB color space.
Source§

fn mediumspringgreen() -> Color

Returns a CSS-compliant named color for mediumspringgreen in the sRGB color space.
Source§

fn mediumturquoise() -> Color

Returns a CSS-compliant named color for mediumturquoise in the sRGB color space.
Source§

fn mediumvioletred() -> Color

Returns a CSS-compliant named color for mediumvioletred in the sRGB color space.
Source§

fn midnightblue() -> Color

Returns a CSS-compliant named color for midnightblue in the sRGB color space.
Source§

fn mintcream() -> Color

Returns a CSS-compliant named color for mintcream in the sRGB color space.
Source§

fn mistyrose() -> Color

Returns a CSS-compliant named color for mistyrose in the sRGB color space.
Source§

fn moccasin() -> Color

Returns a CSS-compliant named color for moccasin in the sRGB color space.
Source§

fn navajowhite() -> Color

Returns a CSS-compliant named color for navajowhite in the sRGB color space.
Source§

fn navy() -> Color

Returns a CSS-compliant named color for navy in the sRGB color space.
Source§

fn oldlace() -> Color

Returns a CSS-compliant named color for oldlace in the sRGB color space.
Source§

fn olive() -> Color

Returns a CSS-compliant named color for olive in the sRGB color space.
Source§

fn olivedrab() -> Color

Returns a CSS-compliant named color for olivedrab in the sRGB color space.
Source§

fn orange() -> Color

Returns a CSS-compliant named color for orange in the sRGB color space.
Source§

fn orangered() -> Color

Returns a CSS-compliant named color for orangered in the sRGB color space.
Source§

fn orchid() -> Color

Returns a CSS-compliant named color for orchid in the sRGB color space.
Source§

fn palegoldenrod() -> Color

Returns a CSS-compliant named color for palegoldenrod in the sRGB color space.
Source§

fn palegreen() -> Color

Returns a CSS-compliant named color for palegreen in the sRGB color space.
Source§

fn paleturquoise() -> Color

Returns a CSS-compliant named color for paleturquoise in the sRGB color space.
Source§

fn palevioletred() -> Color

Returns a CSS-compliant named color for palevioletred in the sRGB color space.
Source§

fn papayawhip() -> Color

Returns a CSS-compliant named color for papayawhip in the sRGB color space.
Source§

fn peachpuff() -> Color

Returns a CSS-compliant named color for peachpuff in the sRGB color space.
Source§

fn peru() -> Color

Returns a CSS-compliant named color for peru in the sRGB color space.
Source§

fn pink() -> Color

Returns a CSS-compliant named color for pink in the sRGB color space.
Source§

fn plum() -> Color

Returns a CSS-compliant named color for plum in the sRGB color space.
Source§

fn powderblue() -> Color

Returns a CSS-compliant named color for powderblue in the sRGB color space.
Source§

fn purple() -> Color

Returns a CSS-compliant named color for purple in the sRGB color space.
Source§

fn rebeccapurple() -> Color

Returns a CSS-compliant named color for rebeccapurple in the sRGB color space.
Source§

fn red() -> Color

Returns a CSS-compliant named color for red in the sRGB color space.
Source§

fn rosybrown() -> Color

Returns a CSS-compliant named color for rosybrown in the sRGB color space.
Source§

fn royalblue() -> Color

Returns a CSS-compliant named color for royalblue in the sRGB color space.
Source§

fn saddlebrown() -> Color

Returns a CSS-compliant named color for saddlebrown in the sRGB color space.
Source§

fn salmon() -> Color

Returns a CSS-compliant named color for salmon in the sRGB color space.
Source§

fn sandybrown() -> Color

Returns a CSS-compliant named color for sandybrown in the sRGB color space.
Source§

fn seagreen() -> Color

Returns a CSS-compliant named color for seagreen in the sRGB color space.
Source§

fn seashell() -> Color

Returns a CSS-compliant named color for seashell in the sRGB color space.
Source§

fn sienna() -> Color

Returns a CSS-compliant named color for sienna in the sRGB color space.
Source§

fn silver() -> Color

Returns a CSS-compliant named color for silver in the sRGB color space.
Source§

fn skyblue() -> Color

Returns a CSS-compliant named color for skyblue in the sRGB color space.
Source§

fn slateblue() -> Color

Returns a CSS-compliant named color for slateblue in the sRGB color space.
Source§

fn slategray() -> Color

Returns a CSS-compliant named color for slategray in the sRGB color space.
Source§

fn slategrey() -> Color

Returns a CSS-compliant named color for slategrey in the sRGB color space.
Source§

fn snow() -> Color

Returns a CSS-compliant named color for snow in the sRGB color space.
Source§

fn springgreen() -> Color

Returns a CSS-compliant named color for springgreen in the sRGB color space.
Source§

fn steelblue() -> Color

Returns a CSS-compliant named color for steelblue in the sRGB color space.
Source§

fn tan() -> Color

Returns a CSS-compliant named color for tan in the sRGB color space.
Source§

fn teal() -> Color

Returns a CSS-compliant named color for teal in the sRGB color space.
Source§

fn thistle() -> Color

Returns a CSS-compliant named color for thistle in the sRGB color space.
Source§

fn tomato() -> Color

Returns a CSS-compliant named color for tomato in the sRGB color space.
Source§

fn turquoise() -> Color

Returns a CSS-compliant named color for turquoise in the sRGB color space.
Source§

fn violet() -> Color

Returns a CSS-compliant named color for violet in the sRGB color space.
Source§

fn wheat() -> Color

Returns a CSS-compliant named color for wheat in the sRGB color space.
Source§

fn white() -> Color

Returns a CSS-compliant named color for white in the sRGB color space.
Source§

fn whitesmoke() -> Color

Returns a CSS-compliant named color for whitesmoke in the sRGB color space.
Source§

fn yellow() -> Color

Returns a CSS-compliant named color for yellow in the sRGB color space.
Source§

fn yellowgreen() -> Color

Returns a CSS-compliant named color for yellowgreen in the sRGB color space.
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 ToTokens for Color

Source§

fn to_tokens(&self, tokens: &mut TokenStream)

Write self to the given TokenStream. Read more
Source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
Source§

fn into_token_stream(self) -> TokenStream
where Self: Sized,

Convert self directly into a TokenStream object. Read more
Source§

impl Copy 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: Component + Float, 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> AsAny for T
where T: Any,

Source§

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

Source§

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

Source§

fn type_name(&self) -> &'static str

Gets the type name of 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<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, U> ConvertInto<U> for T
where U: ConvertFrom<T>,

Source§

fn convert_into(self) -> U

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

fn convert_unclamped_into(self) -> U

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

fn try_convert_into(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<'a, T> Desc<'a, T> for T

Source§

fn lookup(self, _: &JNIEnv<'a>) -> Result<T, Error>

Look up the concrete type from the JVM.
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> IsDefault for T
where T: Default + PartialEq + Copy,

Source§

fn is_default(&self) -> bool

Checks that type has a default value.
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, 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.