colorutils_rs

Struct Rgba

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

Represents any RGBA values, Rgba, Rgba etc.

Fields§

§r: T

Red component

§g: T

Green component

§b: T

Blue component

§a: T

Alpha component

Implementations§

source§

impl Rgba<f16>

source

pub fn from_rgb(r: f16, g: f16, b: f16) -> Rgba<f16>

source§

impl<T> Rgba<T>

source

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

source§

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

source

pub fn dup(v: T) -> Self

source§

impl Rgba<f32>

source

pub fn zeroed() -> Rgba<f32>

source

pub fn ones() -> Rgba<f32>

source

pub fn white() -> Rgba<f32>

source

pub fn black() -> Rgba<f32>

source

pub fn from_rgb(r: f32, g: f32, b: f32) -> Rgba<f32>

source§

impl Rgba<f64>

source

pub fn zeroed() -> Rgba<f64>

source

pub fn ones() -> Rgba<f64>

source

pub fn white() -> Rgba<f64>

source

pub fn black() -> Rgba<f64>

source

pub fn from_rgb(r: f64, g: f64, b: f64) -> Rgba<f64>

source§

impl Rgba<u8>

source

pub fn zeroed() -> Rgba<u8>

source

pub fn capped() -> Rgba<u8>

source

pub fn black() -> Rgba<u8>

source

pub fn white() -> Rgba<u8>

source§

impl Rgba<u16>

source

pub fn zeroed() -> Rgba<u16>

source

pub fn capped() -> Rgba<u16>

source

pub fn black() -> Rgba<u16>

source

pub fn white() -> Rgba<u16>

source§

impl Rgba<i8>

source

pub fn zeroed() -> Rgba<i8>

source

pub fn capped() -> Rgba<i8>

source

pub fn black() -> Rgba<i8>

source

pub fn white() -> Rgba<i8>

source§

impl Rgba<i16>

source

pub fn zeroed() -> Rgba<i16>

source

pub fn capped() -> Rgba<i16>

source

pub fn black() -> Rgba<i16>

source

pub fn white() -> Rgba<i16>

source§

impl Rgba<i32>

source

pub fn zeroed() -> Rgba<i32>

source

pub fn capped() -> Rgba<i32>

source

pub fn black() -> Rgba<i32>

source

pub fn white() -> Rgba<i32>

source§

impl Rgba<u32>

source

pub fn zeroed() -> Rgba<u32>

source

pub fn capped() -> Rgba<u32>

source

pub fn black() -> Rgba<u32>

source

pub fn white() -> Rgba<u32>

source§

impl Rgba<f32>

source

pub fn blend_over_alpha(&self, color_foreground: Rgba<f32>) -> Rgba<f32>

Using alpha blend over algorithm where current color is on bottom ( destination )

source

pub fn blend_over_with_op( &self, color_foreground: Rgba<f32>, op: fn(_: f32, _: f32) -> f32, ) -> Rgba<f32>

Using alpha blend over algorithm where current color is on bottom ( destination ) aR = aA + aB·(1−aA) xR = 1/aR · [ (1−aB)·xaA + (1−aA)·xaB + aA·aB·f(xA,xB) ]

source

pub fn blend_overlay(&self, other: Rgba<f32>) -> Rgba<f32>

source

pub fn blend_add(&self, other: Rgba<f32>) -> Rgba<f32>

The output of the ADD operator is the same for both bounded and unbounded source interpretations. Resulting alpha (aR) - min(1, aA+aB) Resulting color (xR) - (xaA + xaB)/aR

source

pub fn blend_saturate(&self, other: Rgba<f32>) -> Rgba<f32>

The output of the ADD operator is the same for both bounded and unbounded source interpretations. Resulting alpha (aR) - min(1, aA+aB) Resulting color (xR) - (min(aA, 1−aB)·xA + xaB)/aR

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

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

source

pub fn blend_in(&self, other: Rgba<f32>) -> Rgba<f32>

source

pub fn blend_out(&self, other: Rgba<f32>) -> Rgba<f32>

source

pub fn blend_atop(&self, other: Rgba<f32>) -> Rgba<f32>

source

pub fn blend_dest_out(&self, other: Rgba<f32>) -> Rgba<f32>

source

pub fn blend_dest_atop(&self, other: Rgba<f32>) -> Rgba<f32>

source

pub fn blend_xor(&self, other: Rgba<f32>) -> Rgba<f32>

The output of the ADD operator is the same for both bounded and unbounded source interpretations. Resulting alpha (aR) - aA + aB − 2·aA·aB Resulting color (xR) - (xaA·(1−aB) + xaB·(1−aA))/aR

source

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

source

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

source

pub fn blend_hsl_saturation(&self, backdrop: Rgba<f32>) -> Rgba<f32>

source

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

source

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

source

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

source§

impl Rgba<u8>

source

pub fn from_rgb(r: u8, g: u8, b: u8) -> Rgba<u8>

source

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

source

pub fn blend_over_alpha(&self, color_foreground: Rgba<u8>) -> Rgba<u8>

Using alpha blend over algorithm where current color is on bottom ( destination )

source

pub fn blend_hsl_color(&self, backdrop: Rgba<u8>) -> Rgba<u8>

f(cA,cB) = set_lum(cA, lum(cB))

source

pub fn blend_hsl_lumonosity(&self, backdrop: Rgba<u8>) -> Rgba<u8>

f(cA,cB) = set_lum(cB, lum(cA))

source

pub fn blend_overlay(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_add(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_substract(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_lighten(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_darken(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_color_burn(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_color_dodge(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_screen(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_linear_light(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_vivid_light(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_pin_light(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_hard_mix(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_reflect(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_difference(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_saturate(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_hard_light(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_soft_light(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_exclusion(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_in(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_out(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_atop(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_dest_out(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_dest_atop(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

pub fn blend_xor(&self, backdrop: Rgba<u8>) -> Rgba<u8>

source

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

source

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

source

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

source

pub fn to_linear(&self, transfer_function: TransferFunction) -> Rgba<f32>

Converts gamma corrected RGBA to linear RGBA

§Arguments

transfer_function - Transfer function to convert RGB into linear RGB

source

pub fn from_linear( linear_rgb: Rgba<f32>, transfer_function: TransferFunction, ) -> Rgba<u8>

Converts gamma corrected RGB to linear RGB

§Arguments

transfer_function - Transfer function to convert RGB into linear RGB

source§

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

source

pub fn clamp(&self, min: T, max: T) -> Rgba<T>

Clamp function to clamp each channel within a given range

source

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

Min function to define min

source

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

Max function to define max

source

pub fn clamp_p(&self, min: Rgba<T>, max: Rgba<T>) -> Rgba<T>

Clamp function to clamp each channel within a given range

source

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

Min function to define min

source

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

Max function to define max

source§

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

source

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

source

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

Trait Implementations§

source§

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

source§

type Output = Rgba<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 for Rgba<T>
where T: AddAssign<T>,

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<T: Clone> Clone for Rgba<T>

source§

fn clone(&self) -> Rgba<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 Rgba<T>

source§

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

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

impl Default for Rgba<f32>

source§

fn default() -> Self

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

impl Default for Rgba<f64>

source§

fn default() -> Self

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

impl Default for Rgba<i16>

source§

fn default() -> Self

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

impl Default for Rgba<i32>

source§

fn default() -> Self

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

impl Default for Rgba<i8>

source§

fn default() -> Self

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

impl Default for Rgba<u16>

source§

fn default() -> Self

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

impl Default for Rgba<u32>

source§

fn default() -> Self

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

impl Default for Rgba<u8>

source§

fn default() -> Self

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

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

source§

type Output = Rgba<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 Rgba<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 Rgba<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 Rgba<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 Rgba<T>
where T: DivAssign<i32> + Copy,

source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
source§

impl<T> DivAssign<u16> for Rgba<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 Rgba<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 Rgba<T>
where T: DivAssign<u8> + Copy,

source§

fn div_assign(&mut self, rhs: u8)

Performs the /= operation. Read more
source§

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

source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
source§

impl<T> EuclideanDistance for Rgba<T>
where T: AsPrimitive<f32>,

source§

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

source§

impl<T> Index<usize> for Rgba<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 Rgba<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 Rgba<T>
where T: Mul<Output = T>,

source§

type Output = Rgba<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

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

source§

type Output = Rgba<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 Rgba<T>

source§

fn eq(&self, other: &Rgba<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 Rgba<T>

source§

fn partial_cmp(&self, other: &Rgba<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<Rgba<T>> for Rgba<T>
where T: Float,

source§

type Output = Rgba<T>

The result after applying the operator.
source§

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

Returns self to the power rhs. Read more
source§

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

source§

type Output = Rgba<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 Rgba<T>
where T: Sub<Output = T>,

source§

type Output = Rgba<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 Rgba<T>
where T: AsPrimitive<f32>,

source§

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

source§

impl ToRgb565 for Rgba<f16>

source§

impl ToRgb565 for Rgba<f32>

source§

impl ToRgb565 for Rgba<u8>

source§

impl ToRgba1010102 for Rgba<f16>

source§

impl ToRgba1010102 for Rgba<u8>

source§

impl ToRgba8 for Rgba<f16>

source§

fn to_rgba8(&self) -> Rgba<u8>

source§

impl ToRgba8 for Rgba<f32>

source§

fn to_rgba8(&self) -> Rgba<u8>

source§

impl ToRgbaF16 for Rgba<f32>

source§

impl ToRgbaF16 for Rgba<u8>

source§

impl ToRgbaF32 for Rgba<u8>

source§

impl<T: Copy> Copy for Rgba<T>

source§

impl<T> StructuralPartialEq for Rgba<T>

Auto Trait Implementations§

§

impl<T> Freeze for Rgba<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Rgba<T>
where T: RefUnwindSafe,

§

impl<T> Send for Rgba<T>
where T: Send,

§

impl<T> Sync for Rgba<T>
where T: Sync,

§

impl<T> Unpin for Rgba<T>
where T: Unpin,

§

impl<T> UnwindSafe for Rgba<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.