xxxxxxxxxx
21
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
}
function draw() {
let angle = frameCount / 5;
clear();
rotateAbout(angle, 200, 100);
fill('green');
rect(150, 50, 100, 150);
}
/** Rotates a shape the amount specified by the angle
* parameter, around the point (x, y).
*/
function rotateAbout(angle, x, y) {
translate(x, y);
rotate(angle);
translate(-x, -y);
}