PImage img, img2;
PGraphics msk;
void setup() {
size(600, 600);
msk = createGraphics(width, height);
background(100, 0, 0);
noStroke();
for ( int t = 0; t < 100; t++) {
fill(random(200), random(200), random(200));
rect( random(width-20), random(height-20), 20, 20);
}
img = get();
}
void draw() {
msk.beginDraw();
msk.background(0);
msk.fill(255);
msk.ellipse(mouseX, mouseY, 80, 80);
msk.endDraw();
background(img);
img2 = get();
filter(BLUR, 7);
img2.mask(msk);
image( img2, 0, 0);
noFill();
stroke(0);
ellipse(mouseX, mouseY, 80, 80);
}
There’s probably a bunch of ways to optimize this.