[][src]Struct nannou::color::blend::PreAlpha

#[repr(C)]
pub struct PreAlpha<C, T> where
    T: Float
{ pub color: C, pub alpha: T, }

Premultiplied alpha wrapper.

Premultiplied colors are commonly used in composition algorithms to simplify the calculations. It may also be preferred when interpolating between colors, which is one of the reasons why it's offered as a separate type. The other reason is to make it easier to avoid unnecessary computations in composition chains.

use palette::{Blend, LinSrgb, LinSrgba};
use palette::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 = LinSrgb::from_premultiplied(a.screen(b).overlay(c));

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

Fields

color: C

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

alpha: T

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

Trait Implementations

impl<C, T, P> AsRef<P> for PreAlpha<C, T> where
    C: Pixel<T>,
    P: RawPixel<T> + ?Sized,
    T: Float
[src]

impl<C> Mix for PreAlpha<C, <C as Mix>::Scalar> where
    C: Mix
[src]

type Scalar = <C as Mix>::Scalar

The type of the mixing factor.

impl<T, C> Add<T> for PreAlpha<C, T> where
    C: Add<T>,
    T: Float
[src]

type Output = PreAlpha<<C as Add<T>>::Output, T>

The resulting type after applying the + operator.

impl<C, T> Add<PreAlpha<C, T>> for PreAlpha<C, T> where
    C: Add<C>,
    T: Float
[src]

type Output = PreAlpha<<C as Add<C>>::Output, T>

The resulting type after applying the + operator.

impl<C, T> DerefMut for PreAlpha<C, T> where
    T: Float
[src]

impl<C, T> PartialEq<PreAlpha<C, T>> for PreAlpha<C, T> where
    C: PartialEq<C>,
    T: PartialEq<T> + Float
[src]

impl<C, T> ComponentWise for PreAlpha<C, T> where
    C: ComponentWise<Scalar = T>,
    T: Float
[src]

type Scalar = T

The scalar type for color components.

impl<T, C> Mul<T> for PreAlpha<C, T> where
    C: Mul<T>,
    T: Float
[src]

type Output = PreAlpha<<C as Mul<T>>::Output, T>

The resulting type after applying the * operator.

impl<C, T> Mul<PreAlpha<C, T>> for PreAlpha<C, T> where
    C: Mul<C>,
    T: Float
[src]

type Output = PreAlpha<<C as Mul<C>>::Output, T>

The resulting type after applying the * operator.

impl<C, T> Sub<PreAlpha<C, T>> for PreAlpha<C, T> where
    C: Sub<C>,
    T: Float
[src]

type Output = PreAlpha<<C as Sub<C>>::Output, T>

The resulting type after applying the - operator.

impl<T, C> Sub<T> for PreAlpha<C, T> where
    C: Sub<T>,
    T: Float
[src]

type Output = PreAlpha<<C as Sub<T>>::Output, T>

The resulting type after applying the - operator.

impl<C, T> Deref for PreAlpha<C, T> where
    T: Float
[src]

type Target = C

The resulting type after dereferencing.

impl<T, C> Pixel<T> for PreAlpha<C, T> where
    C: Pixel<T>,
    T: Float
[src]

impl<C, T> Debug for PreAlpha<C, T> where
    C: Debug,
    T: Debug + Float
[src]

impl<C, T> Div<PreAlpha<C, T>> for PreAlpha<C, T> where
    C: Div<C>,
    T: Float
[src]

type Output = PreAlpha<<C as Div<C>>::Output, T>

The resulting type after applying the / operator.

impl<T, C> Div<T> for PreAlpha<C, T> where
    C: Div<T>,
    T: Float
[src]

type Output = PreAlpha<<C as Div<T>>::Output, T>

The resulting type after applying the / operator.

impl<C, T> Default for PreAlpha<C, T> where
    C: Default,
    T: Float
[src]

impl<C, T> Clone for PreAlpha<C, T> where
    C: Clone,
    T: Clone + Float
[src]

impl<C, T> Copy for PreAlpha<C, T> where
    C: Copy,
    T: Copy + Float
[src]

impl<C, T> ApproxEq for PreAlpha<C, T> where
    C: ApproxEq<Epsilon = <T as ApproxEq>::Epsilon>,
    T: ApproxEq + Float,
    <T as ApproxEq>::Epsilon: Copy
[src]

type Epsilon = <T as ApproxEq>::Epsilon

Used for specifying relative comparisons.

impl<C, T> From<PreAlpha<C, T>> for Alpha<C, T> where
    C: ComponentWise<Scalar = T>,
    T: Float
[src]

impl<C, T> From<Alpha<C, T>> for PreAlpha<C, T> where
    C: ComponentWise<Scalar = T>,
    T: Float
[src]

impl<C, T> Blend for PreAlpha<C, T> where
    C: Blend<Color = C> + ComponentWise<Scalar = T>,
    T: Float
[src]

type Color = C

The core color type. Typically Self for color types without alpha.

impl<C, T, P> AsMut<P> for PreAlpha<C, T> where
    C: Pixel<T>,
    P: RawPixel<T> + ?Sized,
    T: Float
[src]

Auto Trait Implementations

impl<C, T> Send for PreAlpha<C, T> where
    C: Send,
    T: Send

impl<C, T> Sync for PreAlpha<C, T> where
    C: Sync,
    T: Sync

impl<C, T> Unpin for PreAlpha<C, T> where
    C: Unpin,
    T: Unpin

impl<C, T> UnwindSafe for PreAlpha<C, T> where
    C: UnwindSafe,
    T: UnwindSafe

impl<C, T> RefUnwindSafe for PreAlpha<C, T> where
    C: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Style for T where
    T: Any + Debug + PartialEq<T>, 
[src]

impl<T> DeviceOwned for T where
    T: Deref,
    <T as Deref>::Target: DeviceOwned
[src]

impl<T> Content for T[src]

impl<T> SafeBorrow<T> for T[src]

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

impl<T> SetParameter for T

impl<T> SetParameter for T

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