Struct Rgb

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

Represents any RGB values

Fields§

§r: T

Red component

§g: T

Green component

§b: T

Blue component

Implementations§

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

pub const fn to_vector(self) -> Vector3<T>

Source§

impl Rgb<f32>

Source

pub fn apply(&self, matrix: Matrix3f) -> Rgb<f32>

Source

pub fn to_xyz(&self, matrix: Matrix3f) -> Xyz

Source

pub fn is_out_of_gamut(&self) -> bool

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§

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§

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<T> Rgb<T>
where T: Copy + AsPrimitive<f32>,

Source

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

Source§

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

Source

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

Source§

impl<T> Rgb<T>
where T: Signed + Copy + Clone,

Source

pub fn abs(self) -> Self

Source§

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

Source

pub fn mla(&self, b: Rgb<T>, c: Rgb<T>) -> Rgb<T>

Source§

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

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<T> for Rgb<T>
where T: Add<Output = T> + Copy + Clone,

Source§

type Output = Rgb<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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 duplicate 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<T: Default> Default for Rgb<T>

Source§

fn default() -> Rgb<T>

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

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

Source§

type Output = Rgb<T>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. 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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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> + Copy,

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 FusedExp<Rgb<f32>> for Rgb<f32>

Source§

fn f_exp(&self) -> Rgb<f32>

Source§

impl FusedExp<Rgb<f64>> for Rgb<f64>

Source§

fn f_exp(&self) -> Rgb<f64>

Source§

impl FusedExp10<Rgb<f32>> for Rgb<f32>

Source§

fn f_exp10(&self) -> Rgb<f32>

Source§

impl FusedExp10<Rgb<f64>> for Rgb<f64>

Source§

fn f_exp10(&self) -> Rgb<f64>

Source§

impl FusedExp2<Rgb<f32>> for Rgb<f32>

Source§

fn f_exp2(&self) -> Rgb<f32>

Source§

impl FusedExp2<Rgb<f64>> for Rgb<f64>

Source§

fn f_exp2(&self) -> Rgb<f64>

Source§

impl FusedLog<Rgb<f32>> for Rgb<f32>

Source§

fn f_log(&self) -> Rgb<f32>

Source§

impl FusedLog<Rgb<f64>> for Rgb<f64>

Source§

fn f_log(&self) -> Rgb<f64>

Source§

impl FusedLog10<Rgb<f32>> for Rgb<f32>

Source§

fn f_log10(&self) -> Rgb<f32>

Source§

impl FusedLog10<Rgb<f64>> for Rgb<f64>

Source§

fn f_log10(&self) -> Rgb<f64>

Source§

impl FusedLog2<Rgb<f32>> for Rgb<f32>

Source§

fn f_log2(&self) -> Rgb<f32>

Source§

impl FusedLog2<Rgb<f64>> for Rgb<f64>

Source§

fn f_log2(&self) -> Rgb<f64>

Source§

impl FusedPow<Rgb<f32>> for Rgb<f32>

Source§

fn f_pow(&self, power: Rgb<f32>) -> Rgb<f32>

Source§

impl FusedPow<Rgb<f64>> for Rgb<f64>

Source§

fn f_pow(&self, power: Rgb<f64>) -> Rgb<f64>

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<T> for Rgb<T>
where T: Mul<Output = T> + Clone + Copy,

Source§

type Output = Rgb<T>

The resulting type after applying the * operator.
Source§

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

Performs the * 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<T> for Rgb<T>
where T: Sub<Output = T> + Copy + Clone,

Source§

type Output = Rgb<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. 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: 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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.