[][src]Enum amethyst_rendy::palette::Color

pub enum Color<S = Srgb, T = f32> where
    S: RgbSpace,
    T: Float + Component
{ Luma(Luma<Linear<<S as RgbSpace>::WhitePoint>, T>), Rgb(Rgb<Linear<S>, T>), Xyz(Xyz<<S as RgbSpace>::WhitePoint, T>), Yxy(Yxy<<S as RgbSpace>::WhitePoint, T>), Lab(Lab<<S as RgbSpace>::WhitePoint, T>), Lch(Lch<<S as RgbSpace>::WhitePoint, T>), Hsv(Hsv<S, T>), Hsl(Hsl<S, T>), Hwb(Hwb<S, T>), }

A generic color type.

The Color may belong to any color space and it may change depending on which operation is performed. That makes it immune to the "without conversion" rule of the operations it supports. The color spaces are selected as follows:

It's not recommended to use Color when full control is necessary, but it can easily be converted to a fixed color space in those cases.

Variants

Luma(Luma<Linear<<S as RgbSpace>::WhitePoint>, T>)

Linear luminance.

Rgb(Rgb<Linear<S>, T>)

Linear RGB.

Xyz(Xyz<<S as RgbSpace>::WhitePoint, T>)

CIE 1931 XYZ.

Yxy(Yxy<<S as RgbSpace>::WhitePoint, T>)

CIE 1931 Yxy.

Lab(Lab<<S as RgbSpace>::WhitePoint, T>)

CIE L*a*b* (CIELAB).

Lch(Lch<<S as RgbSpace>::WhitePoint, T>)

CIE L*C*h°, a polar version of CIE L*a*b*.

Hsv(Hsv<S, T>)

Linear HSV, a cylindrical version of RGB.

Hsl(Hsl<S, T>)

Linear HSL, a cylindrical version of RGB.

Hwb(Hwb<S, T>)

Linear HWB, an intuitive cylindrical version of RGB.

Methods

impl<T> Color<Srgb, T> where
    T: Component + Float
[src]

pub fn linear_y(luma: T) -> Color<Srgb, T>[src]

Linear luminance.

pub fn linear_rgb(red: T, green: T, blue: T) -> Color<Srgb, T>[src]

Linear RGB.

pub fn xyz(x: T, y: T, z: T) -> Color<Srgb, T>[src]

CIE XYZ.

pub fn yxy(x: T, y: T, luma: T) -> Color<Srgb, T>[src]

CIE Yxy.

pub fn lab(l: T, a: T, b: T) -> Color<Srgb, T>[src]

CIE L*a*b*.

pub fn lch(l: T, chroma: T, hue: LabHue<T>) -> Color<Srgb, T>[src]

CIE L*C*h°.

pub fn hsv(hue: RgbHue<T>, saturation: T, value: T) -> Color<Srgb, T>[src]

Linear HSV.

pub fn hsl(hue: RgbHue<T>, saturation: T, lightness: T) -> Color<Srgb, T>[src]

Linear HSL.

pub fn hwb(hue: RgbHue<T>, whiteness: T, balckness: T) -> Color<Srgb, T>[src]

Linear HWB.

Trait Implementations

impl<S, T> Default for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> Copy for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> Clone for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<S, T> Blend for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

type Color = Rgb<Linear<S>, T>

The core color type. Typically Self for color types without alpha.

fn blend<F>(self, destination: Self, blend_function: F) -> Self where
    F: BlendFunction<Self::Color>, 
[src]

Blend self, as the source color, with destination, using blend_function. Anything that implements BlendFunction is acceptable, including functions and closures. Read more

fn over(self, other: Self) -> Self[src]

Place self over other. This is the good old common alpha composition equation. Read more

fn inside(self, other: Self) -> Self[src]

Results in the parts of self that overlaps the visible parts of other. Read more

fn outside(self, other: Self) -> Self[src]

Results in the parts of self that lies outside the visible parts of other. Read more

fn atop(self, other: Self) -> Self[src]

Place self over only the visible parts of other.

fn xor(self, other: Self) -> Self[src]

Results in either self or other, where they do not overlap.

fn plus(self, other: Self) -> Self[src]

Add self and other. This uses the alpha component to regulate the effect, so it's not just plain component wise addition. Read more

fn multiply(self, other: Self) -> Self[src]

Multiply self with other. This uses the alpha component to regulate the effect, so it's not just plain component wise multiplication. Read more

fn screen(self, other: Self) -> Self[src]

Make a color which is at least as light as self or other.

fn overlay(self, other: Self) -> Self[src]

Multiply self or other if other is dark, or screen them if other is light. This results in an S curve. Read more

fn darken(self, other: Self) -> Self[src]

Return the darkest parts of self and other.

fn lighten(self, other: Self) -> Self[src]

Return the lightest parts of self and other.

fn dodge(self, other: Self) -> Self[src]

Lighten other to reflect self. Results in other if self is black. Read more

fn burn(self, other: Self) -> Self[src]

Darken other to reflect self. Results in other if self is white. Read more

fn hard_light(self, other: Self) -> Self[src]

Multiply self or other if other is dark, or screen them if self is light. This is similar to overlay, but depends on self instead of other. Read more

fn soft_light(self, other: Self) -> Self[src]

Lighten other if self is light, or darken other as if it's burned if self is dark. The effect is increased if the components of self is further from 0.5. Read more

fn difference(self, other: Self) -> Self[src]

Return the absolute difference between self and other. It's basically abs(self - other), but regulated by the alpha component. Read more

fn exclusion(self, other: Self) -> Self[src]

Similar to difference, but appears to result in a lower contrast. other is inverted if self is white, and preserved if self is black. Read more

impl<S, T> Saturate for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

type Scalar = T

The type of the (de)saturation factor.

fn desaturate(&self, factor: Self::Scalar) -> Self[src]

Decrease the saturation by factor.

impl<S, T> Mix for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

type Scalar = T

The type of the mixing factor.

impl<S, T> ApproxEq for Color<S, T> where
    S: RgbSpace,
    T: Float + Component + ApproxEq,
    <T as ApproxEq>::Epsilon: Float
[src]

type Epsilon = <T as ApproxEq>::Epsilon

Used for specifying relative comparisons.

fn relative_ne(
    &self,
    other: &Self,
    epsilon: Self::Epsilon,
    max_relative: Self::Epsilon
) -> bool
[src]

The inverse of ApproxEq::relative_eq.

fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool[src]

The inverse of ApproxEq::ulps_eq.

impl<S, T> Debug for Color<S, T> where
    S: Debug + RgbSpace,
    T: Debug + Float + Component,
    <S as RgbSpace>::WhitePoint: Debug
[src]

impl<S, T> From<Alpha<Xyz<<S as RgbSpace>::WhitePoint, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Hsl<S, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Color<<S as RgbStandard>::Space, T>> for Alpha<Rgb<S, T>, T> where
    S: RgbStandard,
    T: Component + Float
[src]

impl<Wp, T, _S> From<Color<_S, T>> for Xyz<Wp, T> where
    T: Component + Float,
    Wp: WhitePoint,
    _S: RgbSpace<WhitePoint = Wp>, 
[src]

impl<S, T> From<Color<S, T>> for Alpha<Hwb<S, T>, T> where
    S: RgbSpace,
    T: Component + Float
[src]

impl<Wp, T, _S> From<Color<_S, T>> for Alpha<Lch<Wp, T>, T> where
    T: Component + Float,
    Wp: WhitePoint,
    _S: RgbSpace<WhitePoint = Wp>, 
[src]

impl<S, T, _S> From<Color<_S, T>> for Alpha<Luma<S, T>, T> where
    S: LumaStandard,
    T: Component + Float,
    _S: RgbSpace<WhitePoint = <S as LumaStandard>::WhitePoint>, 
[src]

impl<Wp, T, _S> From<Color<_S, T>> for Lab<Wp, T> where
    T: Component + Float,
    Wp: WhitePoint,
    _S: RgbSpace<WhitePoint = Wp>, 
[src]

impl<S, T> From<Alpha<Lch<<S as RgbSpace>::WhitePoint, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Lab<<S as RgbSpace>::WhitePoint, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Lch<<S as RgbSpace>::WhitePoint, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Luma<Linear<<S as RgbSpace>::WhitePoint>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Alpha<Lab<<S as RgbSpace>::WhitePoint, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Color<S, T>> for Hsv<S, T> where
    S: RgbSpace,
    T: Component + Float
[src]

impl<Wp, T, _S> From<Color<_S, T>> for Lch<Wp, T> where
    T: Component + Float,
    Wp: WhitePoint,
    _S: RgbSpace<WhitePoint = Wp>, 
[src]

impl<S, T> From<Alpha<Yxy<<S as RgbSpace>::WhitePoint, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Alpha<Hsl<S, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<Wp, T, _S> From<Color<_S, T>> for Alpha<Xyz<Wp, T>, T> where
    T: Component + Float,
    Wp: WhitePoint,
    _S: RgbSpace<WhitePoint = Wp>, 
[src]

impl<S, T, _S> From<Color<_S, T>> for Luma<S, T> where
    S: LumaStandard,
    T: Component + Float,
    _S: RgbSpace<WhitePoint = <S as LumaStandard>::WhitePoint>, 
[src]

impl<Wp, T, _S> From<Color<_S, T>> for Alpha<Yxy<Wp, T>, T> where
    T: Component + Float,
    Wp: WhitePoint,
    _S: RgbSpace<WhitePoint = Wp>, 
[src]

impl<S, T> From<Alpha<Hwb<S, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Color<<S as RgbStandard>::Space, T>> for Rgb<S, T> where
    S: RgbStandard,
    T: Component + Float
[src]

impl<S, T> From<Color<S, T>> for Alpha<Hsv<S, T>, T> where
    S: RgbSpace,
    T: Component + Float
[src]

impl<Wp, T, _S> From<Color<_S, T>> for Alpha<Lab<Wp, T>, T> where
    T: Component + Float,
    Wp: WhitePoint,
    _S: RgbSpace<WhitePoint = Wp>, 
[src]

impl<Wp, T, _S> From<Color<_S, T>> for Yxy<Wp, T> where
    T: Component + Float,
    Wp: WhitePoint,
    _S: RgbSpace<WhitePoint = Wp>, 
[src]

impl<S, T> From<Hsv<S, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Color<S, T>> for Alpha<Hsl<S, T>, T> where
    S: RgbSpace,
    T: Component + Float
[src]

impl<S, T> From<Alpha<Rgb<Linear<S>, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Color<S, T>> for Hwb<S, T> where
    S: RgbSpace,
    T: Component + Float
[src]

impl<S, T> From<Hwb<S, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Alpha<Hsv<S, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Alpha<Luma<Linear<<S as RgbSpace>::WhitePoint>, T>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Color<S, T>> for Hsl<S, T> where
    S: RgbSpace,
    T: Component + Float
[src]

impl<S, T> From<Yxy<<S as RgbSpace>::WhitePoint, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Xyz<<S as RgbSpace>::WhitePoint, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> From<Rgb<Linear<S>, T>> for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

impl<S, T> Shade for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

type Scalar = T

The type of the lighten/darken amount.

fn darken(&self, amount: Self::Scalar) -> Self[src]

Darken the color by amount.

impl<S, T> GetHue for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

type Hue = LabHue<T>

The kind of hue unit this color space uses. Read more

impl<S, T> Hue for Color<S, T> where
    S: RgbSpace,
    T: Float + Component
[src]

Auto Trait Implementations

impl<S, T> Unpin for Color<S, T> where
    S: Unpin,
    T: Unpin,
    <S as RgbSpace>::WhitePoint: Unpin

impl<S, T> Sync for Color<S, T> where
    S: Sync,
    T: Sync,
    <S as RgbSpace>::WhitePoint: Sync

impl<S, T> Send for Color<S, T> where
    S: Send,
    T: Send,
    <S as RgbSpace>::WhitePoint: Send

impl<S, T> UnwindSafe for Color<S, T> where
    S: UnwindSafe,
    T: UnwindSafe,
    <S as RgbSpace>::WhitePoint: UnwindSafe

impl<S, T> RefUnwindSafe for Color<S, T> where
    S: RefUnwindSafe,
    T: RefUnwindSafe,
    <S as RgbSpace>::WhitePoint: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

fn adapt_into(self) -> D[src]

Convert the source color to the destination color using the bradford method by default Read more

impl<T> SetParameter for T[src]

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 
[src]

Sets value as a parameter of self.

impl<T> Supports<T> for T[src]

impl<T> Erased for T[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

impl<T> Resource for T where
    T: Any + Send + Sync
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> TryDefault for T where
    T: Default
[src]

fn unwrap_default() -> Self[src]

Calls try_default and panics on an error case.

impl<T> Event for T where
    T: Send + Sync + 'static, 
[src]

impl<T> Clone for T where
    T: Clone
[src]