xxxxxxxxxx
116
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// change background colors depending on location of mouse
if (mouseX < width/2 && mouseY < height/2) { // top left // spring
background("green");
// draw a spring creature
drawSpringCreature("purple",mouseX, mouseY, 0.01, 0.5);
} else if (mouseX > width/2 && mouseY < height/2) { // top right // summer
background("yellow");
// draw a summer creature
drawSpringCreature("purple",mouseX, mouseY, 0.01, 0.5);
// fill("yellow");
// drawStar(mouseX, mouseY, 0.01, 1.5);
// fill("pink");
// drawStar(mouseX, mouseY, 0.03, 1.0);
// fill("cyan");
// drawStar(mouseX, mouseY, 0.05, 1.2);
} else if (mouseX < width/2 && mouseY > height/2) { // bottom left // fall
background("orange");
// draw a fall creature
} else { // bottom right // winter
background("blue");
// draw a winter creature
}
// functions defined below
// // Function to draw a basic circle creature
// function drawCreature(creatureColor,x, y, spd, scl) {
// push();
// fill(creatureColor);
// translate(x, y);
// rotate(frameCount * spd); // rotates below stuff
// scale(scl);
// noStroke();
// ellipse(0, 0, 100, 100);
// pop();
// draw a spring creature
function drawSpringCreature(creatureColor,x, y, spd, scl) {
push();
fill(creatureColor);
translate(x, y);
rotate(frameCount * spd); // rotates below stuff
scale(scl);
noStroke();
ellipse(0, 0, 100, 100);
ellipse(0, 0, 50, 200);
pop();
}
// draw a summer creature
function drawSummerCreature(creatureColor,x, y, spd, scl) {
push();
fill(creatureColor);
translate(x+10, y+10);
rotate(frameCount * spd); // rotates below stuff
scale(scl);
noStroke();
ellipse(0, 0, 100, 100);
rect(0, 0, 100, 100);
pop();
}
// draw a fall creature
function drawFallCreature(creatureColor,x, y, spd, scl) {
push();
fill(creatureColor);
translate(x-20, y-20);
rotate(frameCount * spd); // rotates below stuff
scale(scl);
noStroke();
ellipse(0, 0, 100, 100);
pop();
}
// draw a winter creature
function drawWinterCreature(creatureColor,x, y, spd, scl) {
push();
fill(creatureColor);
translate(x-30, y-30);
rotate(frameCount * spd); // rotates below stuff
scale(scl);
noStroke();
ellipse(0, 0, 100, 100);
pop();
}
// // 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, 100, 20);
// ellipse(0, 0, 20, 100);
// pop();
//}
}