xxxxxxxxxx
37
function setup() {
createCanvas(400, 400);
}
function draw() {
background(50);
// change background colors depending on location of mouse
if (mouseX > width / 2 || mouseY > height/2) {
background("teal");
} else {
background("pink");
}
fill("yellow");
drawStar(mouseX, mouseY, 0.01, 1.5);
fill("pink");
drawStar(mouseX, mouseY, -0.02, 1.0);
fill("teal");
drawStar(mouseX, mouseY, 0.03, 1.2);
}
// 2. Function to draw rotating star
function drawStar(x, y, spd, scl) {
push();
translate(x, y);
rotate(frameCount * spd); // rotates below stuff
scale(scl);
noStroke();
ellipse(0, 0, 50, 20);
ellipse(0, 0, 20, 50);
pop();
}