BlendMode Enum

How the color of a paint is mixed with the color of the pixels it is drawn on, before it is composited: the blend modes of image editors and of CSS.

public enum BlendMode

Remarks

With the colors of the paint s and of the pixel d as fractions of one, a blend mode gives a color B(s, d). The paint takes the color (1 - ad) s + ad B(s, d), where ad is the alpha of the pixel: on a transparent pixel the paint keeps its color, and on an opaque one it has the blended color. It is then composited by the CompositeMode of the brush, with its own alpha, as any paint is. The formulas are those of "Compositing and Blending Level 1" of the W3C.

The blended color is computed in double precision from the sample values, and rounded to the nearest sample value, ties upward, before the paint is composited with the exact arithmetic of the operators. Only additions, multiplications, divisions and square roots are involved: the pixels are the same on every platform. The modes from BlendMode.Multiply to BlendMode.Exclusion mix each color channel on its own; the last four take a color as a whole, with the luminosity 0.3 R + 0.59 G + 0.11 B. On a grayscale frame the paint and the pixels are gray levels, which these four modes treat as colors without saturation.

Fields

NameValueDescription
Normal0The color of the paint, as it is. This is the default.
Multiply1The product of the two colors, s d: always darker, as two slides held together. White changes nothing.
Screen2The inverse of the product of the inverses, s + d - s d: always lighter, as two projectors on one screen. Black changes nothing.
Overlay3BlendMode.Multiply where the pixel is dark and BlendMode.Screen where it is light: BlendMode.HardLight with the two colors exchanged.
Darken4The darker of the two colors, channel by channel.
Lighten5The lighter of the two colors, channel by channel.
ColorDodge6The pixel brightened to reflect the paint: min(1, d / (1 - s)). Black changes nothing.
ColorBurn7The pixel darkened to reflect the paint: 1 - min(1, (1 - d) / s). White changes nothing.
HardLight8BlendMode.Multiply where the paint is dark and BlendMode.Screen where it is light: a harsh spotlight.
SoftLight9The pixel darkened where the paint is dark and lightened where it is light, without reaching black or white: a diffused spotlight.
Difference10The difference of the two colors, |d - s|. White inverts the pixel; black changes nothing.
Exclusion11s + d - 2 s d: like BlendMode.Difference, with less contrast.
Hue12The hue of the paint, with the saturation and the luminosity of the pixel.
Saturation13The saturation of the paint, with the hue and the luminosity of the pixel.
Color14The hue and the saturation of the paint, with the luminosity of the pixel: tints a gray image.
Luminosity15The luminosity of the paint, with the hue and the saturation of the pixel.