We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi :) at first my code:
//processing step1
void setup (){
size (600, 600);
// corner_lines
line (300,300,600,0);
line (300,300,600,600);
line (300,300,0,600);
line (300,300,0,0);
// rectangles
float rect_x = 280;
float rect_y = 280;
int rect_width = 40;
int rect_height = 40;
noFill();
for (int i=1; i<9; i++) {
rect (rect_x, rect_y, rect_width, rect_height);
rect_x = rect_x - 35;
rect_y = rect_y - 35;
rect_width = rect_width + 70;
rect_height = rect_height + 70;
}
// lines_left
float endx1 = 0;
float endy1 = random(40,150);
for (int i = 1; i<=4; i++){
line(width/2,height/2,endx1,endy1);
endy1 = endy1 + random(40,150);
}
// lines_right
float endx2 = 600;
float endy2 = random(40,150);
for (int i = 1; i<=4; i++){
line(width/2,height/2,endx2,endy2);
endy2 = endy2 + random(40,150);
}
// lines_top
float endx3 = random(40,150);
float endy3 = 0;
for (int i = 1; i<=4; i++){
line(width/2,height/2,endx3,endy3);
endx3 = endx3 + random(40,150);
}
// lines_buttom
float endx4 = random(40,150);
float endy4 = 600;
for (int i = 1; i<=4; i++){
line(width/2,height/2,endx4,endy4);
endx4 = endx4 + random(40,150);
}
}
I know it could be a better structure ...but I haven´t so many skills until now :-S
The problem is, that I don´t know how to fill out every second shape in my sketch (look at the attachment/picture). Is there a function which can help me?
Answers
Your problem description is very clear. And it is very good to post your code so far. Unfortunately, I don't see any easy way to get from your existing code to the intended visual.
What would help is if you would define your shape in terms of faces made from vertices. Currently you have lines. While these result in the correct shape outline, there are no actual 'computational faces' to color. One could use a color-filling technique (think: paint bucket in photoshop) but that seems a bit convulated.
For this type of image, the most useful method is filter(INVERT). You can draw the rectangles in one PGraphics (i.e. main), then the star burst in another PGraphics (i.e. mask). Then display the main as normal. Then invert the colors of the main, mask it using the star burst PGraphics, then display the masked & inverted image.
You can try this yourself! :-)
Here is an implementation of the described method...
Code Example (not optimized for speed)
I believe I've got it optimized a lil'...: (*)