xxxxxxxxxx
28
/*
* Creative Coding Workshop #3 Demo - Translate & Rotate
*
* Jack B. Du (github@jackbdu.com)
*/
function setup() {
// create a 400px by 400px canvas
createCanvas(400, 400);
}
function draw() {
// specify a background for each frame
background(220);
// let rectangles to be specified with center position
rectMode(CENTER);
// save current settings (to be reloaded later)
push();
// move origin to (200, 200), which is the center of canvas
translate(200, 200);
// rotate at a different angle based on frameCount
rotate(frameCount / 20);
// draw rectangle at origin
rect(0, 0, 50, 100);
// reload settings
pop();
}