cosmic::cosmic_theme::palette::blend

Struct PreAlpha

source
#[repr(C)]
pub struct PreAlpha<C>
where C: Premultiply,
{ pub color: C, pub alpha: <C as Premultiply>::Scalar, }
Expand description

Premultiplied alpha wrapper.

Premultiplied, or alpha masked, or associated alpha colors have had their component values multiplied with their alpha value. They are commonly used in composition algorithms and as output from computer generated graphics. It may also be preferred when interpolating between colors and in other image manipulation operations, such as blurring or resizing images.

use palette::{LinSrgb, LinSrgba};
use palette::blend::{Blend, PreAlpha};

let a = PreAlpha::from(LinSrgba::new(0.4, 0.5, 0.5, 0.3));
let b = PreAlpha::from(LinSrgba::new(0.3, 0.8, 0.4, 0.4));
let c = PreAlpha::from(LinSrgba::new(0.7, 0.1, 0.8, 0.8));

let res: LinSrgba = a.screen(b).overlay(c).into();

Note that converting to and from premultiplied alpha will cause the alpha component to be clamped to [0.0, 1.0], and fully transparent colors will become black.

Fields§

§color: C

The premultiplied color components (original.color * original.alpha).

§alpha: <C as Premultiply>::Scalar

The transparency component. 0.0 is fully transparent and 1.0 is fully opaque.

Implementations§

source§

impl<C> PreAlpha<C>
where C: Premultiply,

source

pub fn new(color: C, alpha: <C as Premultiply>::Scalar) -> PreAlpha<C>

Alpha mask color with alpha.

source

pub fn new_opaque(color: C) -> PreAlpha<C>
where <C as Premultiply>::Scalar: Stimulus,

Create an opaque alpha masked color.

source

pub fn unpremultiply(self) -> Alpha<C, <C as Premultiply>::Scalar>

Alpha unmask the color.

Trait Implementations§

source§

impl<C, T> AbsDiffEq for PreAlpha<C>
where C: AbsDiffEq<Epsilon = <T as AbsDiffEq>::Epsilon> + Premultiply<Scalar = T>, T: AbsDiffEq, <T as AbsDiffEq>::Epsilon: Clone,

source§

type Epsilon = <T as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> <PreAlpha<C> as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq( &self, other: &PreAlpha<C>, epsilon: <PreAlpha<C> as AbsDiffEq>::Epsilon, ) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
source§

impl<C> Add<f32> for PreAlpha<C>
where C: Premultiply<Scalar = f32> + Add<f32, Output = C>,

source§

type Output = PreAlpha<C>

The resulting type after applying the + operator.
source§

fn add(self, c: f32) -> <PreAlpha<C> as Add<f32>>::Output

Performs the + operation. Read more
source§

impl<C> Add<f64> for PreAlpha<C>
where C: Premultiply<Scalar = f64> + Add<f64, Output = C>,

source§

type Output = PreAlpha<C>

The resulting type after applying the + operator.
source§

fn add(self, c: f64) -> <PreAlpha<C> as Add<f64>>::Output

Performs the + operation. Read more
source§

impl<C> Add for PreAlpha<C>
where C: Premultiply + Add<Output = C>, <C as Premultiply>::Scalar: Add<Output = <C as Premultiply>::Scalar>,

source§

type Output = PreAlpha<C>

The resulting type after applying the + operator.
source§

fn add(self, other: PreAlpha<C>) -> <PreAlpha<C> as Add>::Output

Performs the + operation. Read more
source§

impl<C> AddAssign<f32> for PreAlpha<C>
where C: AddAssign<f32> + Premultiply<Scalar = f32>,

source§

fn add_assign(&mut self, c: f32)

Performs the += operation. Read more
source§

impl<C> AddAssign<f64> for PreAlpha<C>
where C: AddAssign<f64> + Premultiply<Scalar = f64>,

source§

fn add_assign(&mut self, c: f64)

Performs the += operation. Read more
source§

impl<C> AddAssign for PreAlpha<C>

source§

fn add_assign(&mut self, other: PreAlpha<C>)

Performs the += operation. Read more
source§

impl<C, T> ArrayCast for PreAlpha<C>
where C: ArrayCast + Premultiply<Scalar = T>, <C as ArrayCast>::Array: NextArray + ArrayExt<Item = T>,

source§

type Array = <<C as ArrayCast>::Array as NextArray>::Next

The output type of a cast to an array.
source§

impl<C, const N: usize> AsMut<[<C as Premultiply>::Scalar]> for PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn as_mut(&mut self) -> &mut [<C as Premultiply>::Scalar]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<C, const N: usize> AsMut<[<C as Premultiply>::Scalar; N]> for PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn as_mut(&mut self) -> &mut [<C as Premultiply>::Scalar; N]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<C, const N: usize> AsRef<[<C as Premultiply>::Scalar]> for PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn as_ref(&self) -> &[<C as Premultiply>::Scalar]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<C, const N: usize> AsRef<[<C as Premultiply>::Scalar; N]> for PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn as_ref(&self) -> &[<C as Premultiply>::Scalar; N]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<C, T, const N: usize> Blend for PreAlpha<C>
where C: Premultiply<Scalar = T> + StimulusColor + ArrayCast<Array = [T; N]> + Clone, T: Real + Zero + One + MinMax + Clamp + Sqrt + Abs + Arithmetics + PartialCmp + Clone, <T as HasBoolMask>::Mask: LazySelect<T>,

source§

fn multiply(self, other: PreAlpha<C>) -> PreAlpha<C>

Multiply self with other. This uses the alpha component to regulate the effect, so it’s not just plain component wise multiplication.
source§

fn screen(self, other: PreAlpha<C>) -> PreAlpha<C>

Make a color which is at least as light as self or other.
source§

fn overlay(self, other: PreAlpha<C>) -> PreAlpha<C>

Multiply self or other if other is dark, or screen them if other is light. This results in an S curve.
source§

fn darken(self, other: PreAlpha<C>) -> PreAlpha<C>

Return the darkest parts of self and other.
source§

fn lighten(self, other: PreAlpha<C>) -> PreAlpha<C>

Return the lightest parts of self and other.
source§

fn dodge(self, other: PreAlpha<C>) -> PreAlpha<C>

Lighten other to reflect self. Results in other if self is black.
source§

fn burn(self, other: PreAlpha<C>) -> PreAlpha<C>

Darken other to reflect self. Results in other if self is white.
source§

fn hard_light(self, other: PreAlpha<C>) -> PreAlpha<C>

Multiply self or other if other is dark, or screen them if self is light. This is similar to overlay, but depends on self instead of other.
source§

fn soft_light(self, other: PreAlpha<C>) -> PreAlpha<C>

Lighten other if self is light, or darken other as if it’s burned if self is dark. The effect is increased if the components of self is further from 0.5.
source§

fn difference(self, other: PreAlpha<C>) -> PreAlpha<C>

Return the absolute difference between self and other. It’s basically abs(self - other), but regulated by the alpha component.
source§

fn exclusion(self, other: PreAlpha<C>) -> PreAlpha<C>

Similar to difference, but appears to result in a lower contrast. other is inverted if self is white, and preserved if self is black.
source§

impl<C> BlendWith for PreAlpha<C>
where C: Premultiply,

source§

type Color = C

The base color type of Self.
source§

fn blend_with<F>(self, other: PreAlpha<C>, blend_function: F) -> PreAlpha<C>

Blend self, as the source color, with destination, using blend_function. Anything that implements BlendFunction is acceptable, including functions and closures. Read more
source§

impl<C> Clone for PreAlpha<C>
where C: Clone + Premultiply, <C as Premultiply>::Scalar: Clone,

source§

fn clone(&self) -> PreAlpha<C>

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<C, T, const N: usize> Compose for PreAlpha<C>
where C: ArrayCast<Array = [T; N]> + Premultiply<Scalar = T>, T: Real + Zero + One + Arithmetics + Clamp + Clone,

source§

fn over(self, other: PreAlpha<C>) -> PreAlpha<C>

Place self over other. This is the good old common alpha composition equation.
source§

fn inside(self, other: PreAlpha<C>) -> PreAlpha<C>

Results in the parts of self that overlaps the visible parts of other.
source§

fn outside(self, other: PreAlpha<C>) -> PreAlpha<C>

Results in the parts of self that lies outside the visible parts of other.
source§

fn atop(self, other: PreAlpha<C>) -> PreAlpha<C>

Place self over only the visible parts of other.
source§

fn xor(self, other: PreAlpha<C>) -> PreAlpha<C>

Results in either self or other, where they do not overlap.
source§

fn plus(self, other: PreAlpha<C>) -> PreAlpha<C>

Add self and other. This uses the alpha component to regulate the effect, so it’s not just plain component wise addition.
source§

impl<C> Debug for PreAlpha<C>
where C: Debug + Premultiply, <C as Premultiply>::Scalar: Debug,

source§

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

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

impl<C> Default for PreAlpha<C>

source§

fn default() -> PreAlpha<C>

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

impl<C> DerefMut for PreAlpha<C>
where C: Premultiply,

source§

fn deref_mut(&mut self) -> &mut C

Mutably dereferences the value.
source§

impl<'de, C> Deserialize<'de> for PreAlpha<C>
where C: Premultiply + Deserialize<'de>, <C as Premultiply>::Scalar: Deserialize<'de>,

source§

fn deserialize<D>( deserializer: D, ) -> Result<PreAlpha<C>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<C> Div<f32> for PreAlpha<C>
where C: Premultiply<Scalar = f32> + Div<f32, Output = C>,

source§

type Output = PreAlpha<C>

The resulting type after applying the / operator.
source§

fn div(self, c: f32) -> <PreAlpha<C> as Div<f32>>::Output

Performs the / operation. Read more
source§

impl<C> Div<f64> for PreAlpha<C>
where C: Premultiply<Scalar = f64> + Div<f64, Output = C>,

source§

type Output = PreAlpha<C>

The resulting type after applying the / operator.
source§

fn div(self, c: f64) -> <PreAlpha<C> as Div<f64>>::Output

Performs the / operation. Read more
source§

impl<C> Div for PreAlpha<C>
where C: Premultiply + Div<Output = C>, <C as Premultiply>::Scalar: Div<Output = <C as Premultiply>::Scalar>,

source§

type Output = PreAlpha<C>

The resulting type after applying the / operator.
source§

fn div(self, other: PreAlpha<C>) -> <PreAlpha<C> as Div>::Output

Performs the / operation. Read more
source§

impl<C> DivAssign<f32> for PreAlpha<C>
where C: DivAssign<f32> + Premultiply<Scalar = f32>,

source§

fn div_assign(&mut self, c: f32)

Performs the /= operation. Read more
source§

impl<C> DivAssign<f64> for PreAlpha<C>
where C: DivAssign<f64> + Premultiply<Scalar = f64>,

source§

fn div_assign(&mut self, c: f64)

Performs the /= operation. Read more
source§

impl<C> DivAssign for PreAlpha<C>

source§

fn div_assign(&mut self, other: PreAlpha<C>)

Performs the /= operation. Read more
source§

impl<'a, C, const N: usize> From<&'a [<C as Premultiply>::Scalar; N]> for &'a PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn from(array: &'a [<C as Premultiply>::Scalar; N]) -> &'a PreAlpha<C>

Converts to this type from the input type.
source§

impl<'a, C, const N: usize> From<&'a PreAlpha<C>> for &'a [<C as Premultiply>::Scalar]
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn from(color: &'a PreAlpha<C>) -> &'a [<C as Premultiply>::Scalar]

Converts to this type from the input type.
source§

impl<'a, C, const N: usize> From<&'a mut [<C as Premultiply>::Scalar; N]> for &'a mut PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn from(array: &'a mut [<C as Premultiply>::Scalar; N]) -> &'a mut PreAlpha<C>

Converts to this type from the input type.
source§

impl<'a, C, const N: usize> From<&'a mut PreAlpha<C>> for &'a mut [<C as Premultiply>::Scalar]
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn from(color: &'a mut PreAlpha<C>) -> &'a mut [<C as Premultiply>::Scalar]

Converts to this type from the input type.
source§

impl<C, const N: usize> From<[<C as Premultiply>::Scalar; N]> for PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn from(array: [<C as Premultiply>::Scalar; N]) -> PreAlpha<C>

Converts to this type from the input type.
source§

impl<T, V, const N: usize> From<[PreAlpha<Cam16UcsJab<T>>; N]> for PreAlpha<Cam16UcsJab<V>>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>, Cam16UcsJab<T>: Premultiply<Scalar = T>, Cam16UcsJab<V>: Premultiply<Scalar = V>,

source§

fn from(colors: [PreAlpha<Cam16UcsJab<T>>; N]) -> PreAlpha<Cam16UcsJab<V>>

Converts to this type from the input type.
source§

impl<Wp, T, V, const N: usize> From<[PreAlpha<Lab<Wp, T>>; N]> for PreAlpha<Lab<Wp, V>>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>, Lab<Wp, T>: Premultiply<Scalar = T>, Lab<Wp, V>: Premultiply<Scalar = V>,

source§

fn from(colors: [PreAlpha<Lab<Wp, T>>; N]) -> PreAlpha<Lab<Wp, V>>

Converts to this type from the input type.
source§

impl<S, T, V, const N: usize> From<[PreAlpha<Luma<S, T>>; N]> for PreAlpha<Luma<S, V>>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>, Luma<S, T>: Premultiply<Scalar = T>, Luma<S, V>: Premultiply<Scalar = V>,

source§

fn from(colors: [PreAlpha<Luma<S, T>>; N]) -> PreAlpha<Luma<S, V>>

Converts to this type from the input type.
source§

impl<Wp, T, V, const N: usize> From<[PreAlpha<Luv<Wp, T>>; N]> for PreAlpha<Luv<Wp, V>>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>, Luv<Wp, T>: Premultiply<Scalar = T>, Luv<Wp, V>: Premultiply<Scalar = V>,

source§

fn from(colors: [PreAlpha<Luv<Wp, T>>; N]) -> PreAlpha<Luv<Wp, V>>

Converts to this type from the input type.
source§

impl<T, V, const N: usize> From<[PreAlpha<Oklab<T>>; N]> for PreAlpha<Oklab<V>>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>, Oklab<T>: Premultiply<Scalar = T>, Oklab<V>: Premultiply<Scalar = V>,

source§

fn from(colors: [PreAlpha<Oklab<T>>; N]) -> PreAlpha<Oklab<V>>

Converts to this type from the input type.
source§

impl<S, T, V, const N: usize> From<[PreAlpha<Rgb<S, T>>; N]> for PreAlpha<Rgb<S, V>>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>, Rgb<S, T>: Premultiply<Scalar = T>, Rgb<S, V>: Premultiply<Scalar = V>,

source§

fn from(colors: [PreAlpha<Rgb<S, T>>; N]) -> PreAlpha<Rgb<S, V>>

Converts to this type from the input type.
source§

impl<Wp, T, V, const N: usize> From<[PreAlpha<Xyz<Wp, T>>; N]> for PreAlpha<Xyz<Wp, V>>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>, Xyz<Wp, T>: Premultiply<Scalar = T>, Xyz<Wp, V>: Premultiply<Scalar = V>,

source§

fn from(colors: [PreAlpha<Xyz<Wp, T>>; N]) -> PreAlpha<Xyz<Wp, V>>

Converts to this type from the input type.
source§

impl<Wp, T, V, const N: usize> From<[PreAlpha<Yxy<Wp, T>>; N]> for PreAlpha<Yxy<Wp, V>>
where [T; N]: Default, V: FromScalarArray<N, Scalar = T>, Yxy<Wp, T>: Premultiply<Scalar = T>, Yxy<Wp, V>: Premultiply<Scalar = V>,

source§

fn from(colors: [PreAlpha<Yxy<Wp, T>>; N]) -> PreAlpha<Yxy<Wp, V>>

Converts to this type from the input type.
source§

impl<C> From<Alpha<C, <C as Premultiply>::Scalar>> for PreAlpha<C>
where C: Premultiply,

source§

fn from(color: Alpha<C, <C as Premultiply>::Scalar>) -> PreAlpha<C>

Converts to this type from the input type.
source§

impl<C, const N: usize> From<Box<[<C as Premultiply>::Scalar; N]>> for Box<PreAlpha<C>>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

fn from(array: Box<[<C as Premultiply>::Scalar; N]>) -> Box<PreAlpha<C>>

Converts to this type from the input type.
source§

impl<C> From<C> for PreAlpha<C>

source§

fn from(color: C) -> PreAlpha<C>

Converts to this type from the input type.
source§

impl<C> From<PreAlpha<C>> for Alpha<C, <C as Premultiply>::Scalar>
where C: Premultiply,

source§

fn from(color: PreAlpha<C>) -> Alpha<C, <C as Premultiply>::Scalar>

Converts to this type from the input type.
source§

impl<T> From<PreAlpha<Cam16UcsJab<T>>> for Cam16UcsJab<T>
where Cam16UcsJab<T>: Premultiply<Scalar = T>,

source§

fn from(premultiplied: PreAlpha<Cam16UcsJab<T>>) -> Cam16UcsJab<T>

Converts to this type from the input type.
source§

impl<Wp, T> From<PreAlpha<Lab<Wp, T>>> for Lab<Wp, T>
where Lab<Wp, T>: Premultiply<Scalar = T>,

source§

fn from(premultiplied: PreAlpha<Lab<Wp, T>>) -> Lab<Wp, T>

Converts to this type from the input type.
source§

impl<S, T> From<PreAlpha<Luma<S, T>>> for Luma<S, T>
where Luma<S, T>: Premultiply<Scalar = T>,

source§

fn from(premultiplied: PreAlpha<Luma<S, T>>) -> Luma<S, T>

Converts to this type from the input type.
source§

impl<Wp, T> From<PreAlpha<Luv<Wp, T>>> for Luv<Wp, T>
where Luv<Wp, T>: Premultiply<Scalar = T>,

source§

fn from(premultiplied: PreAlpha<Luv<Wp, T>>) -> Luv<Wp, T>

Converts to this type from the input type.
source§

impl<T> From<PreAlpha<Oklab<T>>> for Oklab<T>
where Oklab<T>: Premultiply<Scalar = T>,

source§

fn from(premultiplied: PreAlpha<Oklab<T>>) -> Oklab<T>

Converts to this type from the input type.
source§

impl<S, T> From<PreAlpha<Rgb<S, T>>> for Rgb<S, T>
where Rgb<S, T>: Premultiply<Scalar = T>,

source§

fn from(premultiplied: PreAlpha<Rgb<S, T>>) -> Rgb<S, T>

Converts to this type from the input type.
source§

impl<Wp, T> From<PreAlpha<Xyz<Wp, T>>> for Xyz<Wp, T>
where Xyz<Wp, T>: Premultiply<Scalar = T>,

source§

fn from(premultiplied: PreAlpha<Xyz<Wp, T>>) -> Xyz<Wp, T>

Converts to this type from the input type.
source§

impl<Wp, T> From<PreAlpha<Yxy<Wp, T>>> for Yxy<Wp, T>
where Yxy<Wp, T>: Premultiply<Scalar = T>,

source§

fn from(premultiplied: PreAlpha<Yxy<Wp, T>>) -> Yxy<Wp, T>

Converts to this type from the input type.
source§

impl<C, T> Mix for PreAlpha<C>
where C: Mix<Scalar = T> + Premultiply<Scalar = T>, T: Real + Zero + One + Clamp + Arithmetics + Clone,

source§

type Scalar = T

The type of the mixing factor.
source§

fn mix(self, other: PreAlpha<C>, factor: T) -> PreAlpha<C>

Mix the color with an other color, by factor. Read more
source§

impl<C, T> MixAssign for PreAlpha<C>
where C: MixAssign<Scalar = T> + Premultiply<Scalar = T>, T: Real + Zero + One + Clamp + Arithmetics + AddAssign + Clone,

source§

type Scalar = T

The type of the mixing factor.
source§

fn mix_assign(&mut self, other: PreAlpha<C>, factor: T)

Mix the color with an other color, by factor. Read more
source§

impl<C> Mul<f32> for PreAlpha<C>
where C: Premultiply<Scalar = f32> + Mul<f32, Output = C>,

source§

type Output = PreAlpha<C>

The resulting type after applying the * operator.
source§

fn mul(self, c: f32) -> <PreAlpha<C> as Mul<f32>>::Output

Performs the * operation. Read more
source§

impl<C> Mul<f64> for PreAlpha<C>
where C: Premultiply<Scalar = f64> + Mul<f64, Output = C>,

source§

type Output = PreAlpha<C>

The resulting type after applying the * operator.
source§

fn mul(self, c: f64) -> <PreAlpha<C> as Mul<f64>>::Output

Performs the * operation. Read more
source§

impl<C> Mul for PreAlpha<C>
where C: Premultiply + Mul<Output = C>, <C as Premultiply>::Scalar: Mul<Output = <C as Premultiply>::Scalar>,

source§

type Output = PreAlpha<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: PreAlpha<C>) -> <PreAlpha<C> as Mul>::Output

Performs the * operation. Read more
source§

impl<C> MulAssign<f32> for PreAlpha<C>
where C: MulAssign<f32> + Premultiply<Scalar = f32>,

source§

fn mul_assign(&mut self, c: f32)

Performs the *= operation. Read more
source§

impl<C> MulAssign<f64> for PreAlpha<C>
where C: MulAssign<f64> + Premultiply<Scalar = f64>,

source§

fn mul_assign(&mut self, c: f64)

Performs the *= operation. Read more
source§

impl<C> MulAssign for PreAlpha<C>

source§

fn mul_assign(&mut self, other: PreAlpha<C>)

Performs the *= operation. Read more
source§

impl<C> PartialEq for PreAlpha<C>

source§

fn eq(&self, other: &PreAlpha<C>) -> 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<C, T> RelativeEq for PreAlpha<C>
where C: RelativeEq<Epsilon = <T as AbsDiffEq>::Epsilon> + Premultiply<Scalar = T>, T: RelativeEq, <T as AbsDiffEq>::Epsilon: Clone,

source§

fn default_max_relative() -> <PreAlpha<C> as AbsDiffEq>::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &PreAlpha<C>, epsilon: <PreAlpha<C> as AbsDiffEq>::Epsilon, max_relative: <PreAlpha<C> as AbsDiffEq>::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
source§

impl<C> Serialize for PreAlpha<C>

source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<C> Sub<f32> for PreAlpha<C>
where C: Premultiply<Scalar = f32> + Sub<f32, Output = C>,

source§

type Output = PreAlpha<C>

The resulting type after applying the - operator.
source§

fn sub(self, c: f32) -> <PreAlpha<C> as Sub<f32>>::Output

Performs the - operation. Read more
source§

impl<C> Sub<f64> for PreAlpha<C>
where C: Premultiply<Scalar = f64> + Sub<f64, Output = C>,

source§

type Output = PreAlpha<C>

The resulting type after applying the - operator.
source§

fn sub(self, c: f64) -> <PreAlpha<C> as Sub<f64>>::Output

Performs the - operation. Read more
source§

impl<C> Sub for PreAlpha<C>
where C: Premultiply + Sub<Output = C>, <C as Premultiply>::Scalar: Sub<Output = <C as Premultiply>::Scalar>,

source§

type Output = PreAlpha<C>

The resulting type after applying the - operator.
source§

fn sub(self, other: PreAlpha<C>) -> <PreAlpha<C> as Sub>::Output

Performs the - operation. Read more
source§

impl<C> SubAssign<f32> for PreAlpha<C>
where C: SubAssign<f32> + Premultiply<Scalar = f32>,

source§

fn sub_assign(&mut self, c: f32)

Performs the -= operation. Read more
source§

impl<C> SubAssign<f64> for PreAlpha<C>
where C: SubAssign<f64> + Premultiply<Scalar = f64>,

source§

fn sub_assign(&mut self, c: f64)

Performs the -= operation. Read more
source§

impl<C> SubAssign for PreAlpha<C>

source§

fn sub_assign(&mut self, other: PreAlpha<C>)

Performs the -= operation. Read more
source§

impl<'a, C, const N: usize> TryFrom<&'a [<C as Premultiply>::Scalar]> for &'a PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

type Error = <&'a [<C as Premultiply>::Scalar; N] as TryFrom<&'a [<C as Premultiply>::Scalar]>>::Error

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

fn try_from( slice: &'a [<C as Premultiply>::Scalar], ) -> Result<&'a PreAlpha<C>, <&'a PreAlpha<C> as TryFrom<&'a [<C as Premultiply>::Scalar]>>::Error>

Performs the conversion.
source§

impl<'a, C, const N: usize> TryFrom<&'a mut [<C as Premultiply>::Scalar]> for &'a mut PreAlpha<C>
where C: Premultiply, PreAlpha<C>: ArrayCast<Array = [<C as Premultiply>::Scalar; N]>,

source§

type Error = <&'a mut [<C as Premultiply>::Scalar; N] as TryFrom<&'a mut [<C as Premultiply>::Scalar]>>::Error

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

fn try_from( slice: &'a mut [<C as Premultiply>::Scalar], ) -> Result<&'a mut PreAlpha<C>, <&'a mut PreAlpha<C> as TryFrom<&'a mut [<C as Premultiply>::Scalar]>>::Error>

Performs the conversion.
source§

impl<C, T> UlpsEq for PreAlpha<C>
where C: UlpsEq<Epsilon = <T as AbsDiffEq>::Epsilon> + Premultiply<Scalar = T>, T: UlpsEq, <T as AbsDiffEq>::Epsilon: Clone,

source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn ulps_eq( &self, other: &PreAlpha<C>, epsilon: <PreAlpha<C> as AbsDiffEq>::Epsilon, max_ulps: u32, ) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.
source§

impl<C> Deref for PreAlpha<C>
where C: Premultiply,

source§

type Target = C

The resulting type after dereferencing.
source§

fn deref(&self) -> &C

Dereferences the value.
source§

impl<C> Copy for PreAlpha<C>
where C: Copy + Premultiply, <C as Premultiply>::Scalar: Copy,

source§

impl<C> Eq for PreAlpha<C>
where C: Eq + Premultiply, <C as Premultiply>::Scalar: Eq,

Auto Trait Implementations§

§

impl<C> Freeze for PreAlpha<C>
where C: Freeze, <C as Premultiply>::Scalar: Freeze,

§

impl<C> RefUnwindSafe for PreAlpha<C>

§

impl<C> Send for PreAlpha<C>
where C: Send, <C as Premultiply>::Scalar: Send,

§

impl<C> Sync for PreAlpha<C>
where C: Sync, <C as Premultiply>::Scalar: Sync,

§

impl<C> Unpin for PreAlpha<C>
where C: Unpin, <C as Premultiply>::Scalar: Unpin,

§

impl<C> UnwindSafe for PreAlpha<C>

Blanket Implementations§

source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
source§

impl<T> Also for T

source§

fn also<F>(self, block: F) -> Self
where F: FnOnce(&mut Self),

Apply a function to this value and return the (possibly) modified value.
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, Res> Apply<Res> for T
where T: ?Sized,

source§

fn apply<F>(self, f: F) -> Res
where F: FnOnce(Self) -> Res, Self: Sized,

Apply a function which takes the parameter by value.
source§

fn apply_ref<F>(&self, f: F) -> Res
where F: FnOnce(&Self) -> Res,

Apply a function which takes the parameter by reference.
source§

fn apply_mut<F>(&mut self, f: F) -> Res
where F: FnOnce(&mut Self) -> Res,

Apply a function which takes the parameter by mutable reference.
source§

impl<T, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
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, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromAngle<T> for T

source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> IntoAngle<U> for T
where U: FromAngle<T>,

source§

fn into_angle(self) -> U

Performs a conversion into T.
source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
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> IntoStimulus<T> for T

source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
source§

impl<T> NoneValue for T
where T: Default,

source§

type NoneType = T

source§

fn null_value() -> T

The none-equivalent value.
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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToHex for T
where T: AsRef<[u8]>,

source§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
source§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
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, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. 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.
source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

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

source§

impl<T> MaybeSendSync for T

source§

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