Processing sketch - project 3
From Physical Programming
so this is what my sketch says, though you will also see this when you open the file:
void setup() {
size (500, 500);
// the 'size' command determines the size of the window when it opens
background (0, 0, 0);
// labels the background colour as black
}
// this brackets indicate what the end of the loop
// this loop is the initial setup and occurs when the window is opened
void draw() {
//this is the second loop
background (0, 0, 0);
//this means the background is reset each time to loop is run
translate (mouseX, mouseY);
// this command moves the ojbects listed below as the mouse moves
ellipse(0, 0, 150, 150);
// this command makes up the circle for the face of the smiley
// this is the command for drawing a circle in 2D space
fill (0, 0, 0);
// and this tells the circle to have a black fill
ellipse (-25, -25, 10, 10);
//this command makes up the left eye on the face
// these are the relevant co-ordinates for the circle.
//the first relates to the x co-ordinate, the second is the y co-ordinate.
//the third co-ordinate dictates the width and the 4th relates to the height of the ellipse.
ellipse (25, -25, 10, 10);
// as above and this command makes up the right eye
arc(0, 25, 70, 75, 0, PI);
//this arc makes up the smile/mouth of the face.
// 0 is the x co-ordinate of the ellipse
// 25 is the y co-ordinate of the ellipse
// 70 relates to the width of the ellipse
// 75 relates to the height of the ellipse
// 0 is the start of where the arc is drawn
// and PI dictates how much of the arc shows, so if this was TWO_PI instead, the whole circle would show as PI is multiplied by two
if (mousePressed == true) {
// this runs a different loop if the mouse is pressed
ellipse(0, 0, 150, 150);
// this is once again the face circle
ellipse (-25, -25, 10, 10);
// and this is the left eye again
line (20, -25, 30, -25);
// to make MR Smiley wink, the right eye is removed and this line drawn instead
arc(0, 25, 45, 50, 0, TWO_PI);
// i have altered the width and height of the arc and given it a TWO_PI to create a circle and an 'oh' expresseion
stroke (200,0,0);
//this command changes the colour of the lines that create the face to red
}
else {stroke(0, 0, 250);
//this command says that, at all other times that the mouse button is not clicked, the stoke colour shoule be blue
} }
// hope you like it! xo

