Enum printpdf::SeperableBlendMode
source · 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
impl Clone for SeperableBlendMode
source§fn clone(&self) -> SeperableBlendMode
fn clone(&self) -> SeperableBlendMode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SeperableBlendMode
impl Debug for SeperableBlendMode
source§impl PartialEq for SeperableBlendMode
impl PartialEq for SeperableBlendMode
source§fn eq(&self, other: &SeperableBlendMode) -> bool
fn eq(&self, other: &SeperableBlendMode) -> bool
self
and other
values to be equal, and is used
by ==
.