Project2-Variable-Face

sketch

//color
var colorA=255;
var colorB=240;
var colorC=178;
var skinA=242;
var eyeballcolorA=35;
var eyeballcolorB=39;
//size
var earsize=50;
var eyesize=88;
var nosesize=18;
var facesizeY=344;
var facesizeX=310;
//XY
var earY=276;
var eyeballLX=227;
var eyeballRX=eyeballLX+140;
var eyeballY=230;
var noseX=312;
var noseY=294;
var mouseLX=263;
var mouseLY=357;
var mouseRX=350;
var mouseRY=337;

function setup() {
    createCanvas(640, 480);
}

function draw() {
    background(180);

    //hair   
    fill(colorA,colorB,colorC);
    noStroke();
    arc(320,254,420,425,2*PI,2*PI);

    //ears
    fill(247,skinA,216);
    ellipse(163,earY,earsize,earsize);
    ellipse(462,earY,earsize,earsize);

    //neck
    rect(245,369,140,155);

    //face
    stroke(220);
    strokeWeight(3);
    ellipse(312,260,facesizeX,facesizeY);

    //eyes
    fill(255);
    stroke(1);
    strokeWeight(2);
    ellipse(237,243,61,eyesize);
    ellipse(377,243,61,eyesize);

    //eyeballs
    fill(58,eyeballcolorB,eyeballcolorA);
    stroke(1);
    ellipse(eyeballLX,eyeballY,33,48);
    ellipse(eyeballRX,eyeballY,33,48);

    //nose
    noFill();
    stroke(1);
    ellipse(noseX,noseY,nosesize,nosesize);

    //mouse
    stroke(1);
    line(mouseLX,mouseLY,mouseRX,mouseRY);

    //hairban
    fill(colorA,colorB,colorC);
    noStroke();
    ellipse(396,125,150,75);

    //brows
    noFill();
    stroke(1);
    //browLeft
    beginShape();
    curveVertex(218,164);
    curveVertex(238,165);
    curveVertex(250,168);
    curveVertex(261,176);
    curveVertex(280,199);
    endShape();
    //browRight
    beginShape();
    curveVertex(350,193);
    curveVertex(351,190);
    curveVertex(354,184);
    curveVertex(364,176);
    curveVertex(375,171);
    curveVertex(403,167);
    endShape();
}

function mousePressed() {
	//color
	colorA = random(0,255);
	colorB = random(220,240);
	colorC = random(160,200);
	skinA = random(221,242);
	eyeballcolorA=random(0,255);
	eyeballcolorB=random(0,255);
	//size
	earsize = random(50,70);
	eyesize = random(80,120);
	nosesize=random(15,25);
	facesizeY=random(320,360);
	facesizeX=random(270,330);
	//XY
	earY = random(250,285);
	eyeballLX=random(227,250);
	eyeballRX=eyeballLX+140;
	eyeballY=random(230,250);
	mouseLX=random(265,290);
	mouseLY=random(340,365);
	mouseRX=random(340,360);
	mouseRY=random(325,360);
}

   


I used simple geometries to create this face. Hair colour, eye size, eyeball colour and size, mouth, nose and ears are set random each time mouse is clicked.

Leave a Reply