Struct palette::blend::PreAlpha

source ·
#[repr(C)]
pub struct PreAlpha<C: Premultiply> { pub color: C, pub alpha: C::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::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::Scalar) -> Self

Alpha mask color with alpha.

source

pub fn new_opaque(color: C) -> Self
where C::Scalar: Stimulus,

Create an opaque alpha masked color.

source

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

Alpha unmask the color.

Trait Implementations§

source§

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

source§

type Epsilon = <T as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> Self::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: Self::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: Add<f32, Output = C> + Premultiply<Scalar = f32>,

source§

type Output = PreAlpha<C>

The resulting type after applying the + operator.
source§

fn add(self, c: f32) -> Self::Output

Performs the + operation. Read more
source§

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

source§

type Output = PreAlpha<C>

The resulting type after applying the + operator.
source§

fn add(self, c: f64) -> Self::Output

Performs the + operation. Read more
source§

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

source§

type Output = PreAlpha<C>

The resulting type after applying the + operator.
source§

fn add(self, other: PreAlpha<C>) -> Self::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::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: Premultiply, const N: usize> AsMut<[<C as Premultiply>::Scalar]> for PreAlpha<C>
where PreAlpha<C>: ArrayCast<Array = [C::Scalar; N]>,

source§

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

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

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

source§

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

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

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

source§

fn as_mut(&mut self) -> &mut PreAlpha<C>

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

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

source§

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

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

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

source§

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

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

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

source§

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

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::Mask: LazySelect<T>,

source§

fn multiply(self, other: Self) -> Self

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: Self) -> Self

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

fn overlay(self, other: Self) -> Self

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: Self) -> Self

Return the darkest parts of self and other.
source§

fn lighten(self, other: Self) -> Self

Return the lightest parts of self and other.
source§

fn dodge(self, other: Self) -> Self

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

fn burn(self, other: Self) -> Self

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

fn hard_light(self, other: Self) -> Self

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: Self) -> Self

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: Self) -> Self

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: Self) -> Self

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: Self, blend_function: F) -> Self
where F: BlendFunction<Self::Color>,

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 + Premultiply> Clone for PreAlpha<C>
where C::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: Self) -> Self

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

fn inside(self, other: Self) -> Self

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

fn outside(self, other: Self) -> Self

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

fn atop(self, other: Self) -> Self

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

fn xor(self, other: Self) -> Self

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

fn plus(self, other: Self) -> Self

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 + Premultiply> Debug for PreAlpha<C>
where C::Scalar: Debug,

source§

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

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: Premultiply> Deref for PreAlpha<C>

source§

type Target = C

The resulting type after dereferencing.
source§

fn deref(&self) -> &C

Dereferences the value.
source§

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

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::Scalar: Deserialize<'de>,

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::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: Div<f32, Output = C> + Premultiply<Scalar = f32>,

source§

type Output = PreAlpha<C>

The resulting type after applying the / operator.
source§

fn div(self, c: f32) -> Self::Output

Performs the / operation. Read more
source§

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

source§

type Output = PreAlpha<C>

The resulting type after applying the / operator.
source§

fn div(self, c: f64) -> Self::Output

Performs the / operation. Read more
source§

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

source§

type Output = PreAlpha<C>

The resulting type after applying the / operator.
source§

fn div(self, other: PreAlpha<C>) -> Self::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: Premultiply, const N: usize> From<&'a [<C as Premultiply>::Scalar; N]> for &'a PreAlpha<C>
where PreAlpha<C>: ArrayCast<Array = [C::Scalar; N]>,

source§

fn from(array: &'a [C::Scalar; N]) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: &'a PreAlpha<C>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: &'a PreAlpha<C>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(array: &'a mut [C::Scalar; N]) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: &'a mut PreAlpha<C>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: &'a mut PreAlpha<C>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(array: [C::Scalar; N]) -> Self

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]) -> Self

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]) -> Self

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]) -> Self

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]) -> Self

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]) -> Self

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]) -> Self

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]) -> Self

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]) -> Self

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::Scalar>) -> Self

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

fn from(color: C) -> Self

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

fn from(premultiplied: PreAlpha<Self>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: PreAlpha<Cam16UcsJab<V>>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(premultiplied: PreAlpha<Self>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: PreAlpha<Lab<Wp, V>>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(premultiplied: PreAlpha<Self>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: PreAlpha<Luma<S, V>>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(premultiplied: PreAlpha<Self>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: PreAlpha<Luv<Wp, V>>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(premultiplied: PreAlpha<Self>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: PreAlpha<Oklab<V>>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(premultiplied: PreAlpha<Self>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: PreAlpha<Rgb<S, V>>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(premultiplied: PreAlpha<Self>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: PreAlpha<Xyz<Wp, V>>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(premultiplied: PreAlpha<Self>) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(color: PreAlpha<Yxy<Wp, V>>) -> Self

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: Self, factor: T) -> Self

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: Self, factor: T)

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

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

source§

type Output = PreAlpha<C>

The resulting type after applying the * operator.
source§

fn mul(self, c: f32) -> Self::Output

Performs the * operation. Read more
source§

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

source§

type Output = PreAlpha<C>

The resulting type after applying the * operator.
source§

fn mul(self, c: f64) -> Self::Output

Performs the * operation. Read more
source§

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

source§

type Output = PreAlpha<C>

The resulting type after applying the * operator.
source§

fn mul(self, other: PreAlpha<C>) -> Self::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: &Self) -> 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::Epsilon> + Premultiply<Scalar = T>, T: RelativeEq, T::Epsilon: Clone,

source§

fn default_max_relative() -> Self::Epsilon

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

fn relative_eq( &self, other: &PreAlpha<C>, epsilon: Self::Epsilon, max_relative: Self::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::Ok, S::Error>
where S: Serializer,

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

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

source§

type Output = PreAlpha<C>

The resulting type after applying the - operator.
source§

fn sub(self, c: f32) -> Self::Output

Performs the - operation. Read more
source§

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

source§

type Output = PreAlpha<C>

The resulting type after applying the - operator.
source§

fn sub(self, c: f64) -> Self::Output

Performs the - operation. Read more
source§

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

source§

type Output = PreAlpha<C>

The resulting type after applying the - operator.
source§

fn sub(self, other: PreAlpha<C>) -> Self::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: Premultiply, const N: usize> TryFrom<&'a [<C as Premultiply>::Scalar]> for &'a PreAlpha<C>
where PreAlpha<C>: ArrayCast<Array = [C::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::Scalar]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a, C: Premultiply, const N: usize> TryFrom<&'a mut [<C as Premultiply>::Scalar]> for &'a mut PreAlpha<C>
where PreAlpha<C>: ArrayCast<Array = [C::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::Scalar]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<C, T> UlpsEq for PreAlpha<C>
where C: UlpsEq<Epsilon = T::Epsilon> + Premultiply<Scalar = T>, T: UlpsEq, T::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: Self::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: Copy + Premultiply> Copy for PreAlpha<C>
where C::Scalar: Copy,

source§

impl<C> Eq for PreAlpha<C>
where C: Eq + Premultiply, C::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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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> 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, 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> 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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,