Create this (or as close as you can) using ONE ellipse()
and a while
loop.
Letβs go back to NYU.
for
loopsHow many ellipses will draw?
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
strokeWeight(4);
stroke(255);
// nested loop:
y = 50;
for (var x = 25; x < 100; x = x + 50) {
ellipse(x, y, 50, 50);
}
}
How about now?
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
strokeWeight(4);
stroke(255);
// nested loop:
y = 50;
for (var x = 25; x < 100; x = x + 50) {
for (var y = 25; y < 100; y = y + 50) {
ellipse(x, y, 50, 50);
}
}
}
A loop in a loop.
In other wordsβ¦