[][src]Struct prisma::Rgb

#[repr(C)]pub struct Rgb<T> { /* fields omitted */ }

The Rgb device-dependent cartesian color model.

Rgb<T> has three primaries: red, green blue, which are always positive and in the normalized range [0, 1]. Rgb<T> accepts both integer and float components.

It is made to be efficient and easy to use in many different applications, and can be transmuted directly to a &[T; N].

Rgb is the base device dependent color space from which all others go through to convert, which can be converted to the other device dependent spaces or to the device independent CIE spaces directly. The color space of Rgb is not specified or assumed, it is up to you to not mix color spaces improperly or use an appropriate wrapper.

Examples:

use prisma::{Broadcast, HomogeneousColor, Lerp, Rgb};

let black = Rgb::broadcast(0.0f32);
let blue = Rgb::new(0, 0, 255u8);
// Convert blue to have float channels and compute the color halfway between blue and black
let blended = black.lerp(&blue.color_cast(), 0.5);

assert_eq!(blended, Rgb::new(0.0, 0.0, 0.5));

Implementations

impl<T> Rgb<T> where
    T: PosNormalChannelScalar
[src]

pub fn new(red: T, green: T, blue: T) -> Self[src]

Construct a new Rgb instance with the given channel values

pub fn color_cast<TOut>(&self) -> Rgb<TOut> where
    T: ChannelFormatCast<TOut>,
    TOut: PosNormalChannelScalar
[src]

Convert the internal channel scalar format

pub fn red(&self) -> T[src]

Returns the red channel scalar

pub fn green(&self) -> T[src]

Returns the green channel scalar

pub fn blue(&self) -> T[src]

Returns the blue channel scalar

pub fn red_mut(&mut self) -> &mut T[src]

Returns a mutable reference to the red channel scalar

pub fn green_mut(&mut self) -> &mut T[src]

Returns a mutable reference to the green channel scalar

pub fn blue_mut(&mut self) -> &mut T[src]

Returns a mutable reference to the blue channel scalar

pub fn set_red(&mut self, val: T)[src]

Set the red channel value

pub fn set_green(&mut self, val: T)[src]

Set the green channel value

pub fn set_blue(&mut self, val: T)[src]

Set the blue channel value

impl<T> Rgb<T> where
    T: PosNormalChannelScalar + Float
[src]

pub fn chromaticity_coordinates(&self) -> ChromaticityCoordinates<T>[src]

Compute the ChromaticityCooridinates for an Rgb instance

Trait Implementations

impl<T> AbsDiffEq<Rgb<T>> for Rgb<T> where
    T: PosNormalChannelScalar + AbsDiffEq,
    T::Epsilon: Clone
[src]

type Epsilon = T::Epsilon

Used for specifying relative comparisons.

impl<T> Bounded for Rgb<T> where
    T: PosNormalChannelScalar
[src]

impl<T> Broadcast for Rgb<T> where
    T: PosNormalChannelScalar
[src]

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

impl<T> Color for Rgb<T> where
    T: PosNormalChannelScalar
[src]

type Tag = RgbTag

The unique tag unit struct identifying the color type

type ChannelsTuple = (T, T, T)

A tuple of types for each channel in the color

impl<T> Color3 for Rgb<T> where
    T: PosNormalChannelScalar
[src]

impl<T, E> ConvertToXyz<T, Rgb<T>, E> for SRgb<T> where
    T: Float + FreeChannelScalar + PosNormalChannelScalar + ChannelFormatCast<f64>,
    f64: ChannelFormatCast<T>,
    E: ColorEncoding
[src]

type OutputColor = Xyz<T>

The type to output. Always some form of Xyz

impl<T, E, EIn> ConvertToXyz<T, Rgb<T>, EIn> for EncodedColorSpace<T, E> where
    T: PosNormalChannelScalar + FreeChannelScalar + Float + ChannelFormatCast<f64>,
    f64: ChannelFormatCast<T>,
    E: ColorEncoding + PartialEq,
    EIn: ColorEncoding + PartialEq
[src]

type OutputColor = Xyz<T>

The type to output. Always some form of Xyz

impl<'a, T, E, EIn> ConvertToXyz<T, Rgb<T>, EIn> for &'a EncodedColorSpace<T, E> where
    T: PosNormalChannelScalar + FreeChannelScalar + Float + ChannelFormatCast<f64>,
    f64: ChannelFormatCast<T>,
    E: ColorEncoding + PartialEq,
    EIn: ColorEncoding + PartialEq
[src]

type OutputColor = Xyz<T>

The type to output. Always some form of Xyz

impl<T, E, EIn> ConvertToXyz<T, Rgb<T>, EIn> for Rc<EncodedColorSpace<T, E>> where
    T: PosNormalChannelScalar + FreeChannelScalar + Float + ChannelFormatCast<f64>,
    f64: ChannelFormatCast<T>,
    E: ColorEncoding + PartialEq,
    EIn: ColorEncoding + PartialEq
[src]

type OutputColor = Xyz<T>

The type to output. Always some form of Xyz

impl<T, E, EIn> ConvertToXyz<T, Rgb<T>, EIn> for Arc<EncodedColorSpace<T, E>> where
    T: PosNormalChannelScalar + FreeChannelScalar + Float + ChannelFormatCast<f64>,
    f64: ChannelFormatCast<T>,
    E: ColorEncoding + PartialEq,
    EIn: ColorEncoding + PartialEq
[src]

type OutputColor = Xyz<T>

The type to output. Always some form of Xyz

impl<T: Copy> Copy for Rgb<T>[src]

impl<T: Debug> Debug for Rgb<T>[src]

impl<T> Default for Rgb<T> where
    T: PosNormalChannelScalar + Zero
[src]

impl<T> Display for Rgb<T> where
    T: PosNormalChannelScalar + Display
[src]

impl<T> EncodableColor for Rgb<T> where
    T: PosNormalChannelScalar
[src]

impl<T: Eq> Eq for Rgb<T>[src]

impl<T> Flatten for Rgb<T> where
    T: PosNormalChannelScalar
[src]

impl<T, A> From<Hsl<T, A>> for Rgb<T> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar
[src]

impl<T, A> From<Hsv<T, A>> for Rgb<T> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar
[src]

impl<T, A> From<Hwb<T, A>> for Rgb<T> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar
[src]

impl<T, A> From<Rgb<T>> for Hsv<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + FromAngle<Turns<T>>, 
[src]

impl<T, A> From<Rgb<T>> for Hsl<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + FromAngle<Turns<T>>, 
[src]

impl<T, A> From<Rgb<T>> for Hwb<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + FromAngle<Turns<T>>, 
[src]

impl<T, A> From<Rgb<T>> for Hsi<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>, 
[src]

impl<T, A> From<Rgb<T>> for eHsi<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>, 
[src]

impl<T, M> From<Rgb<T>> for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

impl<T, A> FromColor<Hsl<T, A>> for Rgb<T> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar
[src]

impl<T, A> FromColor<Hsv<T, A>> for Rgb<T> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar
[src]

impl<T, A> FromColor<Hwb<T, A>> for Rgb<T> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar
[src]

impl<T, A> FromColor<Rgb<T>> for eHsi<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>, 
[src]

impl<T, A> FromColor<Rgb<T>> for Hsi<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>, 
[src]

impl<T, A> FromColor<Rgb<T>> for Hsv<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + FromAngle<Turns<T>>, 
[src]

impl<T, A> FromColor<Rgb<T>> for Hsl<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + FromAngle<Turns<T>>, 
[src]

impl<T, A> FromColor<Rgb<T>> for Hwb<T, A> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + FromAngle<Turns<T>>, 
[src]

impl<T> FromColor<Rgb<T>> for Rgi<T> where
    T: PosNormalChannelScalar + Float
[src]

impl<T, M> FromColor<Rgb<T>> for YCbCr<T, M> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T> + UnitModel<T>, 
[src]

impl<T> FromColor<Rgi<T>> for Rgb<T> where
    T: PosNormalChannelScalar + Float
[src]

impl<T, A> FromColor<eHsi<T, A>> for Rgb<T> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + Angle<Scalar = T>, 
[src]

impl<T, A> FromHsi<Hsi<T, A>> for Rgb<T> where
    T: PosNormalChannelScalar + Float,
    A: AngularChannelScalar + Angle<Scalar = T> + IntoAngle<Rad<T>, OutputScalar = T>, 
[src]

impl<T> FromTuple for Rgb<T> where
    T: PosNormalChannelScalar
[src]

impl<T, M> FromYCbCr<YCbCr<T, M>> for Rgb<T> where
    T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
    M: YCbCrModel<T>, 
[src]

impl<T: Hash> Hash for Rgb<T>[src]

impl<T> HomogeneousColor for Rgb<T> where
    T: PosNormalChannelScalar
[src]

type ChannelFormat = T

The scalar type of each channel

impl<T> Invert for Rgb<T> where
    T: PosNormalChannelScalar
[src]

impl<T> Lerp for Rgb<T> where
    T: PosNormalChannelScalar + Lerp
[src]

type Position = <T as Lerp>::Position

The type of the pos argument

impl<T: Ord> Ord for Rgb<T>[src]

impl<T: PartialEq> PartialEq<Rgb<T>> for Rgb<T>[src]

impl<T: PartialOrd> PartialOrd<Rgb<T>> for Rgb<T>[src]

impl<T> RelativeEq<Rgb<T>> for Rgb<T> where
    T: PosNormalChannelScalar + RelativeEq,
    T::Epsilon: Clone
[src]

impl<T> StructuralEq for Rgb<T>[src]

impl<T> StructuralPartialEq for Rgb<T>[src]

impl<T> TranscodableColor for Rgb<T> where
    T: PosNormalChannelScalar + ChannelFormatCast<f64>,
    f64: ChannelFormatCast<T>, 
[src]

type IntermediateColor = Rgb<f64>

The color type used internally to do conversions. This will always have floating-point channels

impl<T> UlpsEq<Rgb<T>> for Rgb<T> where
    T: PosNormalChannelScalar + UlpsEq,
    T::Epsilon: Clone
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Rgb<T> where
    T: RefUnwindSafe

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

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

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

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

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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