xxxxxxxxxx
69
let angle = 0;
let r;
let g;
let b;
let col = {
r: 255,
g: 255,
b: 255,
}
let speedX;
function setup() {
createCanvas(600, 400);
noCursor();
angleMode(DEGREES);
rectMode(CENTER);
col.r = random(0, 255)
col.g = random(0, 255)
col.b = random(0, 255)
}
function draw() {
//rainbow slider cursor and background
r = map(mouseX, 0, width, 230,0);
g = map(mouseY, 0, height, 30, 255);
b = map(mouseX, 0, width, 255, 70);
background(r/0.5, g, b/2);
fill(r,g,b);
noStroke();
circle(mouseX, mouseY, width * 0.05);
speedX = map(mouseX, 0, width, 0.5, 2.5);
//random color rotating square 1
push();
translate(width * 0.5, height * 0.5);
rotate(angle);
noStroke();
fill(col.r, col.g, col.b);
square(0, 0, width / 10.5);
pop();
//random color rotating square 2 (middle)
push();
translate(width * 0.5, height * 0.5);
rotate(angle * -1);
stroke(255, 255, 255, 20);
fill(col.r, col.g, col.b, 90);
square(0, 0, width / 7);
pop();
//random color rotating square 3 (outer)
push();
translate(width * 0.5, height * 0.5);
rotate(angle);
stroke(255, 255, 255, 20);
fill(col.r, col.g, col.b, 80);
square(0, 0, width / 4);
pop();
angle = angle + speedX
}