Struct nannou::prelude::rgb::Rgb

source ·
#[repr(C)]
pub struct Rgb<S = Srgb, T = f32>
where S: RgbStandard, T: Component,
{ pub red: T, pub green: T, pub blue: T, pub standard: PhantomData<S>, }
Expand description

Generic RGB.

RGB is probably the most common color space, when it comes to computer graphics, and it’s defined as an additive mixture of red, green and blue light, where gray scale colors are created when these three channels are equal in strength.

Many conversions and operations on this color space requires that it’s linear, meaning that gamma correction is required when converting to and from a displayable RGB, such as sRGB. See the pixel module for encoding formats.

Fields§

§red: T

The amount of red light, where 0.0 is no red light and 1.0f (or 255u8) is the highest displayable amount.

§green: T

The amount of green light, where 0.0 is no green light and 1.0f (or 255u8) is the highest displayable amount.

§blue: T

The amount of blue light, where 0.0 is no blue light and 1.0f (or 255u8) is the highest displayable amount.

§standard: PhantomData<S>

The kind of RGB standard. sRGB is the default.

Implementations§

source§

impl<S, T> Rgb<S, T>
where S: RgbStandard, T: Component,

source

pub fn new(red: T, green: T, blue: T) -> Rgb<S, T>

Create an RGB color.

source

pub fn into_format<U>(self) -> Rgb<S, U>
where U: Component,

Convert into another component type.

source

pub fn from_format<U>(color: Rgb<S, U>) -> Rgb<S, T>
where U: Component,

Convert from another component type.

source

pub fn into_components(self) -> (T, T, T)

Convert to a (red, green, blue) tuple.

source

pub fn from_components(_: (T, T, T)) -> Rgb<S, T>

Convert from a (red, green, blue) tuple.

source§

impl<S, T> Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source

pub fn into_linear(self) -> Rgb<Linear<<S as RgbStandard>::Space>, T>

Convert the color to linear RGB.

source

pub fn from_linear( color: Rgb<Linear<<S as RgbStandard>::Space>, T> ) -> Rgb<S, T>

Convert linear RGB to nonlinear RGB.

source

pub fn into_encoding<St>(self) -> Rgb<St, T>
where St: RgbStandard<Space = <S as RgbStandard>::Space>,

Convert the color to a different encoding.

source

pub fn from_encoding<St>(color: Rgb<St, T>) -> Rgb<S, T>
where St: RgbStandard<Space = <S as RgbStandard>::Space>,

Convert RGB from a different encoding.

Trait Implementations§

source§

impl<S, T> AbsDiffEq for Rgb<S, T>
where T: Component + AbsDiffEq, <T as AbsDiffEq>::Epsilon: Copy, S: RgbStandard + PartialEq,

§

type Epsilon = <T as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> <Rgb<S, T> as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq( &self, other: &Rgb<S, T>, epsilon: <Rgb<S, T> as AbsDiffEq>::Epsilon ) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of ApproxEq::abs_diff_eq.
source§

impl<S, T> Add<T> for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Add, <T as Add>::Output: Component,

§

type Output = Rgb<S, <T as Add>::Output>

The resulting type after applying the + operator.
source§

fn add(self, c: T) -> <Rgb<S, T> as Add<T>>::Output

Performs the + operation. Read more
source§

impl<S, T> Add for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Add, <T as Add>::Output: Component,

§

type Output = Rgb<S, <T as Add>::Output>

The resulting type after applying the + operator.
source§

fn add(self, other: Rgb<S, T>) -> <Rgb<S, T> as Add>::Output

Performs the + operation. Read more
source§

impl<S, T> AddAssign<T> for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + AddAssign,

source§

fn add_assign(&mut self, c: T)

Performs the += operation. Read more
source§

impl<S, T> AddAssign for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + AddAssign,

source§

fn add_assign(&mut self, other: Rgb<S, T>)

Performs the += operation. Read more
source§

impl<S, T, P> AsMut<P> for Rgb<S, T>
where T: Component, S: RgbStandard, P: RawPixel<T> + ?Sized,

source§

fn as_mut(&mut self) -> &mut P

Convert to a raw pixel format.

use palette::Srgb;

let mut rgb = Srgb::new(38, 42, 19);
{
    let raw: &mut [u8] = rgb.as_mut();
    raw[1] = 5;
}

assert_eq!(rgb.green, 5);
source§

impl<S, T, P> AsRef<P> for Rgb<S, T>
where T: Component, S: RgbStandard, P: RawPixel<T> + ?Sized,

source§

fn as_ref(&self) -> &P

Convert to a raw pixel format.

use palette::Srgb;

let mut rgb = Srgb::new(38, 42, 19);
let raw: &[u8] = rgb.as_ref();

assert_eq!(raw[1], 42);
source§

impl<S, T> Blend for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Float,

§

type Color = Rgb<S, T>

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

fn into_premultiplied(self) -> PreAlpha<Rgb<S, T>, T>

Convert the color to premultiplied alpha.
source§

fn from_premultiplied(color: PreAlpha<Rgb<S, T>, T>) -> Rgb<S, T>

Convert the color from premultiplied alpha.
source§

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

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

fn over(self, other: Self) -> Self

Place self over other. This is the good old common alpha composition equation.
source§

fn inside(self, other: Self) -> Self

Results in the parts of self that overlaps the visible parts of other.
source§

fn outside(self, other: Self) -> Self

Results in the parts of self that lies outside the visible parts of other.
source§

fn atop(self, other: Self) -> Self

Place self over only the visible parts of other.
source§

fn xor(self, other: Self) -> Self

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

fn plus(self, other: Self) -> Self

Add self and other. This uses the alpha component to regulate the effect, so it’s not just plain component wise addition.
source§

fn multiply(self, other: Self) -> Self

Multiply self with other. This uses the alpha component to regulate the effect, so it’s not just plain component wise multiplication.
source§

fn screen(self, other: Self) -> Self

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

fn overlay(self, other: Self) -> Self

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

fn darken(self, other: Self) -> Self

Return the darkest parts of self and other.
source§

fn lighten(self, other: Self) -> Self

Return the lightest parts of self and other.
source§

fn dodge(self, other: Self) -> Self

Lighten other to reflect self. Results in other if self is black.
source§

fn burn(self, other: Self) -> Self

Darken other to reflect self. Results in other if self is white.
source§

fn hard_light(self, other: Self) -> Self

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.
source§

fn soft_light(self, other: Self) -> Self

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.
source§

fn difference(self, other: Self) -> Self

Return the absolute difference between self and other. It’s basically abs(self - other), but regulated by the alpha component.
source§

fn exclusion(self, other: Self) -> Self

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

impl<S, T> Clone for Rgb<S, T>
where S: RgbStandard, T: Component,

source§

fn clone(&self) -> Rgb<S, T>

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<S, T> ComponentWise for Rgb<S, T>
where S: RgbStandard, T: Component,

§

type Scalar = T

The scalar type for color components.
source§

fn component_wise<F>(&self, other: &Rgb<S, T>, f: F) -> Rgb<S, T>
where F: FnMut(T, T) -> T,

Perform a binary operation on this and an other color.
source§

fn component_wise_self<F>(&self, f: F) -> Rgb<S, T>
where F: FnMut(T) -> T,

Perform a unary operation on this color.
source§

impl<S, T> Debug for Rgb<S, T>
where S: Debug + RgbStandard, T: Debug + Component,

source§

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

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

impl<S, T> Default for Rgb<S, T>
where T: Component, S: RgbStandard,

source§

fn default() -> Rgb<S, T>

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

impl<'de, S, T> Deserialize<'de> for Rgb<S, T>
where S: RgbStandard, T: Component + Deserialize<'de>,

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<Rgb<S, T>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

impl<S, T> Div<T> for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Div, <T as Div>::Output: Component,

§

type Output = Rgb<S, <T as Div>::Output>

The resulting type after applying the / operator.
source§

fn div(self, c: T) -> <Rgb<S, T> as Div<T>>::Output

Performs the / operation. Read more
source§

impl<S, T> Div for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Div, <T as Div>::Output: Component,

§

type Output = Rgb<S, <T as Div>::Output>

The resulting type after applying the / operator.
source§

fn div(self, other: Rgb<S, T>) -> <Rgb<S, T> as Div>::Output

Performs the / operation. Read more
source§

impl<S, T> DivAssign<T> for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + DivAssign,

source§

fn div_assign(&mut self, c: T)

Performs the /= operation. Read more
source§

impl<S, T> DivAssign for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + DivAssign,

source§

fn div_assign(&mut self, other: Rgb<S, T>)

Performs the /= operation. Read more
source§

impl<S, T> From<(T, T, T)> for Rgb<S, T>
where S: RgbStandard, T: Component,

source§

fn from(components: (T, T, T)) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Alpha<Hsl<<S as RgbStandard>::Space, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from(color: Alpha<Hsl<<S as RgbStandard>::Space, T>, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Alpha<Hsv<<S as RgbStandard>::Space, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from(color: Alpha<Hsv<<S as RgbStandard>::Space, T>, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Alpha<Hwb<<S as RgbStandard>::Space, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from(color: Alpha<Hwb<<S as RgbStandard>::Space, T>, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Alpha<Lab<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from( color: Alpha<Lab<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>, T> ) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Alpha<Lch<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from( color: Alpha<Lch<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>, T> ) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Alpha<Luma<_S, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float, _S: LumaStandard<WhitePoint = <<S as RgbStandard>::Space as RgbSpace>::WhitePoint>,

source§

fn from(color: Alpha<Luma<_S, T>, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Alpha<Rgb<_S, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float, _S: RgbStandard<Space = <S as RgbStandard>::Space>,

source§

fn from(color: Alpha<Rgb<_S, T>, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Alpha<Xyz<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from( color: Alpha<Xyz<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>, T> ) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Alpha<Yxy<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from( color: Alpha<Yxy<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>, T> ) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T, Sp, Wp> From<Hsl<Sp, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float, Wp: WhitePoint, <S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>, Sp: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Hsl<Sp, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T, Sp, Wp> From<Hsv<Sp, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float, Wp: WhitePoint, <S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>, Sp: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Hsv<Sp, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Hwb<<S as RgbStandard>::Space, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from(color: Hwb<<S as RgbStandard>::Space, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Lab<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from( color: Lab<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T> ) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Lch<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from( color: Lch<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T> ) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T, St, Wp> From<Luma<St, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float, Wp: WhitePoint, <S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>, St: LumaStandard<WhitePoint = Wp>,

source§

fn from(color: Luma<St, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<Wp, T, S> From<Rgb<S, T>> for Xyz<Wp, T>
where T: Component + Float, Wp: WhitePoint, S: RgbStandard, <S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Rgb<S, T>) -> Xyz<Wp, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Rgb<_S, T>> for Alpha<Hsl<S, T>, T>
where T: Component + Float, S: RgbSpace, _S: RgbStandard<Space = S>,

source§

fn from(color: Rgb<_S, T>) -> Alpha<Hsl<S, T>, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Rgb<_S, T>> for Alpha<Hsv<S, T>, T>
where T: Component + Float, S: RgbSpace, _S: RgbStandard<Space = S>,

source§

fn from(color: Rgb<_S, T>) -> Alpha<Hsv<S, T>, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Rgb<_S, T>> for Alpha<Hwb<S, T>, T>
where T: Component + Float, S: RgbSpace, _S: RgbStandard<Space = S>,

source§

fn from(color: Rgb<_S, T>) -> Alpha<Hwb<S, T>, T>

Converts to this type from the input type.
source§

impl<Wp, T, _S> From<Rgb<_S, T>> for Alpha<Lab<Wp, T>, T>
where T: Component + Float, Wp: WhitePoint, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Rgb<_S, T>) -> Alpha<Lab<Wp, T>, T>

Converts to this type from the input type.
source§

impl<Wp, T, _S> From<Rgb<_S, T>> for Alpha<Lch<Wp, T>, T>
where T: Component + Float, Wp: WhitePoint, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Rgb<_S, T>) -> Alpha<Lch<Wp, T>, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Rgb<_S, T>> for Alpha<Luma<S, T>, T>
where T: Component + Float, S: LumaStandard, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = <S as LumaStandard>::WhitePoint>,

source§

fn from(color: Rgb<_S, T>) -> Alpha<Luma<S, T>, T>

Converts to this type from the input type.
source§

impl<Wp, T, _S> From<Rgb<_S, T>> for Alpha<Xyz<Wp, T>, T>
where T: Component + Float, Wp: WhitePoint, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Rgb<_S, T>) -> Alpha<Xyz<Wp, T>, T>

Converts to this type from the input type.
source§

impl<Wp, T, _S> From<Rgb<_S, T>> for Alpha<Yxy<Wp, T>, T>
where T: Component + Float, Wp: WhitePoint, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Rgb<_S, T>) -> Alpha<Yxy<Wp, T>, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Rgb<_S, T>> for Hsl<S, T>
where T: Component + Float, S: RgbSpace, _S: RgbStandard<Space = S>,

source§

fn from(color: Rgb<_S, T>) -> Hsl<S, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Rgb<_S, T>> for Hsv<S, T>
where T: Component + Float, S: RgbSpace, _S: RgbStandard<Space = S>,

source§

fn from(color: Rgb<_S, T>) -> Hsv<S, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Rgb<_S, T>> for Hwb<S, T>
where T: Component + Float, S: RgbSpace, _S: RgbStandard<Space = S>,

source§

fn from(color: Rgb<_S, T>) -> Hwb<S, T>

Converts to this type from the input type.
source§

impl<Wp, T, _S> From<Rgb<_S, T>> for Lab<Wp, T>
where T: Component + Float, Wp: WhitePoint, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Rgb<_S, T>) -> Lab<Wp, T>

Converts to this type from the input type.
source§

impl<Wp, T, _S> From<Rgb<_S, T>> for Lch<Wp, T>
where T: Component + Float, Wp: WhitePoint, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Rgb<_S, T>) -> Lch<Wp, T>

Converts to this type from the input type.
source§

impl<S, T, _S> From<Rgb<_S, T>> for Luma<S, T>
where T: Component + Float, S: LumaStandard, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = <S as LumaStandard>::WhitePoint>,

source§

fn from(color: Rgb<_S, T>) -> Luma<S, T>

Converts to this type from the input type.
source§

impl<Wp, T, _S> From<Rgb<_S, T>> for Yxy<Wp, T>
where T: Component + Float, Wp: WhitePoint, _S: RgbStandard, <_S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Rgb<_S, T>) -> Yxy<Wp, T>

Converts to this type from the input type.
source§

impl<S, Wp, T> From<Xyz<Wp, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float, Wp: WhitePoint, <S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn from(color: Xyz<Wp, T>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> From<Yxy<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from( color: Yxy<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T> ) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<S, T> FromColor<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T> for Rgb<S, T>
where S: RgbStandard, T: Component + Float,

source§

fn from_xyz( color: Xyz<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T> ) -> Rgb<S, T>

Convert from XYZ color space
source§

fn from_hsv<_S>(color: Hsv<_S, T>) -> Rgb<S, T>
where _S: RgbSpace<WhitePoint = <<S as RgbStandard>::Space as RgbSpace>::WhitePoint>,

Convert from HSV color space
source§

fn from_hsl<_S>(color: Hsl<_S, T>) -> Rgb<S, T>
where _S: RgbSpace<WhitePoint = <<S as RgbStandard>::Space as RgbSpace>::WhitePoint>,

Convert from HSL color space
source§

fn from_luma( color: Luma<Linear<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint>, T> ) -> Rgb<S, T>

Convert from Luma
source§

fn from_rgb<_S>(color: Rgb<Linear<_S>, T>) -> Rgb<S, T>
where _S: RgbSpace<WhitePoint = <<S as RgbStandard>::Space as RgbSpace>::WhitePoint>,

Convert from RGB color space
source§

fn from_yxy(inp: Yxy<Wp, T>) -> Self

Convert from Yxy color space
source§

fn from_lab(inp: Lab<Wp, T>) -> Self

Convert from L*a*b* color space
source§

fn from_lch(inp: Lch<Wp, T>) -> Self

Convert from L*C*h° color space
source§

fn from_hwb<S>(inp: Hwb<S, T>) -> Self
where S: RgbSpace<WhitePoint = Wp>,

Convert from HWB color space
source§

impl<S, T> GetHue for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Float,

§

type Hue = RgbHue<T>

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

fn get_hue(&self) -> Option<RgbHue<T>>

Calculate a hue if possible. Read more
source§

impl<S, T> Into<(T, T, T)> for Rgb<S, T>
where S: RgbStandard, T: Component,

source§

fn into(self) -> (T, T, T)

Converts this type into the (usually inferred) input type.
source§

impl<S, T, Wp> IntoColor<Wp, T> for Rgb<S, T>
where S: RgbStandard, T: Component + Float, Wp: WhitePoint, <S as RgbStandard>::Space: RgbSpace<WhitePoint = Wp>,

source§

fn into_xyz(self) -> Xyz<Wp, T>

Convert into XYZ space
source§

fn into_yxy(self) -> Yxy<Wp, T>

Convert into Yxy color space
source§

fn into_lab(self) -> Lab<Wp, T>

Convert into L*a*b* color space
source§

fn into_lch(self) -> Lch<Wp, T>

Convert into L*C*h° color space
source§

fn into_rgb<Sp>(self) -> Rgb<Linear<Sp>, T>
where Sp: RgbSpace<WhitePoint = Wp>,

Convert into RGB color space.
source§

fn into_hsl<Sp>(self) -> Hsl<Sp, T>
where Sp: RgbSpace<WhitePoint = Wp>,

Convert into HSL color space
source§

fn into_hsv<Sp>(self) -> Hsv<Sp, T>
where Sp: RgbSpace<WhitePoint = Wp>,

Convert into HSV color space
source§

fn into_hwb<Sp>(self) -> Hwb<Sp, T>
where Sp: RgbSpace<WhitePoint = Wp>,

Convert into HWB color space
source§

fn into_luma(self) -> Luma<Linear<Wp>, T>

Convert into Luma
source§

impl<T, S> IntoLinSrgba<S> for Rgb<Linear<Srgb>, T>
where T: Component, S: Component,

source§

fn into_lin_srgba(self) -> Alpha<Rgb<Linear<Srgb>, S>, S>

Convert self into RGBA.
source§

impl<T, S> IntoLinSrgba<S> for Rgb<Srgb, T>
where T: Component, S: Component + Float,

source§

fn into_lin_srgba(self) -> Alpha<Rgb<Linear<Srgb>, S>, S>

Convert self into RGBA.
source§

impl<S, T> Limited for Rgb<S, T>
where S: RgbStandard, T: Component,

source§

fn is_valid(&self) -> bool

Check if the color’s components are within the expected ranges.
source§

fn clamp(&self) -> Rgb<S, T>

Return a new color where the components has been clamped to the nearest valid values.
source§

fn clamp_self(&mut self)

Clamp the color’s components to the nearest valid values.
source§

impl<S, T> LowerHex for Rgb<S, T>

source§

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

Formats the value using the given formatter.
source§

impl<S, T> Mix for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Float,

§

type Scalar = T

The type of the mixing factor.
source§

fn mix(&self, other: &Rgb<S, T>, factor: T) -> Rgb<S, T>

Mix the color with an other color, by factor. Read more
source§

impl<S, T> Mul<T> for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Mul, <T as Mul>::Output: Component,

§

type Output = Rgb<S, <T as Mul>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, c: T) -> <Rgb<S, T> as Mul<T>>::Output

Performs the * operation. Read more
source§

impl<S, T> Mul for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Mul, <T as Mul>::Output: Component,

§

type Output = Rgb<S, <T as Mul>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, other: Rgb<S, T>) -> <Rgb<S, T> as Mul>::Output

Performs the * operation. Read more
source§

impl<S, T> MulAssign<T> for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + MulAssign,

source§

fn mul_assign(&mut self, c: T)

Performs the *= operation. Read more
source§

impl<S, T> MulAssign for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + MulAssign,

source§

fn mul_assign(&mut self, other: Rgb<S, T>)

Performs the *= operation. Read more
source§

impl<S, T> PartialEq for Rgb<S, T>

source§

fn eq(&self, other: &Rgb<S, T>) -> 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<S, T> Pixel<T> for Rgb<S, T>
where S: RgbStandard, T: Component,

source§

const CHANNELS: usize = 3usize

The number of color channels.
source§

fn as_raw<P>(&self) -> &P
where P: RawPixel<T> + ?Sized,

Cast as a reference to raw color components.
source§

fn as_raw_mut<P>(&mut self) -> &mut P
where P: RawPixel<T> + ?Sized,

Cast as a mutable reference to raw color components.
source§

fn into_raw<P>(self) -> P
where P: RawPixelSized<T>,

Convert from raw color components.
source§

fn from_raw<P>(pixel: &P) -> &Self
where P: RawPixel<T> + ?Sized,

Cast from a reference to raw color components.
source§

fn from_raw_mut<P>(pixel: &mut P) -> &mut Self
where P: RawPixel<T> + ?Sized,

Cast from a mutable reference to raw color components.
source§

fn from_raw_slice(slice: &[T]) -> &[Self]

Cast a slice of raw color components to a slice of colors. Read more
source§

fn from_raw_slice_mut(slice: &mut [T]) -> &mut [Self]

Cast a mutable slice of raw color components to a mutable slice of colors. Read more
source§

fn into_raw_slice(slice: &[Self]) -> &[T]

Cast a slice of colors to a slice of raw color components. Read more
source§

fn into_raw_slice_mut(slice: &mut [Self]) -> &mut [T]

Cast a mutable slice of colors to a mutable slice of raw color components. Read more
source§

impl<S, T> RelativeEq for Rgb<S, T>
where T: Component + RelativeEq, <T as AbsDiffEq>::Epsilon: Copy, S: RgbStandard + PartialEq,

source§

fn default_max_relative() -> <Rgb<S, T> as AbsDiffEq>::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Rgb<S, T>, epsilon: <Rgb<S, T> as AbsDiffEq>::Epsilon, max_relative: <Rgb<S, T> as AbsDiffEq>::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
§

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

The inverse of ApproxEq::relative_eq.
source§

impl<S, T> Serialize for Rgb<S, T>

source§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

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

impl<S, T> Shade for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Float,

§

type Scalar = T

The type of the lighten/darken amount.
source§

fn lighten(&self, amount: T) -> Rgb<S, T>

Lighten the color by amount.
source§

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

Darken the color by amount.
source§

impl<S, T> Sub<T> for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Sub, <T as Sub>::Output: Component,

§

type Output = Rgb<S, <T as Sub>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, c: T) -> <Rgb<S, T> as Sub<T>>::Output

Performs the - operation. Read more
source§

impl<S, T> Sub for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + Sub, <T as Sub>::Output: Component,

§

type Output = Rgb<S, <T as Sub>::Output>

The resulting type after applying the - operator.
source§

fn sub(self, other: Rgb<S, T>) -> <Rgb<S, T> as Sub>::Output

Performs the - operation. Read more
source§

impl<S, T> SubAssign<T> for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + SubAssign,

source§

fn sub_assign(&mut self, c: T)

Performs the -= operation. Read more
source§

impl<S, T> SubAssign for Rgb<S, T>
where S: RgbStandard<TransferFn = LinearFn>, T: Component + SubAssign,

source§

fn sub_assign(&mut self, other: Rgb<S, T>)

Performs the -= operation. Read more
source§

impl<S, T> UlpsEq for Rgb<S, T>
where T: Component + UlpsEq, <T as AbsDiffEq>::Epsilon: Copy, S: RgbStandard + PartialEq,

source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn ulps_eq( &self, other: &Rgb<S, T>, epsilon: <Rgb<S, T> as AbsDiffEq>::Epsilon, max_ulps: u32 ) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
§

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

The inverse of ApproxEq::ulps_eq.
source§

impl<S, T> UpperHex for Rgb<S, T>

source§

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

Formats the value using the given formatter.
source§

impl<S, T> Copy for Rgb<S, T>
where S: RgbStandard, T: Component,

source§

impl<S, T> StructuralPartialEq for Rgb<S, T>
where S: RgbStandard, T: Component,

Auto Trait Implementations§

§

impl<S, T> RefUnwindSafe for Rgb<S, T>

§

impl<S, T> Send for Rgb<S, T>
where S: Send, T: Send,

§

impl<S, T> Sync for Rgb<S, T>
where S: Sync, T: Sync,

§

impl<S, T> Unpin for Rgb<S, T>
where S: Unpin, T: Unpin,

§

impl<S, T> UnwindSafe for Rgb<S, T>
where S: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<S, D, Swp, Dwp, T> AdaptFrom<S, Swp, Dwp, T> for D
where T: Component + Float, Swp: WhitePoint, Dwp: WhitePoint, S: IntoColor<Swp, T>, D: FromColor<Dwp, T>,

source§

fn adapt_from_using<M>(color: S, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

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

fn adapt_from(color: S) -> Self

Convert the source color to the destination color using the bradford method by default
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> 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, U> ConvertFrom<T> for U
where U: From<T> + Limited,

source§

fn convert_from(t: T) -> U

Convert from T with values clamped to the color defined bounds Read more
source§

fn try_convert_from(t: T) -> Result<U, OutOfBounds<U>>

Convert from 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§

fn convert_unclamped_from(val: T) -> Self

Convert from T. The resulting color might be invalid in its color space 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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<T> Upcast<T> for T

§

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

§

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

§

fn vzip(self) -> V

source§

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

§

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

§

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