#[repr(C)]pub struct Rgb<T> {
pub r: T,
pub g: T,
pub b: T,
}Expand description
Represents any RGB values, Rgb
Fields§
§r: TRed component
g: TGreen component
b: TBlue component
Implementations§
source§impl Rgb<u8>
impl Rgb<u8>
sourcepub fn to_linear(&self, transfer_function: TransferFunction) -> Rgb<f32>
pub fn to_linear(&self, transfer_function: TransferFunction) -> Rgb<f32>
Converts gamma corrected RGB to linear RGB
§Arguments
transfer_function - Transfer function to convert RGB into linear RGB
sourcepub fn from_linear(
linear_rgb: Rgb<f32>,
transfer_function: TransferFunction,
) -> Rgb<u8>
pub fn from_linear( linear_rgb: Rgb<f32>, transfer_function: TransferFunction, ) -> Rgb<u8>
Converts gamma corrected RGB to linear RGB
§Arguments
transfer_function - Transfer function to convert RGB into linear RGB
sourcepub fn to_jzazbz(&self, transfer_function: TransferFunction) -> Jzazbz
pub fn to_jzazbz(&self, transfer_function: TransferFunction) -> Jzazbz
Converts rgb to Jzazbz Here is luminance always considered 200 nits
§Arguments
display_luminance - display luminance
transfer_function - Transfer function to convert into linear colorspace and backwards
sourcepub fn to_jzazbz_with_luminance(
&self,
display_luminance: f32,
transfer_function: TransferFunction,
) -> Jzazbz
pub fn to_jzazbz_with_luminance( &self, display_luminance: f32, transfer_function: TransferFunction, ) -> Jzazbz
Converts rgb to Jzazbz
§Arguments
display_luminance - display luminance
transfer_function - Transfer function to convert into linear colorspace and backwards
sourcepub fn to_rgb_f32(&self) -> Rgb<f32>
pub fn to_rgb_f32(&self) -> Rgb<f32>
Converts rgb to RGB f32
sourcepub fn to_oklab(&self, transfer_function: TransferFunction) -> Oklab
pub fn to_oklab(&self, transfer_function: TransferFunction) -> Oklab
Converts rgb to Oklab
§Arguments
transfer_function - Transfer function to convert into linear colorspace and backwards
sourcepub fn to_oklch(&self, transfer_function: TransferFunction) -> Oklch
pub fn to_oklch(&self, transfer_function: TransferFunction) -> Oklch
Converts rgb to Oklch
§Arguments
transfer_function - Transfer function to convert into linear colorspace and backwards
sourcepub fn to_sigmoidal(&self) -> Sigmoidal
pub fn to_sigmoidal(&self) -> Sigmoidal
Converts rgb to S-shaped sigmoidized components
sourcepub fn to_lalphabeta(&self, transfer_function: TransferFunction) -> LAlphaBeta
pub fn to_lalphabeta(&self, transfer_function: TransferFunction) -> LAlphaBeta
Converts rgb to lαβ
§Arguments
transfer_function - Transfer function to convert into linear colorspace and backwards
pub fn blend_add(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_hsl_color(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_substract(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_lighten(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_darken(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_color_burn(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_color_dodge(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_screen(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_linear_light(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_vivid_light(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_pin_light(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_hard_mix(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_soft_light(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn blend_exclusion(&self, other: Rgb<u8>) -> Rgb<u8>
pub fn saturation(&self, saturation: f32) -> Rgb<u8>
source§impl Rgb<f32>
impl Rgb<f32>
pub fn apply(&self, gen: fn(_: f32) -> f32) -> Self
pub fn gamma(&self, transfer_function: TransferFunction) -> Self
pub fn linearize(&self, transfer_function: TransferFunction) -> Self
pub fn to_u8(&self) -> Rgb<u8>
pub fn clip_color(&self) -> Rgb<f32>
pub fn blend_hsl_color(&self, backdrop: Rgb<f32>) -> Rgb<f32>
sourcepub fn blend_add(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_add(&self, other: Rgb<f32>) -> Rgb<f32>
The output of the ADD operator is the same for both bounded and unbounded source interpretations. Resulting color (xR) - (xaA + xaB)
pub fn blend_substract(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_lighten(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_darken(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_color_burn(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_color_dodge(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_screen(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_linear_light(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_vivid_light(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_pin_light(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_hard_mix(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_reflect(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_difference(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_hard_light(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_soft_light(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn blend_exclusion(&self, other: Rgb<f32>) -> Rgb<f32>
pub fn saturation(&self, saturation: f32) -> Rgb<f32>
pub fn grayscale(&self, grayscale_amount: f32) -> Rgb<f32>
source§impl<T> Rgb<T>
impl<T> Rgb<T>
Trait Implementations§
source§impl<T> AddAssign<f32> for Rgb<T>
impl<T> AddAssign<f32> for Rgb<T>
source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
+= operation. Read moresource§impl<T> AddAssign<f64> for Rgb<T>
impl<T> AddAssign<f64> for Rgb<T>
source§fn add_assign(&mut self, rhs: f64)
fn add_assign(&mut self, rhs: f64)
+= operation. Read moresource§impl<T> AddAssign<i16> for Rgb<T>
impl<T> AddAssign<i16> for Rgb<T>
source§fn add_assign(&mut self, rhs: i16)
fn add_assign(&mut self, rhs: i16)
+= operation. Read moresource§impl<T> AddAssign<i32> for Rgb<T>
impl<T> AddAssign<i32> for Rgb<T>
source§fn add_assign(&mut self, rhs: i32)
fn add_assign(&mut self, rhs: i32)
+= operation. Read moresource§impl<T> AddAssign<i8> for Rgb<T>
impl<T> AddAssign<i8> for Rgb<T>
source§fn add_assign(&mut self, rhs: i8)
fn add_assign(&mut self, rhs: i8)
+= operation. Read moresource§impl<T> AddAssign<u16> for Rgb<T>
impl<T> AddAssign<u16> for Rgb<T>
source§fn add_assign(&mut self, rhs: u16)
fn add_assign(&mut self, rhs: u16)
+= operation. Read moresource§impl<T> AddAssign<u32> for Rgb<T>
impl<T> AddAssign<u32> for Rgb<T>
source§fn add_assign(&mut self, rhs: u32)
fn add_assign(&mut self, rhs: u32)
+= operation. Read moresource§impl<T> AddAssign<u8> for Rgb<T>
impl<T> AddAssign<u8> for Rgb<T>
source§fn add_assign(&mut self, rhs: u8)
fn add_assign(&mut self, rhs: u8)
+= operation. Read moresource§impl<T> AddAssign for Rgb<T>where
T: AddAssign<T>,
impl<T> AddAssign for Rgb<T>where
T: AddAssign<T>,
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moresource§impl<T> DivAssign<f32> for Rgb<T>
impl<T> DivAssign<f32> for Rgb<T>
source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
/= operation. Read moresource§impl<T> DivAssign<f64> for Rgb<T>
impl<T> DivAssign<f64> for Rgb<T>
source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/= operation. Read moresource§impl<T> DivAssign<i16> for Rgb<T>
impl<T> DivAssign<i16> for Rgb<T>
source§fn div_assign(&mut self, rhs: i16)
fn div_assign(&mut self, rhs: i16)
/= operation. Read moresource§impl<T> DivAssign<i32> for Rgb<T>
impl<T> DivAssign<i32> for Rgb<T>
source§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
/= operation. Read moresource§impl<T> DivAssign<i8> for Rgb<T>
impl<T> DivAssign<i8> for Rgb<T>
source§fn div_assign(&mut self, rhs: i8)
fn div_assign(&mut self, rhs: i8)
/= operation. Read moresource§impl<T> DivAssign<u16> for Rgb<T>
impl<T> DivAssign<u16> for Rgb<T>
source§fn div_assign(&mut self, rhs: u16)
fn div_assign(&mut self, rhs: u16)
/= operation. Read moresource§impl<T> DivAssign<u32> for Rgb<T>
impl<T> DivAssign<u32> for Rgb<T>
source§fn div_assign(&mut self, rhs: u32)
fn div_assign(&mut self, rhs: u32)
/= operation. Read moresource§impl<T> DivAssign<u8> for Rgb<T>
impl<T> DivAssign<u8> for Rgb<T>
source§fn div_assign(&mut self, rhs: u8)
fn div_assign(&mut self, rhs: u8)
/= operation. Read moresource§impl<T> DivAssign for Rgb<T>where
T: DivAssign<T>,
impl<T> DivAssign for Rgb<T>where
T: DivAssign<T>,
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moresource§impl<T> EuclideanDistance for Rgb<T>
impl<T> EuclideanDistance for Rgb<T>
fn euclidean_distance(&self, other: Rgb<T>) -> f32
source§impl<T> MulAssign<f32> for Rgb<T>
impl<T> MulAssign<f32> for Rgb<T>
source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
*= operation. Read moresource§impl<T> MulAssign<f64> for Rgb<T>
impl<T> MulAssign<f64> for Rgb<T>
source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*= operation. Read moresource§impl<T> MulAssign<i16> for Rgb<T>
impl<T> MulAssign<i16> for Rgb<T>
source§fn mul_assign(&mut self, rhs: i16)
fn mul_assign(&mut self, rhs: i16)
*= operation. Read moresource§impl<T> MulAssign<i32> for Rgb<T>
impl<T> MulAssign<i32> for Rgb<T>
source§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*= operation. Read moresource§impl<T> MulAssign<i8> for Rgb<T>
impl<T> MulAssign<i8> for Rgb<T>
source§fn mul_assign(&mut self, rhs: i8)
fn mul_assign(&mut self, rhs: i8)
*= operation. Read moresource§impl<T> MulAssign<u16> for Rgb<T>
impl<T> MulAssign<u16> for Rgb<T>
source§fn mul_assign(&mut self, rhs: u16)
fn mul_assign(&mut self, rhs: u16)
*= operation. Read moresource§impl<T> MulAssign<u32> for Rgb<T>
impl<T> MulAssign<u32> for Rgb<T>
source§fn mul_assign(&mut self, rhs: u32)
fn mul_assign(&mut self, rhs: u32)
*= operation. Read moresource§impl<T> MulAssign<u8> for Rgb<T>
impl<T> MulAssign<u8> for Rgb<T>
source§fn mul_assign(&mut self, rhs: u8)
fn mul_assign(&mut self, rhs: u8)
*= operation. Read moresource§impl<T> MulAssign for Rgb<T>where
T: MulAssign<T>,
impl<T> MulAssign for Rgb<T>where
T: MulAssign<T>,
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moresource§impl<T: PartialOrd> PartialOrd for Rgb<T>
impl<T: PartialOrd> PartialOrd for Rgb<T>
source§impl<T> TaxicabDistance for Rgb<T>
impl<T> TaxicabDistance for Rgb<T>
fn taxicab_distance(&self, other: Self) -> f32
impl<T: Copy> Copy for Rgb<T>
impl<T> StructuralPartialEq for Rgb<T>
Auto Trait Implementations§
impl<T> Freeze for Rgb<T>where
T: Freeze,
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more