xxxxxxxxxx
28
// Rotate a Rectangle
let angle = 0; // Angle of the spinner.
function setup() {
createCanvas(200, 200);
// The spinner will have no stroke and filled pink.
noStroke();
fill(240, 99, 164);
// When drawing rectangle, coordinates specify shape's centre.
rectMode(CENTER);
// Not actually required, since RADIANS is default.
angleMode(RADIANS);
}
function draw() {
// Clear the canvas purple.
background(146, 83, 161);
// Draw spinner rotated by current angle around canvas centre.
translate(width / 2, height / 2);
rotate(angle);
rect(0, 0, width * 0.8, height * 0.1);
// Increment the radian angle.
angle += 0.01;
}