xxxxxxxxxx
24
let count = 0; // initialize a counter variable
function setup() {
createCanvas(400, 300); //size of canvas
rectMode(CENTER); //centre aligned
}
function draw() {
background(1, 186, 240);
// declaration of variables inside the function scope
let x = width / 2 + count;
let y = height / 2;
// circle
fill(237, 34, 93);
noStroke();
ellipse(x, y, 200, 200);
// rectangle
fill(255);
rect(x, y, 150, 30);
count = count + 1; // increment the counter variable
}