//Title: Xray_Machine //Description: This program draws a face that will avoid the mouse around the screen (its eyes will follow). Pressing any key will enable Xray vision (the key can be held). The face's parts are all listed from the perspective of the face (the eye on the left side of the screen is the face's right eye). //Author: Paolo Di Filippo; Student ID: 991442028 //Course: PROG14998 Introduction to Media Computation - 1169_89545; Instructor: Nicolas Hesler void setup() { size(400, 400); } void draw() { background(255); //I specify a frameRate at the begining of the draw loop because the change I make to frameRate in the keyPressed event would affect the whole program after being called frameRate(30); /*SKULL*/ noFill(); stroke(0); strokeWeight(5); //outline for skull's jaw (with the br and bl corners of the rect using 100 as the radius value) rect(width - mouseX, (height + 60) - mouseY, 195, 120, 0, 0, 100, 100); fill(255); //skull top ellipse(width - mouseX, (height - 40) - mouseY, 230, 220); noStroke(); //skull bottom rect(width - mouseX, (height + 60) - mouseY, 195, 120, 0, 0, 100, 100); fill(0); //right skull eye ellipse((width - 50) - mouseX, (height - 30) - mouseY, 60, 50); //left skull eye ellipse((width + 50) - mouseX, (height - 30) - mouseY, 60, 50); //right skull nostril (tl corner is most round, tr is close to bridge of nose and is straighter, br is slightly curver and bl is as curved as tl) rect((width - 10) - mouseX, height - mouseY, 15, 50, 100, 5, 15, 100); //left skull nostril (tl corner is close to bridge of nose and is straighter, tr corner is most round, br is as curved as tr and bl is slightly curved) rect((width + 10) - mouseX, height - mouseY, 15, 50, 5, 100, 100, 15); noFill(); stroke(0); strokeWeight(3); //skull mouth ellipse(width - mouseX, (height + 75) - mouseY, 100, 40); rectMode(CORNERS); //skull's teeth: the first rect in this series is the rightmost tooth, and they are all drawn from right to left rect((width - 48) - mouseX, (height + 55) - mouseY, (width - 36) - mouseX, (height + 95) - mouseY); rect((width - 36) - mouseX, (height + 55) - mouseY, (width - 24) - mouseX, (height + 95) - mouseY); rect((width - 24) - mouseX, (height + 55) - mouseY, (width - 12) - mouseX, (height + 95) - mouseY); rect((width - 12) - mouseX, (height + 55) - mouseY, width - mouseX, (height + 95) - mouseY); rect(width - mouseX, (height + 55) - mouseY, (width + 12) - mouseX, (height + 95) - mouseY); rect((width + 12) - mouseX, (height + 55) - mouseY, (width + 24) - mouseX, (height + 95) - mouseY); rect((width + 24) - mouseX, (height + 55) - mouseY, (width + 36) - mouseX, (height + 95) - mouseY); rect((width + 36) - mouseX, (height + 55) - mouseY, (width + 48) - mouseX, (height + 95) - mouseY); stroke(255); strokeWeight(12); //skull mouth outer lining ellipse(width - mouseX, (height + 75) - mouseY, 115, 55); /*SKULL*/ /*HEAD*/ noStroke(); ellipseMode(CENTER); //skin colour for head fill(250, 190, 190); //head ellipse(width - mouseX, height - mouseY, 250, 300); //hair colour fill(120, 60, 60); //hair arc(width - mouseX, (height - 10) - mouseY, 254, 350, radians(170), radians(370)); //skin colour for head fill(250, 190, 190); //skin coloured arc to cover up hair drawn over head arc(width - mouseX, (height + 21) - mouseY, 200, 300, radians(180), radians(360)); /*HEAD*/ /*EYES*/ //the different parts of the eyes move at different rates to simulate a parallax effect //whites of the eyes fill(255); //right eye triangle((width - 80) - mouseX, (height - 10) - mouseY, (width - 50) - mouseX, (height - 50) - mouseY, (width - 30) - mouseX, (height - 10) - mouseY); //left eye triangle((width + 80) - mouseX, (height - 10) - mouseY, (width + 50) - mouseX, (height - 50) - mouseY, (width + 30) - mouseX, (height - 10) - mouseY); //black for eye rings fill(0, 200); //right eye ring ellipse(((width - 50) - mouseX) - ((width/2 - mouseX) * 0.02), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.02), 30, 30); //left eye ring ellipse(((width + 50) - mouseX) - ((width/2 - mouseX) * 0.02), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.02), 30, 30); //brown for iris fill(150, 55, 55); //right iris ellipse(((width - 50) - mouseX) - ((width/2 - mouseX) * 0.03), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.03), 25, 25); //left iris ellipse(((width + 50) - mouseX) - ((width/2 - mouseX) * 0.03), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.03), 25, 25); //black for pupil fill(0); //right pupil ellipse(((width - 50) - mouseX) - ((width/2 - mouseX) * 0.04), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.04), 10, 10); //left pupil ellipse(((width + 50) - mouseX) - ((width/2 - mouseX) * 0.04), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.04), 10, 10); noFill(); //skin colour for triangles around eyes to cover moving inner eye when it goes outside bounds of white eye triangle stroke(250, 190, 190); strokeWeight(7); //right eye triangle triangle((width - 89) - mouseX, (height - 8) - mouseY, (width - 50) - mouseX, (height - 57) - mouseY, (width - 21) - mouseX, (height - 8) - mouseY); //left eye triangle triangle((width + 89) - mouseX, (height - 8) - mouseY, (width + 50) - mouseX, (height - 57) - mouseY, (width + 21) - mouseX, (height - 8) - mouseY); /*EYES*/ /*NOSE*/ noStroke(); //darker skin colour for nose fill(240, 170, 170); rectMode(CENTER); //bridge of nose rect(width - mouseX, height - mouseY, 50, 100, 50); fill(250, 190, 190); //right curve of nose arc((width - 30) - mouseX, (height - 10) - mouseY, 30, 50, radians(270), radians(450)); //left curve of nose arc((width + 30) - mouseX, (height - 10) - mouseY, 30, 50, radians(90), radians(270)); /*NOSE*/ /*EYEBROWS*/ //eyebrow lining colour stroke(100, 60, 60); strokeWeight(2); //eyebrow inner colour fill(120, 60, 60); //right eyebrow arc((width - 50) - mouseX, (height - 60) - (mouseY + (0.05 * (height/2 - mouseY))), 50, 25, radians(170), radians(370)); //left eyebrow arc((width + 50) - mouseX, (height - 60) - (mouseY + (0.05 * (height/2 - mouseY))), 50, 25, radians(170), radians(370)); /*EYEBROWS*/ /*EYE BAGS*/ noStroke(); //purple skin colour for under eyes fill(210, 170, 200); ellipseMode(CORNERS); //right eye bag arc((width - 70) - mouseX, (height - 20) - mouseY, (width - 30) - mouseX, (height + 5) - mouseY, 0, PI); //left eye bag arc((width + 30) - mouseX, (height - 20) - mouseY, (width + 70) - mouseX, (height + 5) - mouseY, 0, PI); /*EYE BAGS*/ /*LIPS*/ //lip colour fill(240, 100, 125); //lip outline colour stroke(240, 175, 185, 150); ellipseMode(CENTER); //upper lip arc(width - mouseX, (height + 80) - mouseY, 100, 40, PI, TWO_PI); //bottom lip arc(width - mouseX, (height + 80) - mouseY, 80, 40, 0, PI); /*LIPS*/ } void keyPressed() { //set framerate lower to prevent flickering when event is called frameRate(7); background(0); println("Xray mode engaged!"); //all primitives except the skull have the alpha value in their fill functions reduced to create the illusion of an Xray /*SKULL*/ noFill(); stroke(0); strokeWeight(5); //outline for skull's jaw (with the br and bl corners of the rect using 100 as the radius value) rect(width - mouseX, (height + 60) - mouseY, 195, 120, 0, 0, 100, 100); fill(255); //skull top ellipse(width - mouseX, (height - 40) - mouseY, 230, 220); noStroke(); //skull bottom rect(width - mouseX, (height + 60) - mouseY, 195, 120, 0, 0, 100, 100); fill(0); //right skull eye ellipse((width - 50) - mouseX, (height - 30) - mouseY, 60, 50); //left skull eye ellipse((width + 50) - mouseX, (height - 30) - mouseY, 60, 50); //right skull nostril (tl corner is most round, tr is close to bridge of nose and is straighter, br is slightly curver and bl is as curved as tl) rect((width - 10) - mouseX, height - mouseY, 15, 50, 100, 5, 15, 100); //left skull nostril (tl corner is close to bridge of nose and is straighter, tr corner is most round, br is as curved as tr and bl is slightly curved) rect((width + 10) - mouseX, height - mouseY, 15, 50, 5, 100, 100, 15); noFill(); stroke(0); strokeWeight(3); //skull mouth ellipse(width - mouseX, (height + 75) - mouseY, 100, 40); rectMode(CORNERS); //skull's teeth: the first rect in this series is the rightmost tooth, and they are all drawn from right to left rect((width - 48) - mouseX, (height + 55) - mouseY, (width - 36) - mouseX, (height + 95) - mouseY); rect((width - 36) - mouseX, (height + 55) - mouseY, (width - 24) - mouseX, (height + 95) - mouseY); rect((width - 24) - mouseX, (height + 55) - mouseY, (width - 12) - mouseX, (height + 95) - mouseY); rect((width - 12) - mouseX, (height + 55) - mouseY, width - mouseX, (height + 95) - mouseY); rect(width - mouseX, (height + 55) - mouseY, (width + 12) - mouseX, (height + 95) - mouseY); rect((width + 12) - mouseX, (height + 55) - mouseY, (width + 24) - mouseX, (height + 95) - mouseY); rect((width + 24) - mouseX, (height + 55) - mouseY, (width + 36) - mouseX, (height + 95) - mouseY); rect((width + 36) - mouseX, (height + 55) - mouseY, (width + 48) - mouseX, (height + 95) - mouseY); stroke(255); strokeWeight(12); //skull mouth outer lining ellipse(width - mouseX, (height + 75) - mouseY, 115, 55); /*SKULL*/ /*HEAD*/ noStroke(); ellipseMode(CENTER); //skin colour for head fill(250, 190, 190, 50); //head ellipse(width - mouseX, height - mouseY, 250, 300); //hair colour fill(120, 60, 60, 50); //hair arc(width - mouseX, (height - 10) - mouseY, 254, 350, radians(170), radians(370)); //skin colour for head fill(250, 190, 190, 50); //skin coloured arc to cover up hair drawn over head arc(width - mouseX, (height + 21) - mouseY, 200, 300, radians(180), radians(360)); /*HEAD*/ /*EYES*/ //whites of the eyes fill(255, 50); //right eye triangle((width - 80) - mouseX, (height - 10) - mouseY, (width - 50) - mouseX, (height - 50) - mouseY, (width - 30) - mouseX, (height - 10) - mouseY); //left eye triangle((width + 80) - mouseX, (height - 10) - mouseY, (width + 50) - mouseX, (height - 50) - mouseY, (width + 30) - mouseX, (height - 10) - mouseY); //black for eye rings fill(0, 25); //right eye ring ellipse(((width - 50) - mouseX) - ((width/2 - mouseX) * 0.02), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.02), 30, 30); //left eye ring ellipse(((width + 50) - mouseX) - ((width/2 - mouseX) * 0.02), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.02), 30, 30); //brown for iris fill(150, 55, 55, 50); //right iris ellipse(((width - 50) - mouseX) - ((width/2 - mouseX) * 0.03), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.03), 25, 25); //left iris ellipse(((width + 50) - mouseX) - ((width/2 - mouseX) * 0.03), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.03), 25, 25); //black for pupil fill(0, 50); //right pupil ellipse(((width - 50) - mouseX) - ((width/2 - mouseX) * 0.04), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.04), 10, 10); //left pupil ellipse(((width + 50) - mouseX) - ((width/2 - mouseX) * 0.04), ((height - 20) - mouseY) - ((height/2 - mouseY) * 0.04), 10, 10); noFill(); //skin colour for triangles around eyes to cover moving inner eye when it goes outside bounds of white eye triangle stroke(250, 190, 190, 50); strokeWeight(7); //right eye triangle triangle((width - 89) - mouseX, (height - 8) - mouseY, (width - 50) - mouseX, (height - 57) - mouseY, (width - 21) - mouseX, (height - 8) - mouseY); //left eye triangle triangle((width + 89) - mouseX, (height - 8) - mouseY, (width + 50) - mouseX, (height - 57) - mouseY, (width + 21) - mouseX, (height - 8) - mouseY); /*EYES*/ /*NOSE*/ noStroke(); //darker skin colour for nose fill(240, 170, 170, 50); rectMode(CENTER); //bridge of nose rect(width - mouseX, height - mouseY, 50, 100, 50); fill(250, 190, 190, 50); //right curve of nose arc((width - 30) - mouseX, (height - 10) - mouseY, 30, 50, radians(270), radians(450)); //left curve of nose arc((width + 30) - mouseX, (height - 10) - mouseY, 30, 50, radians(90), radians(270)); /*NOSE*/ /*EYEBROWS*/ //eyebrow lining colour stroke(100, 60, 60, 50); strokeWeight(2); //eyebrow inner colour fill(120, 60, 60, 50); //right eyebrow arc((width - 50) - mouseX, (height - 60) - (mouseY + (0.05 * (height/2 - mouseY))), 50, 25, radians(170), radians(370)); //left eyebrow arc((width + 50) - mouseX, (height - 60) - (mouseY + (0.05 * (height/2 - mouseY))), 50, 25, radians(170), radians(370)); /*EYEBROWS*/ /*EYE BAGS*/ noStroke(); //purple skin colour for under eyes fill(210, 170, 200, 50); ellipseMode(CORNERS); //right eye bag arc((width - 70) - mouseX, (height - 20) - mouseY, (width - 30) - mouseX, (height + 5) - mouseY, 0, PI); //left eye bag arc((width + 30) - mouseX, (height - 20) - mouseY, (width + 70) - mouseX, (height + 5) - mouseY, 0, PI); /*EYE BAGS*/ /*LIPS*/ //lip colour fill(240, 100, 125, 50); //lip outline colour stroke(240, 175, 185, 25); ellipseMode(CENTER); //upper lip arc(width - mouseX, (height + 80) - mouseY, 100, 40, PI, TWO_PI); //bottom lip arc(width - mouseX, (height + 80) - mouseY, 80, 40, 0, PI); /*LIPS*/ }