efleischer -02 – project
/*
eliana fleischer
efleisch
section e
*/
//Global variables to be used across different functions
//these are all the variables that will be used to make the initial face before randomization.
var eyewidth = 20;
var eyeheight = 20;
var faceshape = 1;
var facewidth = 200;
var faceheight = 200;
var eyecolorR = (15);
var eyecolorG = (255);
var eyecolorB = (100);
var noseheight = 5;
var nosewidth = 5;
var iris = 10;
var skinR = 100;
var skinG = 100;
var skinB = 100;
var x = 320;
var y = 240;
function setup() {
createCanvas(640, 480);
background(220);
}
function draw() {
background(eyecolorR, eyecolorG, eyecolorB); // sets background to the random variables for the eye color
//faces
push();
fill(skinR,skinG, skinB);
noStroke()
if (faceshape == 1){
face1 = ellipse(x,y, facewidth, faceheight); //draws ellipse face
} else {
face2 = rect(x - facewidth /2 , y - faceheight /2 , facewidth , faceheight); //draws square face
}
//nose
fill(255, 204, 255)
nose = ellipse(x, y, noseheight, nosewidth); //draws nose at the center of the face
pop();
//eyes
fill(255); //white fill for irises
strokeWeight(2); // outline for eyes
Leye = arc(x - facewidth / 5, y - faceheight / 5, eyewidth, eyeheight, 0, PI + QUARTER_PI, OPEN); //draws left eye
Reye = arc(x + facewidth / 5, y - faceheight / 5, eyewidth, eyeheight,100, PI + QUARTER_PI, OPEN); //draws right eye
//iris
fill(eyecolorR, eyecolorG, eyecolorB); // fills in the irises with the random eye color
Riris = ellipse(x + facewidth / 5, y - faceheight / 5, iris, iris)
Liris = ellipse(x - facewidth / 5, y - faceheight / 5, iris, iris);
//mouth
strokeWeight(1);
mouth = line(x - facewidth / 5, y + faceheight / 5, x + facewidth / 5, y + faceheight / 5 );
}
function mousePressed() {
// when the user clicks, these variables are reassigned
facewidth = random(100, 200);
faceheight = random(100, 200);
eyewidth = random(15, 45);
eyeheight = random(10, 45);
nosewidth = random(5,15);
noseheight = random(5,15);
iris = random(1, 7);
eyecolorR = random(0,255);
eyecolorG = random(0,255);
eyecolorB = random(0,255);
faceshape = int(random(1,3));
skinR = random(100,200);
skinG = random(100,200);
skinB = random(100,200);
}
The most difficult part of this project for me was figuring out a creative solution to increase variability and actually make unique and distinct images through randomization.