Trait nannou::color::Blend [−][src]
pub trait Blend where
<Self::Color as ComponentWise>::Scalar: Float, { type Color: Blend + ComponentWise;}Show methods
pub fn into_premultiplied(
self
) -> PreAlpha<Self::Color, <Self::Color as ComponentWise>::Scalar>; pub fn from_premultiplied(
color: PreAlpha<Self::Color, <Self::Color as ComponentWise>::Scalar>
) -> Self; pub fn blend<F>(self, destination: Self, blend_function: F) -> Self
where
F: BlendFunction<Self::Color>, { ... } pub fn over(self, other: Self) -> Self { ... } pub fn inside(self, other: Self) -> Self { ... } pub fn outside(self, other: Self) -> Self { ... } pub fn atop(self, other: Self) -> Self { ... } pub fn xor(self, other: Self) -> Self { ... } pub fn plus(self, other: Self) -> Self { ... } pub fn multiply(self, other: Self) -> Self { ... } pub fn screen(self, other: Self) -> Self { ... } pub fn overlay(self, other: Self) -> Self { ... } pub fn darken(self, other: Self) -> Self { ... } pub fn lighten(self, other: Self) -> Self { ... } pub fn dodge(self, other: Self) -> Self { ... } pub fn burn(self, other: Self) -> Self { ... } pub fn hard_light(self, other: Self) -> Self { ... } pub fn soft_light(self, other: Self) -> Self { ... } pub fn difference(self, other: Self) -> Self { ... } pub fn exclusion(self, other: Self) -> Self { ... }
A trait for colors that can be blended together.
Blending can either be performed through the predefined blend modes, or a custom blend functions.
Note: The default implementations of the blend modes are meant for color components in the range [0.0, 1.0] and may otherwise produce strange results.
Associated Types
type Color: Blend + ComponentWise
[src]
The core color type. Typically Self
for color types without alpha.
Required methods
pub fn into_premultiplied(
self
) -> PreAlpha<Self::Color, <Self::Color as ComponentWise>::Scalar>
[src]
self
) -> PreAlpha<Self::Color, <Self::Color as ComponentWise>::Scalar>
Convert the color to premultiplied alpha.
pub fn from_premultiplied(
color: PreAlpha<Self::Color, <Self::Color as ComponentWise>::Scalar>
) -> Self
[src]
color: PreAlpha<Self::Color, <Self::Color as ComponentWise>::Scalar>
) -> Self
Convert the color from premultiplied alpha.
Provided methods
pub fn blend<F>(self, destination: Self, blend_function: F) -> Self where
F: BlendFunction<Self::Color>,
[src]
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.
use palette::{LinSrgb, LinSrgba, Blend}; use palette::blend::PreAlpha; type PreRgba = PreAlpha<LinSrgb<f32>, f32>; fn blend_mode(a: PreRgba, b: PreRgba) -> PreRgba { PreAlpha { color: LinSrgb::new(a.red * b.green, a.green * b.blue, a.blue * b.red), alpha: a.alpha * b.alpha, } } let a = LinSrgba::new(0.2, 0.5, 0.1, 0.8); let b = LinSrgba::new(0.6, 0.3, 0.5, 0.1); let c = a.blend(b, blend_mode);
pub fn over(self, other: Self) -> Self
[src]
Place self
over other
. This is the good old common alpha
composition equation.
pub fn inside(self, other: Self) -> Self
[src]
Results in the parts of self
that overlaps the visible parts of
other
.
pub fn outside(self, other: Self) -> Self
[src]
Results in the parts of self
that lies outside the visible parts of
other
.
pub fn atop(self, other: Self) -> Self
[src]
Place self
over only the visible parts of other
.
pub fn xor(self, other: Self) -> Self
[src]
Results in either self
or other
, where they do not overlap.
pub fn plus(self, other: Self) -> Self
[src]
Add self
and other
. This uses the alpha component to regulate the
effect, so it’s not just plain component wise addition.
pub fn multiply(self, other: Self) -> Self
[src]
Multiply self
with other
. This uses the alpha component to regulate
the effect, so it’s not just plain component wise multiplication.
pub fn screen(self, other: Self) -> Self
[src]
Make a color which is at least as light as self
or other
.
pub fn overlay(self, other: Self) -> Self
[src]
Multiply self
or other
if other is dark, or screen them if other
is light. This results in an S curve.
pub fn darken(self, other: Self) -> Self
[src]
Return the darkest parts of self
and other
.
pub fn lighten(self, other: Self) -> Self
[src]
Return the lightest parts of self
and other
.
pub fn dodge(self, other: Self) -> Self
[src]
Lighten other
to reflect self
. Results in other
if self
is
black.
pub fn burn(self, other: Self) -> Self
[src]
Darken other
to reflect self
. Results in other
if self
is
white.
pub fn hard_light(self, other: Self) -> Self
[src]
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
.
pub fn soft_light(self, other: Self) -> Self
[src]
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.
pub fn difference(self, other: Self) -> Self
[src]
Return the absolute difference between self
and other
. It’s
basically abs(self - other)
, but regulated by the alpha component.
pub fn exclusion(self, other: Self) -> Self
[src]
Similar to difference
, but appears to result in a lower contrast.
other
is inverted if self
is white, and preserved if self
is
black.
Implementors
impl<C, T> Blend for PreAlpha<C, T> where
C: Blend<Color = C> + ComponentWise<Scalar = T>,
T: Float,
[src]
C: Blend<Color = C> + ComponentWise<Scalar = T>,
T: Float,
type Color = C
pub fn into_premultiplied(self) -> PreAlpha<C, T>
[src]
pub fn from_premultiplied(color: PreAlpha<C, T>) -> PreAlpha<C, T>
[src]
impl<C, T> Blend for Alpha<C, T> where
C: Blend,
T: Float,
<C as Blend>::Color: ComponentWise,
Alpha<C, T>: Into<Alpha<<C as Blend>::Color, T>>,
Alpha<C, T>: From<Alpha<<C as Blend>::Color, T>>,
<<C as Blend>::Color as ComponentWise>::Scalar == T,
[src]
C: Blend,
T: Float,
<C as Blend>::Color: ComponentWise,
Alpha<C, T>: Into<Alpha<<C as Blend>::Color, T>>,
Alpha<C, T>: From<Alpha<<C as Blend>::Color, T>>,
<<C as Blend>::Color as ComponentWise>::Scalar == T,
type Color = <C as Blend>::Color
pub fn into_premultiplied(self) -> PreAlpha<<C as Blend>::Color, T>
[src]
pub fn from_premultiplied(
color: PreAlpha<<C as Blend>::Color, T>
) -> Alpha<C, T>
[src]
color: PreAlpha<<C as Blend>::Color, T>
) -> Alpha<C, T>
impl<S, T> Blend for Rgb<S, T> where
S: RgbStandard<TransferFn = LinearFn>,
T: Component + Float,
[src]
S: RgbStandard<TransferFn = LinearFn>,
T: Component + Float,
type Color = Rgb<S, T>
pub fn into_premultiplied(self) -> PreAlpha<Rgb<S, T>, T>
[src]
pub fn from_premultiplied(color: PreAlpha<Rgb<S, T>, T>) -> Rgb<S, T>
[src]
impl<S, T> Blend for Luma<S, T> where
S: LumaStandard<TransferFn = LinearFn>,
T: Component + Float,
[src]
S: LumaStandard<TransferFn = LinearFn>,
T: Component + Float,