This reference is for Processing 2.0+. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name

blendMode()

Examples
size(100, 100);
background(0);
blendMode(ADD);
stroke(102);
strokeWeight(30);
line(25, 25, 75, 75);
line(75, 25, 25, 75);

size(100, 100, P2D);
blendMode(MULTIPLY);
stroke(51);
strokeWeight(30);
line(25, 25, 75, 75);
line(75, 25, 25, 75);
Description Blends the pixels in the display window according to the defined mode. There is a choice of the following modes to blend the source pixels (A) with the ones of pixels already in the display window (B):

BLEND - linear interpolation of colours: C = A*factor + B. This is the default blending mode.

ADD - additive blending with white clip: C = min(A*factor + B, 255)

SUBTRACT - subtractive blending with black clip: C = max(B - A*factor, 0)

DARKEST - only the darkest colour succeeds: C = min(A*factor, B)

LIGHTEST - only the lightest colour succeeds: C = max(A*factor, B)

DIFFERENCE - subtract colors from underlying image.

EXCLUSION - similar to DIFFERENCE, but less extreme.

MULTIPLY - multiply the colors, result will always be darker.

SCREEN - opposite multiply, uses inverse values of the colors.

REPLACE - the pixels entirely replace the others and don't utilize alpha (transparency) values

For Processing 2.0, we recommend using blendMode() and not the previous blend() function. However, unlike blend(), the blendMode() function does not support the following: HARD_LIGHT, SOFT_LIGHT, OVERLAY, DODGE, BURN. On older hardware, the LIGHTEST, DARKEST, and DIFFERENCE modes might not be available as well.
Syntax
blendMode(mode)
Parameters
mode int: the blending mode to use
Returnsvoid
Updated on May 19, 2014 05:30:01pm PDT

Creative Commons License