(img1, img2, dx, dy, alpha)
| 3204 | } |
| 3205 | |
| 3206 | function 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 | |
| 3220 | var ADD = "add"; // Pixels are added. |
| 3221 | var SUBTRACT = "subtract"; // Pixels are subtracted. |
nothing calls this directly
no test coverage detected
searching dependent graphs…