xxxxxxxxxx
35
// using the different geometric primitives,
// extend this sketch! a challenge: get something rotating CCW
const CANVAS_W = 400;
const CANVAS_H = 400;
let currentHue = 100;
let angle = 0;
function setup() {
createCanvas(CANVAS_W, CANVAS_H);
angleMode(DEGREES);
rectMode(CENTER);
colorMode(HSB);
}
function draw() {
translate(200,200);
rotate(angle);
noFill();
strokeWeight(10);
stroke(currentHue,50,80,0.2);
if ( currentHue > 360) {
currentHue = 0;
}
rect(0, 0, 50);
rotate(angle * 0.2);
rect(50, 0, 100);
rotate(angle * 0.2);
rect(0, 20, 140);
rotate(angle * 0.2);
rect(80, 0, 100);
rotate(angle * 0.2);
rect(0, 90, 150);
rotate(angle * 0.2);
rect(0, 0, 50);
currentHue = currentHue + 1;
angle = angle + 1;
}