#[repr(C)]pub struct Rgb<T> { /* private fields */ }Expand description
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§
Source§impl<T> Rgb<T>where
T: PosNormalChannelScalar,
impl<T> Rgb<T>where
T: PosNormalChannelScalar,
Sourcepub fn new(red: T, green: T, blue: T) -> Self
pub fn new(red: T, green: T, blue: T) -> Self
Construct a new Rgb instance with the given channel values
Sourcepub fn color_cast<TOut>(&self) -> Rgb<TOut>where
T: ChannelFormatCast<TOut>,
TOut: PosNormalChannelScalar,
pub fn color_cast<TOut>(&self) -> Rgb<TOut>where
T: ChannelFormatCast<TOut>,
TOut: PosNormalChannelScalar,
Convert the internal channel scalar format
Source§impl<T> Rgb<T>where
T: PosNormalChannelScalar + Float,
impl<T> Rgb<T>where
T: PosNormalChannelScalar + Float,
Sourcepub fn chromaticity_coordinates(&self) -> ChromaticityCoordinates<T>
pub fn chromaticity_coordinates(&self) -> ChromaticityCoordinates<T>
Compute the ChromaticityCooridinates
for an Rgb instance
Trait Implementations§
Source§impl<T> AbsDiffEq for Rgb<T>
impl<T> AbsDiffEq for Rgb<T>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§impl<T> Bounded for Rgb<T>where
T: PosNormalChannelScalar,
impl<T> Bounded for Rgb<T>where
T: PosNormalChannelScalar,
Source§impl<T> Broadcast for Rgb<T>where
T: PosNormalChannelScalar,
impl<T> Broadcast for Rgb<T>where
T: PosNormalChannelScalar,
Source§impl<T> Color for Rgb<T>where
T: PosNormalChannelScalar,
impl<T> Color for Rgb<T>where
T: PosNormalChannelScalar,
Source§type ChannelsTuple = (T, T, T)
type ChannelsTuple = (T, T, T)
Source§fn num_channels() -> u32
fn num_channels() -> u32
Source§fn to_tuple(self) -> Self::ChannelsTuple
fn to_tuple(self) -> Self::ChannelsTuple
Source§impl<T, E> ConvertToXyz<T, Rgb<T>, E> for SRgb<T>where
T: Float + FreeChannelScalar + PosNormalChannelScalar + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
E: ColorEncoding,
impl<T, E> ConvertToXyz<T, Rgb<T>, E> for SRgb<T>where
T: Float + FreeChannelScalar + PosNormalChannelScalar + ChannelFormatCast<f64>,
f64: ChannelFormatCast<T>,
E: ColorEncoding,
Source§type OutputColor = Xyz<T>
type OutputColor = Xyz<T>
XyzSource§fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, E>) -> Self::OutputColor
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, E>) -> Self::OutputColor
color into the XYZ spaceSource§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,
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,
Source§type OutputColor = Xyz<T>
type OutputColor = Xyz<T>
XyzSource§fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
color into the XYZ spaceSource§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,
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,
Source§type OutputColor = Xyz<T>
type OutputColor = Xyz<T>
XyzSource§fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
color into the XYZ spaceSource§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,
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,
Source§type OutputColor = Xyz<T>
type OutputColor = Xyz<T>
XyzSource§fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
color into the XYZ spaceSource§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,
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,
Source§type OutputColor = Xyz<T>
type OutputColor = Xyz<T>
XyzSource§fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
fn convert_to_xyz(&self, color: &EncodedColor<Rgb<T>, EIn>) -> Self::OutputColor
color into the XYZ spaceSource§impl<T> EncodableColor for Rgb<T>where
T: PosNormalChannelScalar,
impl<T> EncodableColor for Rgb<T>where
T: PosNormalChannelScalar,
Source§fn encoded_as<E>(self, encoding: E) -> EncodedColor<Self, E>where
E: ColorEncoding,
fn encoded_as<E>(self, encoding: E) -> EncodedColor<Self, E>where
E: ColorEncoding,
Source§fn linear(self) -> EncodedColor<Self, LinearEncoding>
fn linear(self) -> EncodedColor<Self, LinearEncoding>
Source§fn srgb_encoded(self) -> EncodedColor<Self, SrgbEncoding>
fn srgb_encoded(self) -> EncodedColor<Self, SrgbEncoding>
Source§fn gamma_encoded<T: Float>(
self,
gamma: T,
) -> EncodedColor<Self, GammaEncoding<T>>
fn gamma_encoded<T: Float>( self, gamma: T, ) -> EncodedColor<Self, GammaEncoding<T>>
Source§impl<T> Flatten for Rgb<T>where
T: PosNormalChannelScalar,
impl<T> Flatten for Rgb<T>where
T: PosNormalChannelScalar,
Source§fn as_slice(&self) -> &[Self::ChannelFormat]
fn as_slice(&self) -> &[Self::ChannelFormat]
SelfSource§fn from_slice(vals: &[T]) -> Self
fn from_slice(vals: &[T]) -> Self
Self constructed from valuesSource§impl<T, A> From<Rgb<T>> for Hsi<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
impl<T, A> From<Rgb<T>> for Hsi<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
Source§impl<T, A> From<Rgb<T>> for eHsi<T, A>where
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>>,
Source§impl<T, A> FromColor<Hsl<T, A>> for Rgb<T>
impl<T, A> FromColor<Hsl<T, A>> for Rgb<T>
Source§fn from_color(from: &Hsl<T, A>) -> Self
fn from_color(from: &Hsl<T, A>) -> Self
Self from fromSource§impl<T, A> FromColor<Hsv<T, A>> for Rgb<T>
impl<T, A> FromColor<Hsv<T, A>> for Rgb<T>
Source§fn from_color(from: &Hsv<T, A>) -> Self
fn from_color(from: &Hsv<T, A>) -> Self
Self from fromSource§impl<T, A> FromColor<Hwb<T, A>> for Rgb<T>
impl<T, A> FromColor<Hwb<T, A>> for Rgb<T>
Source§fn from_color(from: &Hwb<T, A>) -> Self
fn from_color(from: &Hwb<T, A>) -> Self
Self from fromSource§impl<T, A> FromColor<Rgb<T>> for Hsi<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
impl<T, A> FromColor<Rgb<T>> for Hsi<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
Source§fn from_color(from: &Rgb<T>) -> Self
fn from_color(from: &Rgb<T>) -> Self
Self from fromSource§impl<T, A> FromColor<Rgb<T>> for Hsl<T, A>
impl<T, A> FromColor<Rgb<T>> for Hsl<T, A>
Source§fn from_color(from: &Rgb<T>) -> Self
fn from_color(from: &Rgb<T>) -> Self
Self from fromSource§impl<T, A> FromColor<Rgb<T>> for Hsv<T, A>
impl<T, A> FromColor<Rgb<T>> for Hsv<T, A>
Source§fn from_color(from: &Rgb<T>) -> Self
fn from_color(from: &Rgb<T>) -> Self
Self from fromSource§impl<T, A> FromColor<Rgb<T>> for Hwb<T, A>
impl<T, A> FromColor<Rgb<T>> for Hwb<T, A>
Source§fn from_color(from: &Rgb<T>) -> Self
fn from_color(from: &Rgb<T>) -> Self
Self from fromSource§impl<T> FromColor<Rgb<T>> for Rgi<T>where
T: PosNormalChannelScalar + Float,
impl<T> FromColor<Rgb<T>> for Rgi<T>where
T: PosNormalChannelScalar + Float,
Source§fn from_color(from: &Rgb<T>) -> Self
fn from_color(from: &Rgb<T>) -> Self
Self from fromSource§impl<T, M> FromColor<Rgb<T>> for YCbCr<T, M>
impl<T, M> FromColor<Rgb<T>> for YCbCr<T, M>
Source§fn from_color(from: &Rgb<T>) -> YCbCr<T, M>
fn from_color(from: &Rgb<T>) -> YCbCr<T, M>
Self from fromSource§impl<T, A> FromColor<Rgb<T>> for eHsi<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
impl<T, A> FromColor<Rgb<T>> for eHsi<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Rad<T>>,
Source§fn from_color(from: &Rgb<T>) -> Self
fn from_color(from: &Rgb<T>) -> Self
Self from fromSource§impl<T> FromColor<Rgi<T>> for Rgb<T>where
T: PosNormalChannelScalar + Float,
impl<T> FromColor<Rgi<T>> for Rgb<T>where
T: PosNormalChannelScalar + Float,
Source§fn from_color(from: &Rgi<T>) -> Self
fn from_color(from: &Rgi<T>) -> Self
Self from fromSource§impl<T, A> FromColor<eHsi<T, A>> for Rgb<T>
impl<T, A> FromColor<eHsi<T, A>> for Rgb<T>
Source§fn from_color(from: &eHsi<T, A>) -> Rgb<T>
fn from_color(from: &eHsi<T, A>) -> Rgb<T>
Self from fromSource§impl<T, A> FromHsi<Hsi<T, A>> for Rgb<T>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + IntoAngle<Rad<T>, OutputScalar = T>,
impl<T, A> FromHsi<Hsi<T, A>> for Rgb<T>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + IntoAngle<Rad<T>, OutputScalar = T>,
Source§impl<T> FromTuple for Rgb<T>where
T: PosNormalChannelScalar,
impl<T> FromTuple for Rgb<T>where
T: PosNormalChannelScalar,
Source§fn from_tuple(values: Self::ChannelsTuple) -> Self
fn from_tuple(values: Self::ChannelsTuple) -> Self
Self from a tuple of channel valuesSource§impl<T, M> FromYCbCr<YCbCr<T, M>> for Rgb<T>
impl<T, M> FromYCbCr<YCbCr<T, M>> for Rgb<T>
Source§fn from_ycbcr(
from: &YCbCr<T, M>,
out_of_gamut_mode: YCbCrOutOfGamutMode,
) -> Rgb<T>
fn from_ycbcr( from: &YCbCr<T, M>, out_of_gamut_mode: YCbCrOutOfGamutMode, ) -> Rgb<T>
Self from from, describing what to do if the color is out of gamut for SelfSource§impl<T> HomogeneousColor for Rgb<T>where
T: PosNormalChannelScalar,
impl<T> HomogeneousColor for Rgb<T>where
T: PosNormalChannelScalar,
Source§impl<T> Invert for Rgb<T>where
T: PosNormalChannelScalar,
impl<T> Invert for Rgb<T>where
T: PosNormalChannelScalar,
Source§impl<T: Ord> Ord for Rgb<T>
impl<T: Ord> Ord for Rgb<T>
Source§impl<T: PartialOrd> PartialOrd for Rgb<T>
impl<T: PartialOrd> PartialOrd for Rgb<T>
Source§impl<T> RelativeEq for Rgb<T>
impl<T> RelativeEq for Rgb<T>
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
Source§impl<T> TranscodableColor for Rgb<T>
impl<T> TranscodableColor for Rgb<T>
Source§type IntermediateColor = Rgb<f64>
type IntermediateColor = Rgb<f64>
Source§fn encode_color<Encoder>(self, enc: &Encoder) -> Selfwhere
Encoder: ChannelEncoder,
fn encode_color<Encoder>(self, enc: &Encoder) -> Selfwhere
Encoder: ChannelEncoder,
self using the encoder encSource§fn decode_color<Decoder>(self, dec: &Decoder) -> Selfwhere
Decoder: ChannelDecoder,
fn decode_color<Decoder>(self, dec: &Decoder) -> Selfwhere
Decoder: ChannelDecoder,
self using the decoder dec