my task is to draw a grid of 10 x 10 wheels. Each should be a random color and have lots of spokes like a real wheel. I have to do this using nested for loops.
I have got to the code below but for some reason its drawing a 10 x infinite grid. I don't understand why as the outer loop should only run 10 times.
float XPos = 25;
float YPos = 25;
float Radius = 20;
void setup() {
size(500, 500);
}
void draw() {
for (int h = 0; h < 10; h++) {
for (int i = 0; i < 10; i++) {
float RanR = random(250);
float RanG = random(250);
float RanB = random(250);
stroke(RanR, RanG, RanB);
ellipse(XPos, YPos, Radius * 2, Radius * 2);
for (int j = 0; j < 360; j += 10) {
stroke(RanR, RanG, RanB);
line(XPos,
YPos,
XPos + Radius * sin(radians(j)),
YPos + Radius * cos(radians(j))
);
}
XPos += Radius * 2;
}
XPos = 25;
YPos += Radius * 2;
}
}
strokeandlinedo? Also you have three nestedfors so in a simple math you have 10*10*36 (360/10)