[−][src]Struct prisma::Rgi
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]
T: PosNormalChannelScalar + Float,
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]
T: ChannelFormatCast<TOut>,
TOut: PosNormalChannelScalar,
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]
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]
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]
T: PosNormalChannelScalar + AbsDiffEq + Float,
T::Epsilon: Clone,
type Epsilon = T::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> Self::Epsilon
[src]
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
[src]
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
[src]
impl<T> Bounded for Rgi<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
fn normalize(self) -> Self
[src]
fn is_normalized(&self) -> bool
[src]
impl<T> Broadcast for Rgi<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
impl<T: Clone> Clone for Rgi<T>
[src]
impl<T> Color for Rgi<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
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
fn num_channels() -> u32
[src]
fn to_tuple(self) -> Self::ChannelsTuple
[src]
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]
T: PosNormalChannelScalar + Zero + Float,
impl<T> Display for Rgi<T> where
T: PosNormalChannelScalar + Display + Float,
[src]
T: PosNormalChannelScalar + Display + Float,
impl<T> EncodableColor for Rgi<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
fn encoded_as<E>(self, encoding: E) -> EncodedColor<Self, E> where
E: ColorEncoding,
[src]
E: ColorEncoding,
fn linear(self) -> EncodedColor<Self, LinearEncoding>
[src]
fn srgb_encoded(self) -> EncodedColor<Self, SrgbEncoding>
[src]
fn gamma_encoded<T: Float>(
self,
gamma: T
) -> EncodedColor<Self, GammaEncoding<T>>
[src]
self,
gamma: T
) -> EncodedColor<Self, GammaEncoding<T>>
impl<T> Flatten for Rgi<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
fn as_slice(&self) -> &[Self::ChannelFormat]
[src]
fn from_slice(vals: &[T]) -> Self
[src]
impl<T> FromColor<Rgb<T>> for Rgi<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
fn from_color(from: &Rgb<T>) -> Self
[src]
impl<T> FromColor<Rgi<T>> for Rgb<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
fn from_color(from: &Rgi<T>) -> Self
[src]
impl<T> FromTuple for Rgi<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
fn from_tuple(values: Self::ChannelsTuple) -> Self
[src]
impl<T: Hash> Hash for Rgi<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> HomogeneousColor for Rgi<T> where
T: PosNormalChannelScalar + Float,
[src]
T: PosNormalChannelScalar + Float,
impl<T> Lerp for Rgi<T> where
T: PosNormalChannelScalar + Lerp + Float,
[src]
T: PosNormalChannelScalar + Lerp + Float,
type Position = <T as Lerp>::Position
The type of the pos
argument
fn lerp(&self, right: &Self, pos: Self::Position) -> Self
[src]
impl<T: PartialEq> PartialEq<Rgi<T>> for Rgi<T>
[src]
impl<T: PartialOrd> PartialOrd<Rgi<T>> for Rgi<T>
[src]
fn partial_cmp(&self, other: &Rgi<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Rgi<T>) -> bool
[src]
fn le(&self, other: &Rgi<T>) -> bool
[src]
fn gt(&self, other: &Rgi<T>) -> bool
[src]
fn ge(&self, other: &Rgi<T>) -> bool
[src]
impl<T> RelativeEq<Rgi<T>> for Rgi<T> where
T: PosNormalChannelScalar + RelativeEq + Float,
T::Epsilon: Clone,
[src]
T: PosNormalChannelScalar + RelativeEq + Float,
T::Epsilon: Clone,
fn default_max_relative() -> Self::Epsilon
[src]
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
impl<T> StructuralPartialEq for Rgi<T>
[src]
impl<T> UlpsEq<Rgi<T>> for Rgi<T> where
T: PosNormalChannelScalar + UlpsEq + Float,
T::Epsilon: Clone,
[src]
T: PosNormalChannelScalar + UlpsEq + Float,
T::Epsilon: Clone,
Auto Trait Implementations
impl<T> RefUnwindSafe for Rgi<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Rgi<T> where
T: Send,
T: Send,
impl<T> Sync for Rgi<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Rgi<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Rgi<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,