xxxxxxxxxx
37
// Position left-most point 10-pixels
// from the left edge of the canvas
let x = 10;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// Move across the screen
x++;
strokeWeight(5);
// Draw 4 points, evenly spaced
// point(x, 80);
// point(x + 50, 80);
// point(x + 100, 80);
// point(x + 150, 80);
// Use a loop to do the same thing as above
for (let i = 0; i < 4; i++) {
// Each point is successively i*50
// to the right of the left-most point
point(x + (i*50), 80);
// You can try this too
//point((x*i) + 50, 80);
// Why doesn't this work?
// x += 50;
// point(x, 80);
}
}