Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created December 7, 2011 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/1443333 to your computer and use it in GitHub Desktop.
Save atduskgreg/1443333 to your computer and use it in GitHub Desktop.
masking an image with a gradient
PImage theImage;
PImage theMask;
int imageWidth = 140;
int imageHeight = 140;
void setup(){
size(500,500);
noStroke();
theImage = loadImage("cat.png");
theMask = loadImage("mask.png");
}
void draw(){
background(255);
image(theImage, 0, 0);
float percentHidden = map(mouseY,0, width -1 , 0, 1); // 0.0 to 1.0
image(theMask, 0, imageHeight * percentHidden);
fill(255);
rect(0,0, imageWidth, imageHeight * percentHidden);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment