Struct palette::rgb::Rgb [] [src]

pub struct Rgb<S: RgbStandard = Srgb, T: Float = f32> {
    pub red: T,
    pub green: T,
    pub blue: T,
    pub standard: PhantomData<S>,
}

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

The amount of red light, where 0.0 is no red light and 1.0 is the highest displayable amount.

The amount of green light, where 0.0 is no green light and 1.0 is the highest displayable amount.

The amount of blue light, where 0.0 is no blue light and 1.0 is the highest displayable amount.

The kind of RGB standard. sRGB is the default.

Methods

impl<S: RgbStandard, T: Float> Rgb<S, T>
[src]

[src]

Create an RGB color.

[src]

Create an RGB color from 8 bit values.

[src]

Create an RGB color from a pixel.

[src]

Convert the color into a pixel representation.

[src]

Convert the color to linear RGB.

[src]

Convert linear RGB to nonlinear RGB.

[src]

Convert a linear color to an RGB pixel.

[src]

Convert an RGB pixel to a linear color.

Trait Implementations

impl<S: Debug + RgbStandard, T: Debug + Float> Debug for Rgb<S, T>
[src]

[src]

Formats the value using the given formatter.

impl<S: PartialEq + RgbStandard, T: PartialEq + Float> PartialEq for Rgb<S, T>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<S: RgbStandard, T: Float> Copy for Rgb<S, T>
[src]

impl<S: RgbStandard, T: Float> Clone for Rgb<S, T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<S, T> Limited for Rgb<S, T> where
    S: RgbStandard,
    T: Float
[src]

[src]

Check if the color's components are within the expected ranges.

[src]

Return a new color where the components has been clamped to the nearest valid values. Read more

[src]

Clamp the color's components to the nearest valid values.

impl<S, T> Mix for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The type of the mixing factor.

[src]

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

impl<S, T> Shade for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The type of the lighten/darken amount.

[src]

Lighten the color by amount.

[src]

Darken the color by amount.

impl<S, T> GetHue for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

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

[src]

Calculate a hue if possible. Read more

impl<S, T> Blend for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

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

[src]

Convert the color to premultiplied alpha.

[src]

Convert the color from premultiplied alpha.

[src]

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

[src]

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

[src]

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

[src]

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

[src]

Place self over only the visible parts of other.

[src]

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

[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

[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

[src]

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

[src]

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

[src]

Return the darkest parts of self and other.

[src]

Return the lightest parts of self and other.

[src]

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

[src]

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

[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

[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

[src]

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

[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> ComponentWise for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The scalar type for color components.

[src]

Perform a binary operation on this and an other color.

[src]

Perform a unary operation on this color.

impl<S, T> Default for Rgb<S, T> where
    T: Float,
    S: RgbStandard
[src]

[src]

Returns the "default value" for a type. Read more

impl<S, T> Add<Rgb<S, T>> for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<S, T> Add<T> for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The resulting type after applying the + operator.

[src]

Performs the + operation.

impl<S, T> Sub<Rgb<S, T>> for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<S, T> Sub<T> for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The resulting type after applying the - operator.

[src]

Performs the - operation.

impl<S, T> Mul<Rgb<S, T>> for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<S, T> Mul<T> for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The resulting type after applying the * operator.

[src]

Performs the * operation.

impl<S, T> Div<Rgb<S, T>> for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<S, T> Div<T> for Rgb<S, T> where
    S: RgbStandard<TransferFn = LinearFn>,
    T: Float
[src]

The resulting type after applying the / operator.

[src]

Performs the / operation.

impl<S, Wp, T> FromColor<Wp, T> for Rgb<S, T> where
    S: RgbStandard,
    T: Float,
    Wp: WhitePoint,
    S::Space: RgbSpace<WhitePoint = Wp>, 
[src]

[src]

Convert from XYZ color space

[src]

Convert from RGB color space

[src]

Convert from HSL color space

[src]

Convert from HSV color space

[src]

Convert from Luma

[src]

Convert from Yxy color space

[src]

Convert from L*a*b* color space

[src]

Convert from L*C*h° color space

[src]

Convert from HWB color space

impl<S, T, Wp> IntoColor<Wp, T> for Rgb<S, T> where
    S: RgbStandard,
    T: Float,
    Wp: WhitePoint,
    S::Space: RgbSpace<WhitePoint = Wp>, 
[src]

[src]

Convert into XYZ space

[src]

Convert into Yxy color space

[src]

Convert into L*a*b* color space

[src]

Convert into L*C*h° color space

[src]

Convert into RGB color space.

[src]

Convert into HSL color space

[src]

Convert into HSV color space

[src]

Convert into HWB color space

[src]

Convert into Luma

impl<S, T> ApproxEq for Rgb<S, T> where
    T: Float + ApproxEq,
    T::Epsilon: Copy + Float,
    S: RgbStandard
[src]

Used for specifying relative comparisons.

[src]

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

[src]

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

[src]

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

[src]

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

[src]

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

[src]

The inverse of ApproxEq::relative_eq.

[src]

The inverse of ApproxEq::ulps_eq.

impl<S, T> From<Alpha<Rgb<S, T>, T>> for Rgb<S, T> where
    T: Float,
    S: RgbStandard
[src]

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

impl<S, T> From<Xyz<S::WhitePoint, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

impl<S, T> From<Alpha<Xyz<S::WhitePoint, T>, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

impl<S, T> From<Yxy<S::WhitePoint, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

impl<S, T> From<Alpha<Yxy<S::WhitePoint, T>, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

impl<S, T> From<Lab<S::WhitePoint, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

impl<S, T> From<Alpha<Lab<S::WhitePoint, T>, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

impl<S, T> From<Lch<S::WhitePoint, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

impl<S, T> From<Alpha<Lch<S::WhitePoint, T>, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

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

[src]

Performs the conversion.

impl<S, T> From<Luma<S::WhitePoint, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.

impl<S, T> From<Alpha<Luma<S::WhitePoint, T>, T>> for Rgb<Linear<S>, T> where
    T: Float,
    S: RgbSpace
[src]

[src]

Performs the conversion.