Processing.js

Alphamask

This code was updated from the Java source to work with Processing.js asynchronous image loading. Not sure image masks were ever implemented in Processing.js.-F1LT3R

Loads a "mask" for an image to specify the transparency in different parts of the image. The two images are blended together using the mask() method of PImage. Created 29 April 2003.

Original Processing.org Example: Alphamask

// All Examples Written by Casey Reas and Ben Fry
// unless otherwise stated.

/* @pjs preload="data/test.jpg,data/mask.jpg"; */

PImage img;
PImage maskImg;

void setup() 
{
  size(200,200);
  img = loadImage("test.jpg");
  maskImg = loadImage("mask.jpg");
  img.mask(maskImg);
}

void draw() 
{
  background((mouseX+mouseY)/1.5);
  image(img, 50, 50);
  image(img, mouseX-50, mouseY-50);
}