pub enum SeperableBlendMode {
    Normal,
    Multiply,
    Screen,
    Overlay,
    Darken,
    Lighten,
    ColorDodge,
    ColorBurn,
    HardLight,
    SoftLight,
    Difference,
    Exclusion,
}
Expand description

PDF Reference 1.7, Page 520, Table 7.2 Blending modes for objects In the following reference, each function gets one new color (the thing to paint on top) and an old color (the color that was already present before the object gets painted)

The function simply notes the formula that has to be applied to (color_new, color_old) in order to get the desired effect. You have to run each formula once for each color channel.

Variants§

§

Normal

Selects the source color, ignoring the old color. Default mode.

color_new

§

Multiply

Multiplies the old color and source color values Note that these values have to be in the range [0.0 to 1.0] to work. The result color is always at least as dark as either of the two constituent colors. Multiplying any color with black produces black; multiplying with white leaves the original color unchanged.Painting successive overlapping objects with a color other than black or white produces progressively darker colors.

color_old * color_new

§

Screen

Multiplies the complements of the old color and new color values, then complements the result The result color is always at least as light as either of the two constituent colors. Screening any color with white produces white; screening with black leaves the original color unchanged. The effect is similar to projecting multiple photographic slides simultaneously onto a single screen.

color_old + color_new - (color_old * color_new)

§

Overlay

Multiplies or screens the colors, depending on the old color value. Source colors overlay the old color while preserving its highlights and shadows. The old color is not replaced but is mixed with the source color to reflect the lightness or darkness of the old color.

TLDR: It’s the inverse of HardLight

if color_old <= 0.5 {
    Multiply(color_new, 2 x color_old)
} else {
    Screen(color_new, 2 * color_old - 1)
}
§

Darken

Selects the darker one of two colors.The old color is replaced with the new color where the new color is darker; otherwise, it is left unchanged.

min(color_old, color_new)

§

Lighten

Selects the lighter one of two colors. The old color is replaced with the new color where the new color is lighter; otherwise, it is left unchanged.

max(color_old, color_new)

§

ColorDodge

Brightens the backdrop color to reflect the source color. Painting with black produces no changes.

if color_new < 1 {
    min(1, color_old / (1 - color_new))
} else {
    1
}
§

ColorBurn

Darkens the backdrop color to reflect the source color. Painting with white produces no change.

if color_new > 0 {
    1 - min(1, (1 - color_old) / color_new)
} else {
    0
}
§

HardLight

Multiplies or screens the colors, depending on the source color value. The effect is similar to shining a harsh spotlight on the old color. It’s the inverse of Screen.

if color_new <= 0.5 {
    Multiply(color_old, 2 x color_new)
} else {
    Screen(color_old, 2 * color_new - 1)
}
§

SoftLight

Darkens or lightens the colors, depending on the source color value. The effect is similar to shining a diffused spotlight on the backdrop.

if color_new <= 0.5 {
    color_old - ((1 - (2 * color_new)) * color_old * (1 - color_old))
} else {
    let mut dx_factor = color_old.sqrt();
    if color_old <= 0.25 {
        dx_factor = (((16 * color_old - 12) * color_old) + 4) * color_old;
    }
    color_old + ((2 * color_new) - 1) * (dx_factor - color_old)
}
§

Difference

Subtracts the darker of the two constituent colors from the lighter color Painting with white inverts the backdrop color; painting with black produces no change.

abs(color_old - color_new)

§

Exclusion

Produces an effect similar to that of the Difference mode but lower in contrast. Painting with white inverts the backdrop color; painting with black produces no change.

color_old + color_new - (2 * color_old * color_new)

Trait Implementations§

source§

impl Clone for SeperableBlendMode

source§

fn clone(&self) -> SeperableBlendMode

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 Debug for SeperableBlendMode

source§

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

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

impl PartialEq for SeperableBlendMode

source§

fn eq(&self, other: &SeperableBlendMode) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for SeperableBlendMode

source§

impl StructuralPartialEq for SeperableBlendMode

Auto Trait Implementations§

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> Finish for T

source§

fn finish(self)

Does nothing but move self, equivalent to drop.
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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.