[][src]Enum printpdf::types::plugins::graphics::extgstate::SeperableBlendMode

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

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

This example is not tested
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.

This example is not tested
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.

This example is not tested
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.

This example is not tested
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.

This example is not tested
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

impl Clone for SeperableBlendMode[src]

impl Copy for SeperableBlendMode[src]

impl Debug for SeperableBlendMode[src]

impl PartialEq<SeperableBlendMode> for SeperableBlendMode[src]

impl StructuralPartialEq for SeperableBlendMode[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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.