a port of the Processing Visualization Language


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 must be used to preload the image so that it will be available when used in the sketch  

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

PImage img;

PImage maskImg;

void setup() 



  img = loadImage("data/test.jpg");

  maskImg = loadImage("data/mask.jpg");



void draw() 



  image(img, 50, 50);

  image(img, mouseX-50, mouseY-50);

Fork me on GitHub