humano
October 5, 2021, 12:43am
1
Hi there! I have done a loop of vertical lines, but I don’t want them to leak out the rhombus behind. Is there a (easy) way to draw the lines inside the yellow rhombus as you can see in the picture below?
size(1000,1000);
background(255,255,255);
noStroke();
//quad yellow
noStroke();
fill(255,255,0);
quad(500,300,700,500,500,700,300,500);
strokeWeight(25);
stroke(0,0,0);
for(float x=312.5;x<700;x=x+50){
line(x,300,x,700);
}
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();
}
1 Like
humano
October 5, 2021, 8:30pm
3
Hahaha! I made the last image with Photoshop, I tried to do something with masks but I was not able to get that result. Thank you so much for your Code but It does something really different
How could I do something as you can see in the second picture of my first message?
that’s weird it looks like this on my machine
maybe it’s because i am using processing 4? or maybe you just need to mess with the way the masks are applied? masks can be very finicky
humano
October 5, 2021, 10:32pm
5
I am using APDE Android ProcessIng IDE, maybe that is the reason, that app is so tricky! Any idea about solving that?
maybe ask here Processing for Android - Processing Foundation
or someone else will be along with an answer soon no doubt
edit: i’m guessing there is a difference in the way android implements masks and it probably has to do with the blend functions available in android.
humano
October 5, 2021, 10:41pm
7
Thank you so much my friend!
humano
October 6, 2021, 2:01am
8
Could I repeat a mask with several elements in the same file?