We are about to switch to a new forum software. Until then we have removed the registration on this forum.
This is driving me insane and I cannot seem to find any explanation.
Why are (in the following code) multiple shapes in the fill color (150) even though the fill command is the last command in the DRAW zone. I thought only subsequent shapes would be filled in that color - but it is also filling in earlier shapes in the same (150) grey.
void setup() {
size(640,420);
background(240);
smooth();
}
void draw() {
//body of zork
rectMode(CENTER);
rect(320,210,80,120);
//head of zork
ellipse(320,118,65,65);
//eyes of zork
//fill(50);
ellipse(307,115,10,20);
ellipse(333,115,10,20);
fill(150);
}
Answers
fill sets the pen colour so everything drawn after it will have that fill colour.
however, the draw() method loops around, so if you set the pen colour at the bottom then the same fill colour will be active at the top of the next loop...
https://processing.org/reference/draw_.html
https://processing.org/reference/fill_.html
also, if that's all you're doing, if you have no interaction or animation, then use noLoop();
Thank you koogs and GoToLoop. Makes much more sense now!