[−][src]Struct prisma::Rgb
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]
T: PosNormalChannelScalar,
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]
T: ChannelFormatCast<TOut>,
TOut: PosNormalChannelScalar,
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]
T: PosNormalChannelScalar + Float,
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]
T: PosNormalChannelScalar + AbsDiffEq,
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 Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
fn normalize(self) -> Self
[src]
fn is_normalized(&self) -> bool
[src]
impl<T> Broadcast for Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
impl<T: Clone> Clone for Rgb<T>
[src]
impl<T> Color for Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
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
fn num_channels() -> u32
[src]
fn to_tuple(self) -> Self::ChannelsTuple
[src]
impl<T> Color3 for Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
impl<T, E> ConvertToXyz<T, Rgb<T>, E> for SRgb<T> where
T: Float + FreeChannelScalar + PosNormalChannelScalar + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
E: ColorEncoding,
[src]
T: Float + FreeChannelScalar + PosNormalChannelScalar + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
E: ColorEncoding,
type OutputColor = Xyz<T>
The type to output. Always some form of Xyz
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, E>) -> Self::OutputColor
[src]
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]
T: PosNormalChannelScalar + FreeChannelScalar + Float + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
E: ColorEncoding + PartialEq,
EIn: ColorEncoding + PartialEq,
type OutputColor = Xyz<T>
The type to output. Always some form of Xyz
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
[src]
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]
T: PosNormalChannelScalar + FreeChannelScalar + Float + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
E: ColorEncoding + PartialEq,
EIn: ColorEncoding + PartialEq,
type OutputColor = Xyz<T>
The type to output. Always some form of Xyz
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
[src]
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]
T: PosNormalChannelScalar + FreeChannelScalar + Float + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
E: ColorEncoding + PartialEq,
EIn: ColorEncoding + PartialEq,
type OutputColor = Xyz<T>
The type to output. Always some form of Xyz
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
[src]
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]
T: PosNormalChannelScalar + FreeChannelScalar + Float + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
E: ColorEncoding + PartialEq,
EIn: ColorEncoding + PartialEq,
type OutputColor = Xyz<T>
The type to output. Always some form of Xyz
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
[src]
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]
T: PosNormalChannelScalar + Zero,
impl<T> Display for Rgb<T> where
T: PosNormalChannelScalar + Display,
[src]
T: PosNormalChannelScalar + Display,
impl<T> EncodableColor for Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
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: Eq> Eq for Rgb<T>
[src]
impl<T> Flatten for Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
fn as_slice(&self) -> &[Self::ChannelFormat]
[src]
fn from_slice(vals: &[T]) -> Self
[src]
impl<T, A> From<Hsl<T, A>> for Rgb<T> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
impl<T, A> From<Hsv<T, A>> for Rgb<T> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
impl<T, A> From<Hwb<T, A>> for Rgb<T> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
impl<T, A> From<Rgb<T>> for Hsv<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
impl<T, A> From<Rgb<T>> for Hsl<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
impl<T, A> From<Rgb<T>> for Hwb<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
impl<T, A> From<Rgb<T>> for Hsi<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
impl<T, A> From<Rgb<T>> for eHsi<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
impl<T, M> From<Rgb<T>> for YCbCr<T, M> where
T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
M: YCbCrModel<T> + UnitModel<T>,
[src]
T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
M: YCbCrModel<T> + UnitModel<T>,
impl<T, A> FromColor<Hsl<T, A>> for Rgb<T> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
fn from_color(from: &Hsl<T, A>) -> Self
[src]
impl<T, A> FromColor<Hsv<T, A>> for Rgb<T> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
fn from_color(from: &Hsv<T, A>) -> Self
[src]
impl<T, A> FromColor<Hwb<T, A>> for Rgb<T> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar,
fn from_color(from: &Hwb<T, A>) -> Self
[src]
impl<T, A> FromColor<Rgb<T>> for eHsi<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
fn from_color(from: &Rgb<T>) -> Self
[src]
impl<T, A> FromColor<Rgb<T>> for Hsi<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
fn from_color(from: &Rgb<T>) -> Self
[src]
impl<T, A> FromColor<Rgb<T>> for Hsv<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
fn from_color(from: &Rgb<T>) -> Self
[src]
impl<T, A> FromColor<Rgb<T>> for Hsl<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
fn from_color(from: &Rgb<T>) -> Self
[src]
impl<T, A> FromColor<Rgb<T>> for Hwb<T, A> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + FromAngle<Turns<T>>,
fn from_color(from: &Rgb<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, M> FromColor<Rgb<T>> for YCbCr<T, M> where
T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
M: YCbCrModel<T> + UnitModel<T>,
[src]
T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
M: YCbCrModel<T> + UnitModel<T>,
fn from_color(from: &Rgb<T>) -> YCbCr<T, M>
[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, A> FromColor<eHsi<T, A>> for Rgb<T> where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T>,
[src]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T>,
fn from_color(from: &eHsi<T, A>) -> Rgb<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]
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + IntoAngle<Rad<T>, OutputScalar = T>,
fn from_hsi(value: &Hsi<T, A>, out_of_gamut_mode: HsiOutOfGamutMode) -> Rgb<T>
[src]
impl<T> FromTuple for Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
fn from_tuple(values: Self::ChannelsTuple) -> Self
[src]
impl<T, M> FromYCbCr<YCbCr<T, M>> for Rgb<T> where
T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
M: YCbCrModel<T>,
[src]
T: NormalChannelScalar + PosNormalChannelScalar + NumCast,
M: YCbCrModel<T>,
fn from_ycbcr(
from: &YCbCr<T, M>,
out_of_gamut_mode: YCbCrOutOfGamutMode
) -> Rgb<T>
[src]
from: &YCbCr<T, M>,
out_of_gamut_mode: YCbCrOutOfGamutMode
) -> Rgb<T>
impl<T: Hash> Hash for Rgb<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 Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
impl<T> Invert for Rgb<T> where
T: PosNormalChannelScalar,
[src]
T: PosNormalChannelScalar,
impl<T> Lerp for Rgb<T> where
T: PosNormalChannelScalar + Lerp,
[src]
T: PosNormalChannelScalar + Lerp,
type Position = <T as Lerp>::Position
The type of the pos
argument
fn lerp(&self, right: &Self, pos: Self::Position) -> Self
[src]
impl<T: Ord> Ord for Rgb<T>
[src]
fn cmp(&self, other: &Rgb<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<Rgb<T>> for Rgb<T>
[src]
impl<T: PartialOrd> PartialOrd<Rgb<T>> for Rgb<T>
[src]
fn partial_cmp(&self, other: &Rgb<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Rgb<T>) -> bool
[src]
fn le(&self, other: &Rgb<T>) -> bool
[src]
fn gt(&self, other: &Rgb<T>) -> bool
[src]
fn ge(&self, other: &Rgb<T>) -> bool
[src]
impl<T> RelativeEq<Rgb<T>> for Rgb<T> where
T: PosNormalChannelScalar + RelativeEq,
T::Epsilon: Clone,
[src]
T: PosNormalChannelScalar + RelativeEq,
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> 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]
T: PosNormalChannelScalar + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
type IntermediateColor = Rgb<f64>
The color type used internally to do conversions. This will always have floating-point channels
fn encode_color<Encoder>(self, enc: &Encoder) -> Self where
Encoder: ChannelEncoder,
[src]
Encoder: ChannelEncoder,
fn decode_color<Decoder>(self, dec: &Decoder) -> Self where
Decoder: ChannelDecoder,
[src]
Decoder: ChannelDecoder,
impl<T> UlpsEq<Rgb<T>> for Rgb<T> where
T: PosNormalChannelScalar + UlpsEq,
T::Epsilon: Clone,
[src]
T: PosNormalChannelScalar + UlpsEq,
T::Epsilon: Clone,
Auto Trait Implementations
impl<T> RefUnwindSafe for Rgb<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Rgb<T> where
T: Send,
T: Send,
impl<T> Sync for Rgb<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Rgb<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Rgb<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>,