MCPcopy Index your code
hub / github.com/clips/pattern / mask

Function mask

pattern/canvas.js:3206–3218  ·  view source on GitHub ↗
(img1, img2, dx, dy, alpha)

Source from the content-addressed store, hash-verified

3204}
3205
3206function mask(img1, img2, dx, dy, alpha) {
3207 /* Applies the second image as an alpha mask to the first image.
3208 * The second image must be a grayscale image, where the black areas
3209 * make the first image transparent (e.g. punch holes in it).
3210 * - dx: horizontal offset (in pixels) of the blend layer.
3211 * - dy: vertical offset (in pixels) of the blend layer.
3212 */
3213 alpha = (alpha || alpha == 0)? alpha : 1;
3214 return composite(img1, img2, dx, dy, function(p1, p2) {
3215 p1[3] = p1[3] * p2[0]/255 * p2[3]/255 * alpha;
3216 return p1;
3217 });
3218}
3219
3220var ADD = "add"; // Pixels are added.
3221var SUBTRACT = "subtract"; // Pixels are subtracted.

Callers

nothing calls this directly

Calls 1

compositeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…