Ellipse mask with background video
in
Programming Questions
•
5 months ago
Hi, I'm new in processing
I want to make a mouse controlled mask with a ellipse shape, and video in the background.
But I only could made it with a static image, like in the code below
Thanks for your help
But I only could made it with a static image, like in the code below
Thanks for your help
PShader maskShader;
PImage srcImage;
PGraphics maskImage;
void setup() {
size(800, 600, P2D);
srcImage = loadImage("imagen.jpg");
maskImage = createGraphics(srcImage.width, srcImage.height, P2D);
maskImage.noSmooth();
maskShader = loadShader("mask.glsl");
maskShader.set("mask", maskImage);
background(0);
noCursor();
}
void draw() {
maskImage.beginDraw();
maskImage.background(0);
if (mouseX != 0 && mouseY != 0) {
maskImage.noStroke();
maskImage.fill(255, 0, 0);
float speed = abs(mouseX-pmouseX) + abs(mouseY-pmouseY);
maskImage.ellipse(mouseX, mouseY, 30+speed, 30+speed);
}
int m = millis();
maskImage.endDraw();
if (mousePressed == false) {
maskImage.background(0);
}
shader(maskShader);
image(srcImage, 0, 0, width, height);
}
1