Created
December 7, 2011 16:02
-
-
Save atduskgreg/1443333 to your computer and use it in GitHub Desktop.
masking an image with a gradient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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