Initial Commit

This commit is contained in:
plane000
2018-04-20 10:15:15 +01:00
parent 49150ccfe4
commit 62101e8e61
2870 changed files with 520122 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/**
* Image Mask
*
* Move the mouse to reveal the image through the dynamic mask.
*/
PShader maskShader;
PImage srcImage;
PGraphics maskImage;
void setup() {
size(640, 360, P2D);
srcImage = loadImage("leaves.jpg");
maskImage = createGraphics(srcImage.width, srcImage.height, P2D);
maskImage.noSmooth();
maskShader = loadShader("mask.glsl");
maskShader.set("mask", maskImage);
background(255);
}
void draw() {
maskImage.beginDraw();
maskImage.background(0);
if (mouseX != 0 && mouseY != 0) {
maskImage.noStroke();
maskImage.fill(255, 0, 0);
maskImage.ellipse(mouseX, mouseY, 50, 50);
}
maskImage.endDraw();
shader(maskShader);
image(srcImage, 0, 0, width, height);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -0,0 +1,19 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform sampler2D mask;
uniform vec2 texOffset;
varying vec4 vertColor;
varying vec4 vertTexCoord;
void main() {
vec4 texColor = texture2D(texture, vertTexCoord.st).rgba;
vec4 maskColor = texture2D(mask, vec2(vertTexCoord.s, 1.0 - vertTexCoord.t)).rgba;
gl_FragColor = mix(texColor, vec4(0, 0, 0, 0), 1.0 - maskColor.r);
}