//Claire Jarzab
//Student #991524076
//Interactive Cat
//Have you ever seen two cats in a showdown? They stare at each other
//angrily until one of them finally makes a move and the paws begin to fly.
//This usually happens when there are disputes over the good spot on the
//sofa or when one is simply bored and wants to 'play.'
//The program runs through this once.
void setup()
//Size of the screen is set.
//Center is the default ellipse mode and isn't technically needed but it is written
//so that my code is easier to understand.
{
size(400, 400);
ellipseMode(CENTER);
}
//The program runs through this code until the program is terminated or an event occurs.
void draw()
{
//Sets the framerate
frameRate(120);
//Sets the backdround to light blue. As mouse travels along X, it begins to appear red.
{
background (220,255-mouseX,255-mouseX);
}
//Draws the surface the cat is sitting on and makes it appear red as the mouse is moved along X.
{
stroke(115,255-mouseX,255-mouseX);
strokeWeight(80);
line(0,360,400,360);
}
//Draws the cat's tail
{
fill(255);
noStroke();
//Draws all the white and grey circles in the tail. They all move left and right based on the mouse Y.
//They all move up and down based on mouse X. They are all labeled in order from bottom to top.
//Fill has to be stated every time to create the striped, layered effect.
{
ellipse(210-(mouseY *0.01),400,20,20); //1
fill(70);
ellipse(190-(mouseY *0.01),390+(mouseX *0.01),25,25); //2
fill(255);
ellipse(170+(mouseY *0.05),380+(mouseX *0.02),25,25); //3
fill(70);
ellipse(157+(mouseY *0.12),373+(mouseX *0.02),25,25); //4
fill(255);
ellipse(150+(mouseY *0.15),360+(mouseX *0.03),27,27); //5
fill(70);
ellipse(150+(mouseY *0.14),340+(mouseX *0.02),29,29); //6
fill(255);
ellipse(155+(mouseY *0.09),320+(mouseX *0.009),30,30); //7
fill(70);
ellipse(160+(mouseY *0.03),300+(mouseX *0.01),30,30); //8
fill(255);
ellipse(170-(mouseY *0.04),280-(mouseX *0.008),33,33); //9
fill(70);
ellipse(175-(mouseY *0.08),260-(mouseX *0.01),33,33); //10
fill(255);
ellipse(173-(mouseY *0.07),240-(mouseX *0.03),36,36); //11
fill(70);
ellipse(160-(mouseY *0.01),220-(mouseX *0.04),37,37); //12
fill(255);
ellipse(140+(mouseY *0.08),215-(mouseX *0.08),38,38); //13
fill(70);
ellipse(120+(mouseY *0.18),220-(mouseX *0.16),40,40); //14
}
}
//Draws the rest of the cat.
//Draws the cat's body, ears, and head.
{
noStroke();
fill(255);
quad(230,200,355,200,380,400,212,400);
//One point of the triangle is linked to mouseX to 'rotate' the ears
triangle(230,200,240-(mouseX * 0.07),140+(mouseX * 0.06),295,200);
triangle(355,200,335+(mouseX * 0.08),130+(mouseX * 0.08),290,200);
//One point in the triangle is linked to mouseX so that the pink vanishes behind the head as the ears get more flat
fill(255,196,211); //Set colour to pink
triangle(245-(mouseX * 0.02),160+(mouseX * 0.1),255,170,240,185);
triangle(342,180,335-(mouseX * 0.02),150+(mouseX * 0.1),325,170);
fill(255);
ellipse(293,232,133,150);
}
//Draws cat's grey fur.
{
fill(70);
quad(245,355,275,312,290,310,290,333);
quad(290,310,310,310,330,340,290,323);
quad(280,320,308,322,337,386,290,370);
quad(270,320,300,320,280,389,235,389);
quad(242,388,290,388,265,400,236,400);
triangle(290,340,333,400,250,400);
}
//Draws cat's mouth and whiskers.
{
stroke(70);
strokeWeight(10);
line(190,200,220,215);
line(180,240,215,245);
line(392,205,365,215);
line(392,240,367,240);
strokeWeight(6);
line(260,250,270,270);
line(270,270,287,255);
line(287,255,305,270);
line(305,270,315,250);
}
//Draws small eyebrows behind the eyes. They become thicker and move as mouse X gets
//closer to the now angry cat.
{
strokeWeight(3 + (mouseX * 0.03));
line(265 - (mouseX * 0.02), 213 - (mouseX * 0.05), 268 + (mouseX * 0.02), 214 + (mouseX * 0.005));
line(310 + (mouseX * 0.02), 213 - (mouseX * 0.05), 307 - (mouseX * 0.02), 214 + (mouseX * 0.005));
}
//Draws the cat's eyes. The lines get thicker as mouse X increases. I tried to make it so that the eyes flash,
//and continue to flash faster as mouse X approaches the cat to simulate the uncontrolable annoyance it is feeling.
//It does not work as intended, however the effect was kept as it looked fun.
//Figured out that sin() takes the values of and between -1 and 1
{
fill(255);
strokeWeight(3 + (mouseX * 0.005));
ellipse(265, 220, 13 + (mouseX * 0.05), 13 + (mouseX * 0.05) + sin(frameCount * (mouseX * 0.6)));
ellipse(310, 220, 13 + (mouseX * 0.05), 13 + (mouseX * 0.05) + sin(frameCount * (mouseX * 0.6)));
}
//Draws the black paw that follows the mouse.
{
noStroke();
fill(20,20,20);
ellipse(mouseX,mouseY, 40, 40);
ellipse(mouseX,mouseY-20, 20, 20); //top
ellipse(mouseX+16, mouseY-15, 28,28); //middle
ellipse(mouseX+16,mouseY+5,20,20); //bottom
quad(mouseX-17, mouseY-10,mouseX+10,mouseY+10,mouseX-100,mouseY+500,mouseX-150,mouseY+500);
}
}
//Program runs through this code when the mouse is pressed
void mousePressed(){
//Draws line that represents the other cat's paw reaching out to yours
{
frameRate(3);
strokeWeight(35);
stroke(235);
line(390,400,mouseX+4,mouseY-8);
}
//Redraws the black paw overtop to create a "high-five" image
{
noStroke();
fill(20,20,20);
ellipse(mouseX,mouseY, 40, 40);
ellipse(mouseX,mouseY-20, 20, 20); //top
ellipse(mouseX+16, mouseY-15, 28,28); //middle
ellipse(mouseX+16,mouseY+5,20,20); //bottom
quad(mouseX-17, mouseY-10,mouseX+10,mouseY+10,mouseX-100,mouseY+500,mouseX-150,mouseY+500);
}
}