// Matthew Erlebacher
// Section B
// merlebac@andrew.cmu.edu
// Assignment-02-A
/* For this assignment I used the example provide in the assignment
description as a starting point. I then used what I learned from
that to add my own details and variation to the assignment. */
// Global Parameter Variables
var eyeWidth = 30
var eyeHeight = 30
// Determines width and height of eyes
var faceWidth = 150
var faceHeight = 150
// Determines width and height of face
var lipWidth = 100
var lipHeight = 10
// Determines width and height of lip
var noseP1X = 315
var noseP1Y = 265
// Determines 1st point of triangle nose
var noseP2X = 320
var noseP2Y = 255
// Determines 2nd point of triangle nose
var noseP3X = 325
var noseP3Y = 265
// Determines 3rd point of triangle nose
var hornX = 250
var hornY = 150
// Determines last point of horns
var fangP3 = 300
// Determines fang length
// Global color Variables
var faceColorR = 255
var faceColorG = 255
var faceColorB = 255
// Determines the color combination of face
var eyeColorR = 255
var eyeColorG = 255
var eyeColorB = 255
// Determines color combination of eyes
var lipColorR = 255
var lipColorG = 255
var lipColorB = 255
// Determines color combination of lip
var noseColorR = 255
var noseColorG = 255
var noseColorB = 255
// Determines color of nose
var hornColorR = 255
var hornColorG = 255
var hornColorB = 255
// Determines color of the horns
var fangColorR = 255
var fangColorG = 255
var fangColorB = 255
// Determines color of the fangs
function setup() {
createCanvas(640, 480);
// Creates a black canvas
}
function draw() {
background(0);
fill(hornColorR, hornColorG, hornColorB);
triangle(320, 270, 320, 210, hornX, hornY);
// Creates left horn
fill(hornColorR, hornColorG, hornColorB);
triangle(320, 270, 320, 210, width - hornX, hornY);
// Creates right horn
fill(faceColorR, faceColorG, faceColorB);
ellipse(width / 2, height / 2, faceWidth, faceHeight);
// Creates a circle for the face
var eyeLX = width / 2 - faceWidth * 0.25;
var eyeRX = width / 2 + faceWidth * 0.25;
// Chooses a coordinate for the eyes
fill(fangColorR, fangColorG, fangColorB);
triangle(280 + 0.1 * faceWidth, 280,
290 + 0.1 * faceWidth, 280, 285 + 0.1 * faceWidth, fangP3);
// Creates left fang
fill(fangColorR, fangColorG, fangColorB);
triangle(360 - 0.1 * faceWidth, 280,
350 - 0.1 * faceWidth, 280, 355 - 0.1 * faceWidth, fangP3);
// Creates right fang
fill(lipColorR, lipColorG, lipColorB);
rectMode(CENTER);
// Centers rectangle
rect(width / 2, height / 2 + 40,
lipWidth, lipHeight);
// Creates and chooses parameters of lip
fill(eyeColorR, eyeColorG, eyeColorB);
ellipse(eyeLX, height / 2, eyeWidth, eyeHeight);
// Creates a left eye for the face
fill(eyeColorR, eyeColorG, eyeColorB);
ellipse(eyeRX, height / 2, eyeWidth, eyeHeight);
// Creates a right eye for the face
fill(noseColorR, noseColorG, noseColorB);
triangle(noseP1X, noseP1Y, noseP2X, noseP2Y, noseP3X, noseP3Y);
// Creates triangle as a nose
}
function mousePressed() {
// Shape randomizers
eyeWidth = random(10, 50);
eyeHeight = random(10, 50);
// Randomizes the width and height of the eyes
faceWidth = random(100, 200);
faceHeight = random(100, 200);
// Randomizes the width and height of the face
lipWidth = random(75, 150);
lipHeight = random(5, 15);
// Randomizes the width and height of the lip
hornX = random(150, 250);
hornY = random(50, 150);
// Randomizes the last poing of the horn
noseP1X = random(305, 315);
noseP1Y = random(255, 265);
// Randomizes the 1st point of the nose
noseP2X = random(315, 325);
noseP2Y = random(245, 255);
// Randomizes the 2nd point of the nose
noseP3X = random(325, 335);
noseP3Y = random(255, 265);
// Randomizes the 3rd point of the nose
fangP3 = random(300, 400);
// Randomizes the bottom of the fang
// Color Randomizers
faceColorR = random(0, 255);
faceColorG = random(0, 255);
faceColorB = random(0, 255);
// Randomizes the color of the face
eyeColorR = random(0, 255);
eyeColorG = random(0, 255);
eyeColorB = random(0, 255);
// Randomizes the color of the eyes
noseColorR = random(0, 255);
noseColorG = random(0, 255);
noseColorB = random(0, 255);
// Randomizes the color of the nose
lipColorR = random(0, 255);
lipColorG = random(0, 255);
lipColorB = random(0, 255);
// Randomizes the color of the lip
hornColorR = random(0, 255);
hornColorG = random(0, 255);
hornColorB = random(0, 255);
// Randomizes the color of the horns
fangColorR = random(0, 255);
fangColorG = random(0, 255);
fangColorB = random(0, 255);
// Randomizes the color of the fangs
}
Working on this project was an interesting experience for me. I started out by just creating a regular face, and sort of hit a creativity block after that. I decided that it would be cool if the colors would constantly change against a black background so I made each color a variable. Finally, I decided to give the face fangs and horns in order to increase the variability, as well as make it more visually interesting.