Struct colorutils_rs::Rgba

source ·
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 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<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<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>

Trait Implementations§

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

default 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> CloneToUninit for T
where T: Copy,

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> ToOwned for T
where T: Clone,

§

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

§

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

§

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.