I’m studying Daniel Shiffman’s book “Learning Processing”.
In Exercise 6.5 of the book, I can not understand why background(0) which is in draw() is not updated each time a new line is drawn, erasing the previously drawn line, but only when endY returns to 0 at the end, in if(endY > height) …
int endY;
void setup() {
size(200, 200);
frameRate(5);
endY = 0;
}
void draw() {
background(0);
for (int y = 0; y < endY; y += 10) {
stroke(255);
line(0, y, width, y);
}
endY = endY + 10;
if(endY > height) {
endY = 0;
}
}
It’s not very clear to me. Could someone explain to me?