[][src]Struct prisma::Rgi

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

The rgI device-dependent chromaticity color model

rgI is defined by a relative red amount, relative green amount and intensity. The rgI color model is used to keep the color intensity relatively invariant (that is, only the color matters, not how white or black it is), with the caveat that its parent RGB is not perceptually uniform. It is a device-dependent relative to the xyY CIE space.

The r and g components here are not absolute red and green like in RGB, but rather the ratio of red or green to the sum of RGB. That is:

\begin{aligned}
r &= \frac{R}{R+G+B} \\
g &= \frac{G}{R+G+B} \\
b &= \frac{B}{R+G+B} \\
r+g+b &= 1 \\
I &= \frac{R+G+B}{3}
\end{aligned}

Since r+g+b=1, the b component is not stored, but can be reconstructed at will. This also means that setting any of r,g,b will require the others to be changed as well. Rgi does this by proportionally rescaling the other channels with respect to the new value.

Including the intensity channel makes Rgi still a full color model that can convert back to RGB, unlike the sometimes used rg model.

Implementations

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

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

Construct a Rgi instance from red, green and intensity

Panics:

If red+green is greater than 1.0 or less than 0.0, new will panic.

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

Convert the internal channel scalar format

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

Returns the relative red scalar

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

Returns the relative green scalar

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

Returns the relative blue scalar

Unlike red and green, this requires a small computation

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

Returns the intensity scalar

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

Returns a mutable reference to the intensity scalar

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

Set the relative red channel

Panics:

This will panic if val is greater than one or less than zero.

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

Set the relative green channel

Panics:

This will panic if val is greater than one or less than zero.

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

Set the relative blue channel

Panics:

This will panic if val is greater than one or less than zero.

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

Set the intensity value

Trait Implementations

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

type Epsilon = T::Epsilon

Used for specifying relative comparisons.

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

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

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

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

type Tag = RgiTag

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: Copy> Copy for Rgi<T>[src]

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

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

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

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

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

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

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

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

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

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

type ChannelFormat = T

The scalar type of each channel

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

type Position = <T as Lerp>::Position

The type of the pos argument

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

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

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

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

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

Auto Trait Implementations

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

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

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

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

impl<T> UnwindSafe for Rgi<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.