colorutils_rs

Struct Rgb

source
#[repr(C)]
pub struct Rgb<T> { pub r: T, pub g: T, pub b: T, }
Expand description

Represents any RGB values, Rgb, Rgb etc.

Fields§

§r: T

Red component

§g: T

Green component

§b: T

Blue component

Implementations§

source§

impl Rgb<u8>

source

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

source

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

source

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

source

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

source

pub fn to_xyz( &self, matrix: &[[f32; 3]; 3], transfer_function: TransferFunction, ) -> Xyz

Converts rgb to XYZ

§Arguments

transfer_function - Transfer function to convert RGB into linear RGB

source

pub fn to_hsl(&self) -> Hsl

Converts rgb to HSL

source

pub fn to_hsv(&self) -> Hsv

Converts rgb to HSV

source

pub fn to_lab(&self) -> Lab

Converts rgb to CIELAB

source

pub fn to_luv(&self) -> Luv

Converts rgb to CIELUV

source

pub fn to_lch(&self) -> LCh

Converts rgb to CIELCH

source

pub fn to_rgb_f32(&self) -> Rgb<f32>

Converts rgb to RGB f32

source

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

source

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

source

pub fn to_sigmoidal(&self) -> Sigmoidal

Converts rgb to S-shaped sigmoidized components

source

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

source

pub fn blend_add(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_hsl_color(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_substract(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_lighten(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_darken(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_color_burn(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_color_dodge(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_screen(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_linear_light(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_vivid_light(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_pin_light(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_hard_mix(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_soft_light(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn blend_exclusion(&self, other: Rgb<u8>) -> Rgb<u8>

source

pub fn saturation(&self, saturation: f32) -> Rgb<u8>

source§

impl Rgb<f32>

source

pub fn apply(&self, gen: fn(_: f32) -> f32) -> Self

source

pub fn gamma(&self, transfer_function: TransferFunction) -> Self

source

pub fn linearize(&self, transfer_function: TransferFunction) -> Self

source

pub fn to_u8(&self) -> Rgb<u8>

source

pub fn clip_color(&self) -> Rgb<f32>

source

pub fn blend_hsl_color(&self, backdrop: Rgb<f32>) -> Rgb<f32>

source

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)

source

pub fn blend_substract(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_lighten(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_darken(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_color_burn(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_color_dodge(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_screen(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_linear_light(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_vivid_light(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_pin_light(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_hard_mix(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_reflect(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_difference(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_hard_light(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_soft_light(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn blend_exclusion(&self, other: Rgb<f32>) -> Rgb<f32>

source

pub fn saturation(&self, saturation: f32) -> Rgb<f32>

source

pub fn grayscale(&self, grayscale_amount: f32) -> Rgb<f32>

source§

impl<T> Rgb<T>

source

pub fn new(r: T, g: T, b: T) -> Rgb<T>

source§

impl<T> Rgb<T>
where T: Copy,

source

pub fn dup(v: T) -> Rgb<T>

source§

impl Rgb<f32>

source

pub fn zeroed() -> Rgb<f32>

source

pub fn ones() -> Rgb<f32>

source

pub fn white() -> Rgb<f32>

source

pub fn black() -> Rgb<f32>

source

pub fn contrast(&self, contrast: f32) -> Rgb<f32>

source§

impl Rgb<f64>

source

pub fn zeroed() -> Rgb<f64>

source

pub fn ones() -> Rgb<f64>

source

pub fn white() -> Rgb<f64>

source

pub fn black() -> Rgb<f64>

source

pub fn contrast(&self, contrast: f64) -> Rgb<f64>

source§

impl Rgb<u8>

source

pub fn zeroed() -> Rgb<u8>

source

pub fn capped() -> Rgb<u8>

source

pub fn white() -> Rgb<u8>

source

pub fn black() -> Rgb<u8>

source§

impl Rgb<u16>

source

pub fn zeroed() -> Rgb<u16>

source

pub fn capped() -> Rgb<u16>

source

pub fn white() -> Rgb<u16>

source

pub fn black() -> Rgb<u16>

source§

impl Rgb<i8>

source

pub fn zeroed() -> Rgb<i8>

source

pub fn capped() -> Rgb<i8>

source

pub fn white() -> Rgb<i8>

source

pub fn black() -> Rgb<i8>

source§

impl Rgb<i16>

source

pub fn zeroed() -> Rgb<i16>

source

pub fn capped() -> Rgb<i16>

source

pub fn white() -> Rgb<i16>

source

pub fn black() -> Rgb<i16>

source§

impl Rgb<i32>

source

pub fn zeroed() -> Rgb<i32>

source

pub fn capped() -> Rgb<i32>

source

pub fn white() -> Rgb<i32>

source

pub fn black() -> Rgb<i32>

source§

impl Rgb<u32>

source

pub fn zeroed() -> Rgb<u32>

source

pub fn capped() -> Rgb<u32>

source

pub fn white() -> Rgb<u32>

source

pub fn black() -> Rgb<u32>

source§

impl Rgb<u8>

source

pub fn contrast(&self, contrast: f32) -> Rgb<u8>

source

pub fn grayscale(&self, grayscale_amount: f32) -> Rgb<u8>

source§

impl<T> Rgb<T>
where T: Copy,

source

pub fn to_rgba(&self, a: T) -> Rgba<T>

source§

impl<T> Rgb<T>
where T: Num + PartialOrd + Copy + Bounded + Ord,

source

pub fn clamp(&self, min_value: T, max_value: T) -> Rgb<T>

Clamp function to clamp each channel within a given range

source

pub fn min(&self, other_min: T) -> Rgb<T>

Min function to define min

source

pub fn max(&self, other_max: T) -> Rgb<T>

Max function to define max

source

pub fn clamp_p(&self, min_value: Rgb<T>, max_value: Rgb<T>) -> Rgb<T>

Clamp function to clamp each channel within a given range

source

pub fn min_p(&self, other_min: Rgb<T>) -> Rgb<T>

Min function to define min

source

pub fn max_p(&self, other_max: Rgb<T>) -> Rgb<T>

Max function to define max

source§

impl<T> Rgb<T>
where T: Float + 'static, f32: AsPrimitive<T>,

source

pub fn sqrt(&self) -> Rgb<T>

source

pub fn cbrt(&self) -> Rgb<T>

source§

impl<T> Rgb<T>

source

pub fn cast<V>(self) -> Rgb<V>
where T: AsPrimitive<V>, V: Copy + 'static,

source§

impl<T> Rgb<T>
where T: Float + 'static,

source

pub fn round(self) -> Rgb<T>

Trait Implementations§

source§

impl<T> Add for Rgb<T>
where T: Add<Output = T>,

source§

type Output = Rgb<T>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<T> AddAssign<f32> for Rgb<T>
where T: AddAssign<f32>,

source§

fn add_assign(&mut self, rhs: f32)

Performs the += operation. Read more
source§

impl<T> AddAssign<f64> for Rgb<T>
where T: AddAssign<f64>,

source§

fn add_assign(&mut self, rhs: f64)

Performs the += operation. Read more
source§

impl<T> AddAssign<i16> for Rgb<T>
where T: AddAssign<i16>,

source§

fn add_assign(&mut self, rhs: i16)

Performs the += operation. Read more
source§

impl<T> AddAssign<i32> for Rgb<T>
where T: AddAssign<i32>,

source§

fn add_assign(&mut self, rhs: i32)

Performs the += operation. Read more
source§

impl<T> AddAssign<i8> for Rgb<T>
where T: AddAssign<i8>,

source§

fn add_assign(&mut self, rhs: i8)

Performs the += operation. Read more
source§

impl<T> AddAssign<u16> for Rgb<T>
where T: AddAssign<u16>,

source§

fn add_assign(&mut self, rhs: u16)

Performs the += operation. Read more
source§

impl<T> AddAssign<u32> for Rgb<T>
where T: AddAssign<u32>,

source§

fn add_assign(&mut self, rhs: u32)

Performs the += operation. Read more
source§

impl<T> AddAssign<u8> for Rgb<T>
where T: AddAssign<u8>,

source§

fn add_assign(&mut self, rhs: u8)

Performs the += operation. Read more
source§

impl<T> AddAssign for Rgb<T>
where T: AddAssign<T>,

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<T: Clone> Clone for Rgb<T>

source§

fn clone(&self) -> Rgb<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Rgb<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Rgb<f32>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Default for Rgb<f64>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Default for Rgb<i16>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Default for Rgb<i32>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Default for Rgb<i8>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Default for Rgb<u16>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Default for Rgb<u32>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Default for Rgb<u8>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T> Div for Rgb<T>
where T: Div<Output = T>,

source§

type Output = Rgb<T>

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
source§

impl<T> DivAssign<f32> for Rgb<T>
where T: DivAssign<f32>,

source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
source§

impl<T> DivAssign<f64> for Rgb<T>
where T: DivAssign<f64>,

source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
source§

impl<T> DivAssign<i16> for Rgb<T>
where T: DivAssign<i16>,

source§

fn div_assign(&mut self, rhs: i16)

Performs the /= operation. Read more
source§

impl<T> DivAssign<i32> for Rgb<T>
where T: DivAssign<i32>,

source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
source§

impl<T> DivAssign<i8> for Rgb<T>
where T: DivAssign<i8>,

source§

fn div_assign(&mut self, rhs: i8)

Performs the /= operation. Read more
source§

impl<T> DivAssign<u16> for Rgb<T>
where T: DivAssign<u16>,

source§

fn div_assign(&mut self, rhs: u16)

Performs the /= operation. Read more
source§

impl<T> DivAssign<u32> for Rgb<T>
where T: DivAssign<u32>,

source§

fn div_assign(&mut self, rhs: u32)

Performs the /= operation. Read more
source§

impl<T> DivAssign<u8> for Rgb<T>
where T: DivAssign<u8>,

source§

fn div_assign(&mut self, rhs: u8)

Performs the /= operation. Read more
source§

impl<T> DivAssign for Rgb<T>
where T: DivAssign<T>,

source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
source§

impl<T> EuclideanDistance for Rgb<T>
where T: Copy + AsPrimitive<f32>,

source§

fn euclidean_distance(&self, other: Rgb<T>) -> f32

source§

impl From<Rgb<f32>> for Rgb<u8>

source§

fn from(value: Rgb<f32>) -> Self

Converts to this type from the input type.
source§

impl From<Rgb<f32>> for Sigmoidal

source§

fn from(value: Rgb<f32>) -> Self

Converts to this type from the input type.
source§

impl From<Rgb<u8>> for Sigmoidal

source§

fn from(value: Rgb<u8>) -> Self

Converts to this type from the input type.
source§

impl From<Sigmoidal> for Rgb<u8>

source§

fn from(value: Sigmoidal) -> Self

Converts to this type from the input type.
source§

impl<T> Index<usize> for Rgb<T>

source§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: usize) -> &T

Performs the indexing (container[index]) operation. Read more
source§

impl<T> IndexMut<usize> for Rgb<T>

source§

fn index_mut(&mut self, index: usize) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<T> Mul for Rgb<T>
where T: Mul<Output = T>,

source§

type Output = Rgb<T>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<T> MulAssign<f32> for Rgb<T>
where T: MulAssign<f32>,

source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
source§

impl<T> MulAssign<f64> for Rgb<T>
where T: MulAssign<f64>,

source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
source§

impl<T> MulAssign<i16> for Rgb<T>
where T: MulAssign<i16>,

source§

fn mul_assign(&mut self, rhs: i16)

Performs the *= operation. Read more
source§

impl<T> MulAssign<i32> for Rgb<T>
where T: MulAssign<i32>,

source§

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
source§

impl<T> MulAssign<i8> for Rgb<T>
where T: MulAssign<i8>,

source§

fn mul_assign(&mut self, rhs: i8)

Performs the *= operation. Read more
source§

impl<T> MulAssign<u16> for Rgb<T>
where T: MulAssign<u16>,

source§

fn mul_assign(&mut self, rhs: u16)

Performs the *= operation. Read more
source§

impl<T> MulAssign<u32> for Rgb<T>
where T: MulAssign<u32>,

source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
source§

impl<T> MulAssign<u8> for Rgb<T>
where T: MulAssign<u8>,

source§

fn mul_assign(&mut self, rhs: u8)

Performs the *= operation. Read more
source§

impl<T> MulAssign for Rgb<T>
where T: MulAssign<T>,

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl<T> Neg for Rgb<T>
where T: Neg<Output = T>,

source§

type Output = Rgb<T>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<T: PartialEq> PartialEq for Rgb<T>

source§

fn eq(&self, other: &Rgb<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd> PartialOrd for Rgb<T>

source§

fn partial_cmp(&self, other: &Rgb<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T> Pow<Rgb<T>> for Rgb<T>
where T: Float,

source§

type Output = Rgb<T>

The result after applying the operator.
source§

fn pow(self, rhs: Rgb<T>) -> Self::Output

Returns self to the power rhs. Read more
source§

impl<T> Pow<T> for Rgb<T>
where T: Float,

source§

type Output = Rgb<T>

The result after applying the operator.
source§

fn pow(self, rhs: T) -> Self::Output

Returns self to the power rhs. Read more
source§

impl<T> Sub for Rgb<T>
where T: Sub<Output = T>,

source§

type Output = Rgb<T>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<T> TaxicabDistance for Rgb<T>
where T: Copy + AsPrimitive<f32>,

source§

fn taxicab_distance(&self, other: Self) -> f32

source§

impl<T: Copy> Copy for Rgb<T>

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.