This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.
Name | blend() |
||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Examples | background(loadImage("rockies.jpg")); PImage img = loadImage("bricks.jpg"); image(img, 0, 0); blend(img, 0, 0, 33, 100, 67, 0, 33, 100, ADD); background(loadImage("rockies.jpg")); PImage img = loadImage("bricks.jpg"); image(img, 0, 0); blend(img, 0, 0, 33, 100, 67, 0, 33, 100, SUBTRACT); background(loadImage("rockies.jpg")); PImage img = loadImage("bricks.jpg"); image(img, 0, 0); blend(img, 0, 0, 33, 100, 67, 0, 33, 100, DARKEST); background(loadImage("rockies.jpg")); PImage img = loadImage("bricks.jpg"); image(img, 0, 0); blend(img, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST); | ||||||||||||||||||||
Description |
Blends a region of pixels from one image into another (or in itself again) with full alpha channel support. There is a choice of the following modes to blend the source pixels (A) with the ones of pixels in the destination image (B): BLEND - linear interpolation of colors: C = A*factor + B 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 color succeeds: C = min(A*factor, B) LIGHTEST - only the lightest color 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. OVERLAY - A mix of MULTIPLY and SCREEN. Multiplies dark values, and screens light values. HARD_LIGHT - SCREEN when greater than 50% gray, MULTIPLY when lower. SOFT_LIGHT - Mix of DARKEST and LIGHTEST. Works like OVERLAY, but not as harsh. DODGE - Lightens light tones and increases contrast, ignores darks. Called "Color Dodge" in Illustrator and Photoshop. BURN - Darker areas are applied, increasing contrast, ignores lights. Called "Color Burn" in Illustrator and Photoshop. All modes use the alpha information (highest byte) of source image pixels as the blending factor. If the source and destination regions are different sizes, the image will be automatically resized to match the destination size. If the src parameter is not used, the display window is used as the source image. As of release 0149, this function ignores imageMode(). |
||||||||||||||||||||
Syntax | blend(sx, sy, sw, sh, dx, dy, dw, dh, mode) blend(src, sx, sy, sw, sh, dx, dy, dw, dh, mode) | ||||||||||||||||||||
Parameters |
| ||||||||||||||||||||
Returns | void | ||||||||||||||||||||
Related | alpha() copy() |
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.