I am new to Processing and still have lots to learn and there is a ton I don’t understand.
I watched the Youtube Coding Train video on For Loops and While Loops. In the video he uses a while loop to draw lot’s of lines.
I basically changed his code, as I am trying to draw lot’s of circles, but I only get one circle. I left in the code that draws lot’s of lines so you can see what I am referencing.
I think this is the first step to what I am trying to do, which is create a more complex animation around this, but I want to start with this concept.
Thanks you, I’m posting my code below.
int r = 0;
int x = 0;
int circles = 300;
void setup(){
size(600,600);
background(255);
}
void draw(){
while (r < width){
ellipse(width/2, height/2, r, r); // while loop
r = r + 10;
}
while (x < width){
line(x, 0, x,height); // while loop
x = x + 20;
}
}
In order to know what was happening, is just that you were drawing the circles but all in the same point, and the draws are done in the same order you write in your code, so the circles were being painted each one over the last one , that’s why you could only see the bigger one, you could also do drawing in the opposite order:
int r = 0;
int x = 0;
int circles = 300;
void setup(){
size(600,600);
background(255);
}
void draw(){
while (r < width){
ellipse(width/2, height/2, width - r , width - r); // while loop
r = r + 10;
}
while (x < width){
line(x, 0, x,height); // while loop
x = x + 20;
}
}