xxxxxxxxxx
36
function setup() {
createCanvas(400, 400);
describe('A white circle on a gray background. The circle moves from left to right in a loop. It slows down when the mouse is pressed.');
}
function draw() {
colorMode(HSB)
// for (let i = 0; i < 100; i++) {
// background(x, 100, 100);
// }
background(200);
// Set the x variable based
// on the current frameCount.
let x = frameCount % 400;
// If the mouse is pressed,
// decrease the frame rate.
if (mouseIsPressed === true) {
frameRate(10);
} else {
frameRate(60);
}
fill(x, 100, 100);
rect(30, 20, 55, 55)
background(x, 100, 100);
// Use x to set the circle's
// position.
circle(x, 50, 20);
}