Is this helpful? (sorry – just realised this is supposed to be Processing.py)
PGraphics main, mask;
void setup() {
size(600, 600, P2D);
main = createGraphics(width, height, P2D);
mask = createGraphics(width, height, P2D);
}
void draw() {
background(0);
updateMask();
updateMain();
// apply mask
main.mask(mask);
image(main, 0, 0);
}
void updateMain() {
main.beginDraw();
main.background(128, 0, 0);
main.stroke(255);
main.strokeWeight(50);
main.strokeCap(SQUARE);
float y = noise(frameCount*0.01)*height;
main.line(0, y, width, y);
main.endDraw();
}
void updateMask() {
mask.beginDraw();
mask.background(0);
mask.fill(255);
float s = noise(frameCount*0.013);
mask.ellipse(mask.width/2, mask.height/2, mask.width*s, mask.height*s);
mask.endDraw();
}