xxxxxxxxxx
35
// function setup() {
// createCanvas(300, 300);
// let foo = 50; // create and initialize a variable
// while (foo < width) { // keep going as long as the condition is true
// ellipse(foo, 50, 40, 40);
// // modify the variable so something different happens next time
// foo = foo + 50;
// } // ctrl / for commenting out
// }
// function setup() {
// createCanvas(300, 300);
// // initialization, condition, and incrementation all in one line
// for (let foo = 50; foo < width; foo = foo + 50) {
// ellipse(foo, 50, 40, 40);
// }
// }
function setup() {
createCanvas(700, 700);
background(230);
fill(0);
let yPos = 0;
let xPos = 0;
for (yPos = 30; yPos < height; yPos=yPos + 40) { // starting y at 30, y is less than the height, when why is less than the height you add 40 and keep doing so until y equals height
for (xPos = 20; xPos<width; xPos=xPos + 40) {
circle(xPos,yPos, 5);
}
}
} // functions: