is the last image you found the solution? in any case based on this post by @GSA_IxD you could do it like so
PGraphics mask, buffer;
void setup() {
size(1024, 1024, P2D);
mask = createGraphics(width, height, P2D);
buffer = createGraphics(width, height, P2D);
}
void draw() {
background(255);
updateMask();
updateBuffer();
buffer.mask(mask);
image(buffer, 0, 0);
}
void updateMask() {
mask.beginDraw();
mask.noStroke();
mask.fill(255);
mask.quad(500, 300, 700, 500, 500, 700, 300, 500);
mask.endDraw();
}
void updateBuffer() {
buffer.beginDraw();
buffer.background(255, 255, 0);
buffer.strokeWeight(25);
buffer.stroke(0, 0, 0);
for (float x=312.5; x<700; x=x+50) {
buffer.line(x, 300, x, 700);
}
buffer.endDraw();
}