Project-02-Variables-Face

sketch
sketch-13.js


var eyeSize = 20;
var faceWidth = 100;
var faceHeight = 200;
var Rf;
var Gf;
var Bf;
var Re;
var Ge;
var Be;
var rect1y=(480/2-100);
var rect2y=(480/2-130);


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

}

function draw() {
    background(200,100,150);
    //face
    rectMode(CENTER);
    fill(Rf,Gf,Bf);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    var eyeLX = width / 2 - faceWidth * 0.30;
    var eyeRX = width / 2 + faceWidth * 0.30;
    //eyes
    fill(Re,Ge,Be);
    ellipse(eyeLX, (height / 2-40), eyeSize, eyeSize);
    ellipse(eyeRX, (height / 2-40), eyeSize, eyeSize);
    ellipse()
    //mouth
    p1 = {x: 200, y: 200}, p2 = {x:350, y:275 };
    p3 = {x:290, y: 275}, p4 = {x: 200, y: 200};
    noFill();
    stroke(0);
    curve(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y);
    //nose
    q1 = {x: 230, y: 200}, q2 = {x:350, y:240 };
    q3 = {x:310, y: 260}, q4 = {x: 200, y: 200};
    curve(q1.x, q1.y, q2.x, q2.y, q3.x, q3.y, q4.x, q4.y);


}

function mousePressed() {
    //when clicked the face and eyes change shape and color
    //color
    Rf= random(0,255);
    Gf=random(0,255);
    Bf=random(0,255);
    Re= random(0,255);
    Ge=random(0,255);
    Be=random(0,255);
    //shape
    faceWidth = random(100, 250);
    faceHeight = random(150, 300);
    eyeSize = random(10, 50);
    rect2y=(2-(faceWidth/2));
    rect1y=((width/2),(faceHeight-10),60,80);

}

I had trouble figuring out curves and uploading the document.

Project-02-Variable-Face

sketch-98.js

var hairColor = "black" 
var cheekHeight = 160;
var cheekWidth = 160;
var jawHeight = 320;
var jawWidth = 160;
var chinY = jawHeight+100;
var chinX = 320;
var skin = (229,160,115);
var eyeWidth = 64;
var squint = 24;
var eyeBLX = 320-cheekWidth/2;
var eyeBY = cheekHeight; 
var eyeBRX = eyeBLX+cheekWidth;
var eyeY = eyeBY +50 ;
var eyeLX = eyeBLX;
var eyeRX = eyeBRX;
 
var eyeSize = 75;
var irisSize = eyeSize/2;
var pupilSize = irisSize/4;
var eyeColor = "blue"
var noseWidth=25;
var noseLength=80;
var nostrilWidth = noseWidth+20

var mouthHeight = jawHeight
var mouthWidth = jawWidth - 60
var lipsize = 10

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

function draw() {
    background(180,23,230);
    //noStroke();
    strokeWeight(3);

   //hair
    fill(hairColor);
    ellipse(width/2,height/2,500,500);

    fill(skin);
    beginShape();
    curveVertex(width/4,100);
    curveVertex(width/4,100);//left temple

    curveVertex(cheekWidth,cheekHeight);
    curveVertex(jawWidth, jawHeight);

    curveVertex(chinX,chinY);

    curveVertex((width-jawWidth),jawHeight); 
    curveVertex((width-cheekWidth),cheekHeight);
    curveVertex(width-(width/4),100);

    curveVertex(width-(width/4),100);//right temple
    endShape();

    //eyebrows
    fill(hairColor);
    beginShape();
    vertex(eyeBLX-eyeWidth,eyeBY);
    bezierVertex(eyeBLX,eyeBY,eyeBLX+(eyeWidth/2),eyeBY+squint,eyeBLX+eyeWidth,eyeBY);
    bezierVertex(eyeBLX,eyeBY,eyeBLX+(eyeWidth/2),eyeBY-squint,eyeBLX-eyeWidth,eyeBY);
    endShape();

    beginShape();
    vertex(eyeBRX-eyeWidth,eyeBY);
    bezierVertex(eyeBRX, eyeBY, eyeBRX+(eyeWidth/2),eyeBY-squint,eyeBRX+eyeWidth,eyeBY);
    bezierVertex(eyeBRX,eyeBY,eyeBRX+(eyeWidth/2),eyeBY+squint, eyeBRX-eyeWidth,eyeBY);
    endShape();

    //eyes
   fill("white"); //eyeball
   ellipse(eyeLX,eyeY,eyeSize*1.2,irisSize);
   ellipse(eyeRX,eyeY,eyeSize*1.2,irisSize);

   fill(eyeColor); //iris
   ellipse(eyeLX,eyeY, irisSize, irisSize);
   ellipse(eyeRX, eyeY,irisSize,irisSize);

   fill("black");//pupils
   ellipse(eyeLX,eyeY, pupilSize, pupilSize);
   ellipse(eyeRX,eyeY,pupilSize,pupilSize);

   //nose
   strokeWeight(2);
   fill(skin);
   beginShape();
   curveVertex(noseWidth+(width/2),cheekHeight+30);
   curveVertex(noseWidth+(width/2),cheekHeight+30);
   curveVertex((width/2)+nostrilWidth,cheekHeight+noseLength+30);
   curveVertex((width/2)+noseWidth, cheekHeight+noseLength+30);

   curveVertex(width/2,noseLength+cheekHeight+40);

   curveVertex((width/2)-noseWidth,noseLength + cheekHeight+30);
   curveVertex((width/2)-nostrilWidth,noseLength + cheekHeight+30);
   curveVertex((width/2)-noseWidth,cheekHeight+30);
   curveVertex((width/2)-noseWidth,cheekHeight+30);
   endShape();
   
   //mouth 

   fill(255,10,10);

   beginShape(); //lower lip
   curveVertex((width/2)-mouthWidth,mouthHeight);
   curveVertex((width/2)-mouthWidth,mouthHeight);
   curveVertex((width/2)-(mouthWidth/2),mouthHeight+(lipsize/2));
   curveVertex(width/2, mouthHeight+lipsize);
   curveVertex((width/2)+(mouthWidth/2),mouthHeight+(lipsize/2));
   curveVertex((width/2)+mouthWidth,mouthHeight);
   curveVertex((width/2)+mouthWidth,mouthHeight);
   //upper lip
   curveVertex((width/2)-mouthWidth,mouthHeight);
   curveVertex((width/2)-mouthWidth,mouthHeight);

   curveVertex((width/2)-(mouthWidth/2), mouthHeight-(lipsize));
   curveVertex(width/2,mouthHeight-lipsize);
   curveVertex((width/2)+(mouthWidth/2), mouthHeight-(lipsize));

   curveVertex((width/2)+mouthWidth,mouthHeight);
   curveVertex((width/2)+mouthWidth,mouthHeight);
   endShape();

}

function mousePressed() {
    cheekHeight = height/3 + random(-20,20);
    cheekWidth = width/4 + random(-20,20);
    jawHeight = (height/4) + random(150,200);
    jawWidth = (width/4) + random(0,100);

    chinY = jawHeight+random(100,200);
    eyeWidth = width/10 + random(0,25);
    squint = height/20 + random(-20,20);
    
    eyeBY = cheekHeight + random(-10,10);
    eyeBRX = eyeBLX + cheekWidth + random(-10,10);
    hairColor = (random(0,255),random(0,255),random(0,255));

    eyeY = eyeBY + random(30,75);
    eyeSize = random(40, 100);
    irisSize = random((eyeSize/2), eyeSize/10);
    //pupilSize = ranodom((irisSize/4),irisSize/20);
    eyeColor = ((random(0,255),random(0,255),random(0,355)));

    noseWidth = random(10,40);
    noseLength = random(10,100);
    nostrilWidth = noseWidth + random(10,40);

    mouthHeight = jawHeight + random(20,100);
    mouthWidth = random(10,90);
   // lipSize = random(5,20);
    
    skin = random("chocolate", "coral", "khaki","LightSalmon", "moccasin");
}
  

 

Upon doing this project, I realized that I had issues with scaling things in the way that I wanted them. In order to correct that, I utilized the randomized feature to click through facial features that would fit and not fit. Eventually, I decided to have my faces look comedic more than anything else. I also had trouble with randomizing colors.

SEckert-Project-02-Variable Face

seckert-project-02

var hairWidth = (400);
var hairHeight = (420);
var hairColor = ('#A62BFF');
var eyeColor = ('#000000');
var eyeSize = (10);
var mouthSize = (10);
var eyebrowHeight = 50;
var backgroundColor = 255;


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

function draw() {

	background(backgroundColor);
  noStroke();
//hair
  fill(hairColor);
    ellipse ((width/2), (height/2), hairWidth, hairHeight);
//face
  fill('#F0DEFF');
    ellipse((width/2), (height/2), 250, 250);
//hair bangs
  fill(hairColor);
    ellipse ((width/2), ((height/2)-125), 150, 100);
//eyes
  fill(eyeColor);
    ellipse (((width/2)-50), ((height/2)-40), eyeSize, eyeSize);
    ellipse (((width/2)+50), ((height/2)-40), eyeSize, eyeSize);
//eyebrows
  fill (hairColor);
    rect (((width/2)-65), ((height/2)-eyebrowHeight), 30, 5);
    rect (((width/2)+(35)), ((height/2)-eyebrowHeight), 30, 5);
//mouth
  fill ('#000000');
    ellipse ((width/2), ((height/2)+30), mouthSize, mouthSize);
//nose
  fill ('#EBBAFF');
    ellipse ((width/2), (height/2), 30, 10);

  //noLoop()
}

function mousePressed() {
    hairWidth = random(400, 600);
    hairHeight = random(420, 620);
    hairColor = random(255);
    eyeColor = random(255);
    eyeSize = random(10, 30);
    mouthSize = random(10, 50);
    eyebrowHeight = random(50, 70);
    backgroundColor = random(0-255);
}

This project made me very aware of how little I remembered about programing in colors, particularly randomizing them. I’m sure that with more tinkering I could have added a lot more variety but I am happy with it as is.

Project-02-Variable Face

sketch

//Naomi Shimada
//15-104 Section D
//Project-02

       
   var r = 255;

   var g = 134;

   var b = 5; 

   var l = 110;   

   var c = 50;

   var h = 50;

   var e = 150;

   var b = 155;

   var d = 19;

   var z = 30;

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


function draw(){

     
    // REGULAR FACE CODE

       fill(83,39,5);              //hair
    ellipse(300,300,475,900);

    
       strokeWeight(0);
       fill(229,171,110);             //face
    ellipse(300,200,300,400);
    
        strokeWeight(0);
        fill(255);
    ellipse(240,190,50,40);         //white of the eye, right
    
        strokeWeight(0);
        fill (159,56,d);           //brown
    ellipse(240,190,z,z);
        
        strokeWeight(0);
        fill(217,155,88);         //bridge of the nose
    triangle(305,190,330,260,275,260); 

        strokeWeight(0);
        fill(253,208,229);            //cheek L
    rect(200,225,h,c);
  
        strokeWeight(0);
        fill(253,208,229);                   //cheek R
    rect(350,225,c,h);

        fill(83,39,5);                //hair swoop
    ellipse(330,50,250,e);

        strokeWeight(7);           //Left eyebrow 1
        stroke(83,39,5); 
    line(330,165,355,155);
        
        strokeWeight(7);           //Left eyebrow 2
        stroke(83,39,5); 
    line(355,155,380,155);

        strokeWeight(7);           //Left eyebrow 3
        stroke(83,39,5); 
    line(380,155,400,165);

        strokeWeight(0);         //neck
        fill(229,171,110); 
    rect(250,350,100,300);

    strokeWeight(0);
        fill(r,g,b);            //barrett 1
    ellipse(470,100,20,20);

        stroke(r,g,b);
        strokeWeight(0);           //barrett L
    triangle(480,95,500,70,520,110);

        stroke(226,52,123);
        strokeWeight(0);           //barrett R
    triangle(462,105,420,90,435,130);

        strokeWeight(10);
        stroke(83,39,5);          //ribbon L
    line(470,100,460,140);

        strokeWeight(9);
               //ribbon R
    line(470,100,500,135);

        strokeWeight(0);
                  //barrett 1
    ellipse(470,100,20,20);
    
        strokeWeight(9);
        stroke(r,g,b);          //ribbon L Yellow
    line(470,100,500,140);


        strokeWeight(9);                     //ribbon R Color
    line(470,100,540,135);

      
        strokeWeight(0);         //body
        fill(g,r,b); 
    ellipse(300,500,300,150);


    //hair flow
   

        strokeWeight(60);                        //flowing hair brown 
        stroke(83,39,5);
    curve(0,0,478,170,600,400,1000,600);

        fill(83,39,5);                //filler
    ellipse(550,500,195,275);

        fill(83,39,5);                      //hair filler
    ellipse(525,350,125,225);


        strokeWeight(70);              //black flowing hair line
        stroke(0);
    curve(0,0,70,465,480,600,600,600);

   
        strokeWeight(0);           //winking eye
        fill(229,171,110);
    ellipse(370,190,55,45); 

        strokeWeight(7);                        //wink of the eye
        stroke(0);
    curve(10,100,335,190,390,190,190,300);

        //eyelashes starting at inner corner
        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(332,190,333,195,336,190);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(336,190,339,197,340,190);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(336,190,339,202,341,191);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(341,190,344,202,347,191);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(347,192,350,203,353,192);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(353,193,356,204,359,193);
        
        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(360,194,363,205,366,194);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(366,194,369,205.5,372,194);

        strokeWeight(3);
        stroke(0);
    triangle(372,194,375,205,378,194);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(378,193,381,204,384,193);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(384,192,387,202,390,192);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(390,190,393,200,396,191);

        strokeWeight(3);
        stroke(0);
        fill(0);
    triangle(396,190,399,197,402,188);

        strokeWeight(0);          //lower lip
        fill(229,171,l);
    quad(240,310,370,310,355,335,255,335);

        strokeWeight(2);
        stroke(229,171,l);         //upper lip R
        fill(229,171,l);
    triangle(240,310,290,300,305,310);
 
        strokeWeight(2);  
        stroke(229,171,l);         //upper lip L
        fill(229,171,l);
    triangle(305,310,330,300,370,310);

        strokeWeight(10);              //smile
        stroke(201,42,88);
    line(240,310,370,310);

        strokeWeight(10);              //smile
        stroke(201,42,88);
    curve(0,0,240,310,370,310,420,300);

        strokeWeight(0);              //teeth
        fill(225);
    quad(248,310,370,310,335,317,262,317);

        strokeWeight(8);           //Undos original Right eyebrow 2
        stroke(229,171,110); 
    line(250,155,225,155);

        strokeWeight(9);           //Undos original Right eyebrow 3
        stroke(229,171,110); 
    line(225,155,205,165);

        strokeWeight(7);           //Right eyebrow 1
        stroke(83,39,5); 
    line(275,165,250,155);

        strokeWeight(7);           //Right eyebrow 2
        stroke(83,39,5); 
    line(250,155,215,b);

        strokeWeight(7);           //Right eyebrow 3
        stroke(83,39,5); 
    line(215,b,205,155);
     
    
}

function mousePressed(){
 
         r = random(0,255);

         g = random(0,255);

         b = random(0,255);

         l = random(100,120);

         c = random(10,85);

         h = random(10,85);

         e = random(150,240);     
        
         b = random(120,155);
   
         d = random(0,105);

         z = random(30,40);
       

    }

I had a lot of fun with this program.  It took a while to make sure draw the original face but once I got into the rhythm of creating the variables, the random variability was fairly easy.

SadieJohnson-Project02-VaribleFaces

variablefaces

/*
*Sadie Johnson
*15-104 Section C
*sajohnso@andrew.cmu.edu
*Project-02
*This program draws random faces
*/

var eyeWidth = 20;
var eyeHeight = 20;
var faceWidth = 100;
var faceHeight = 150;
var earSize = 30; 
var x = 10;
var lensSize = 40;
var hairWidth = 100;
var hairHeight = 100;
var mouthSize = 30;

function setup() {
    createCanvas(640, 480);
    g = color(120);
    b = color(120);
    
    //rgb colors for the hair 
    //i wanted to put them in  certain range
    h = color(10);
    i = color(15);
    j = color(20);
}

function draw() {
    //fill();
    background(234,237,216);
    //draw background triange
    fill(140, g, b, 127); //color  
    triangle(0, 0, 0, 480, 640, 480);

    //draw hair
    fill (h,i,j); //random hair color
    ellipse(width / 2, height / 2 - 30, hairWidth,  hairHeight);

    //draw ears
    fill (168, 133, 73);
    var earLX = width / 2 - faceWidth / 2
    var earRX = width / 2 + faceWidth / 2
    ellipse(earLX, height / 2 + x, earSize, earSize);
    ellipse(earRX, height / 2 + x, earSize, earSize);

    //draw face
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);

    //draw eyes  
    fill(225);
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    ellipse(eyeLX, (height/2) -5, eyeWidth, eyeHeight);
    ellipse(eyeRX, (height/2) -5, eyeWidth, eyeHeight);

     //draw glasses
     fill(140, g, b, 127); //color glasses 
     ellipse(eyeLX, height/2 + x, lensSize, lensSize);
     ellipse(eyeRX, height/2 + x, lensSize, lensSize);
     //noFill();
        //draw bridge of glasses
    var arcStart = (width/2) - (eyeWidth*.25)
    var arcFin = (width/2) + (eyeWidth*.25)
    line(arcStart, height/2, arcFin, height/2);

    //draw mouth
    fill(89,23,23);
    arc(width/2, height/2 + 40, mouthSize, mouthSize, 0, PI+QUARTER_PI, PIE);

    }

function mousePressed() {
    // when the user clicks, these variables are reassigned
    // to random values within specified ranges. For example,
    // 'faceWidth' gets a random value between 75 and 150.
    faceWidth = random(100, 175);
    faceHeight = random(100, 200);
        eyeWidth = random(10, 30);
    eyeHeight = random(10, 30);
    earSize = random(15,40);
    x = random(0,20);
    g = random(0,225);
    b = random(0,225);
     hairWidth = random(100,175);
 hairHeight = random(100,200);
    h = random(0,225);
    i = random(0,225);
    j = random(1,20);
    mouthSize = random(5,35);
    
}

The hardest part of this assignment by far was making sure that all of the features remained on the face- that is, that everything was controlled by interlocking variables and not “magic numbers”.

Generative Faces Project-02

I was trying to make the face resemble the style of characters from PowerPuff Girls and FairlyOdd Parents I really like the changing eye colors, which I did by replacing the g value in (r, g, b) with the variable eyeColor.

 

sketch index

//Arula Ratnakar
//Section C
//aratnaka@andrew.cmu.edu
//Generative Faces



var eyeSize = 20;
var faceWidth = 120;
var faceHeight = 150;
var pupil = 20//I said pupil but I meant iris
var mouth = 20
var hairWidth = 200
var hairHeight = 150
eyeColor = 7

function setup() {
    createCanvas(640, 480);
}
 
function draw() {
    background(170, 204, 235);
    noStroke ()
    ellipse (width /2, ((height/2)-20), hairWidth, hairHeight)//adds hair to the face
    fill (184, 151, 123)// colors the face
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    fill (0)
    ellipse (width/2, ((height/2)-50), 70, 70)
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    fill (255)
    ellipse(eyeLX, height / 2, eyeSize, eyeSize);
    ellipse(eyeRX, height / 2, eyeSize, eyeSize);
    fill (116,eyeColor, 183)
    ellipse (eyeRX, height /2, pupil, pupil)//adds right iris
    ellipse (eyeLX, height/2, pupil, pupil)//adds left iris
    fill(0)
    ellipse (eyeLX, height/2, pupil/2, pupil/2)//adds left pupil
    ellipse (eyeRX, height/2, pupil/2, pupil/2)//adds right pupil
    ellipse (width/2, 280, 30, mouth);//adds a mouth
   
}
 
function mousePressed() {
    faceWidth = random(100, 200);
    faceHeight = random(100, 160);
    eyeSize = random(20, 30);
    pupil = random (15, 20)
    mouth = random (1, 40)
    hairWidth = random (200, 350)
    eyeColor= random (1, 255)// changes the eyecolor


} 

JamesKatungyi-Project02-VariableFaces

jameskatungyi-project02-variablefaces

//James Katungyi
//Section A (Tuesdays 9:00)
//jkatungy@andrew.cmu.edu
//Project-02-Variable-Faces

var hairWidth = 240;
var hairHeight = 240;
var LEheight = 20;
var LEwidth = 60;
var REheight = 20;
var REwidth = 60;
var NoseWidth = 30;
var EyeBrowStartY = 305;
 
function setup() {
    createCanvas(480, 640);
    background(135);

}

function draw() {
    //hair
    fill(0);
    ellipse(width/2, 260, hairWidth, hairHeight);
    //face
    fill(175, 135, 0);
    stroke(110);
    strokeWeight(1);
    ellipse(width/2, height/2, 240, 320);
    //more hair
    fill(0);
    noStroke();
    ellipse(width/2, 200, 180, 90);
    //lashes
    stroke(0);
    strokeWeight(4);
    line(270, EyeBrowStartY, 330, 290); //Right brow
    line(210, EyeBrowStartY, 150, 290); //Left brow
    //eyes
    fill(222);
    ellipse(300, height/2, REwidth, REheight); //Right Eye
    ellipse(180, height/2, LEwidth, LEheight); //Left Eye
    fill(45);
    ellipse(300, height/2, 10); //Right pupil
    ellipse(180, height/2, 10); //Left pupil
    //nose
    stroke(240, 150, 0);
    strokeWeight(1);
    fill(200, 135, 0);
    ellipse(width/2, 350, NoseWidth, 60); //bridge
    ellipse(225, 372, 15); //right nostril
    ellipse(255, 372, 15); //left nostril
    //mouth
    stroke(0);
    strokeWeight(1);
    noFill(200, 135, 0);
    curveVertex(195, 400);
    curveVertex(210, 408);
    curveVertex(240, 415);
    curveVertex(270, 408);
    curveVertex(285, 400);
    endShape();
}
 
function mousePressed() {
    // when the user clicks, these variables are reassigned
    // to random values within specified ranges. For example,
    // 'faceWidth' gets a random value between 75 and 150.
    hairWidth = random(240, 360);
    hairHeight = random(240, 360);
    LEheight = random(10, 30);
    LEwidth = random(30, 60);
    REheight = random(10, 30);
    REwidth = random(30, 60);
    NoseWidth = random(20, 40);
    EyeBrowStartY = random(275, 305);
}

A sketch helped. The outcome was close… I had to tamper down initial ambitions.

variablefacedraft

Lydia Jin Project-02-Variable Face

sketch


var eyeSize = 20;
var faceWidth = 100;
var faceHeight = 150;
var mouthsize=30;
var nosesize=20;
var eyecolor=0;
var colorR=20;
var colorG=20;
var colorB=20;
var light1=20;
var light1X=10;
var light1Y=10;
var light2=50;
var light2X=250;
var light2Y=20;
var light3=100;
var light3X=400;
var light3Y=300;

function setup() {
    createCanvas(640, 480);
}
 
function draw() {
    background(colorR,colorG,colorB);
    fill(243,215,198);
    ellipse(width / 2, height / 2, faceWidth,  faceHeight);
    //face
    fill(0);
    rect(width/2-15,height/2-faceHeight/2,30,40);
    //hair
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    fill(eyecolor);
    ellipse(eyeLX, height / 2-15, eyeSize, eyeSize);
    ellipse(eyeRX, height / 2-15, eyeSize, eyeSize);
    //eyes\
    fill(247,196,152);
    ellipse(width/2,height/2,eyeSize-5,eyeSize+5);
    //nose
    fill(232,0,0);
    ellipse(width/2,height/2+50,nosesize,nosesize);
    //mouth
    fill(200);
    rect(width/2-faceWidth/2,height/2+faceHeight/2,faceWidth,200);
    //shirt (body)
    fill(163,98,81);
    ellipse(width/2,height/2+faceHeight/2+50,10);
    ellipse(width/2,height/2+faceHeight/2+100,10);
    //buttons
    fill(255,colorR,colorG,colorB);
    ellipse(light1X,light1Y,light1);
    ellipse(light2X,light2Y,light2);
    ellipse(light3X,light3Y,light3);
    //party lights

}
 
function mousePressed() {
    // when the user clicks, these variables are reassigned
    // to random values within specified ranges. For example,
    // 'faceWidth' gets a random value between 75 and 150.
    faceWidth = random(100, 200);
    faceHeight = random(150, 200);
    eyeSize = random(10, 30);
    mouthsize=random(10,50);
    nosesize=random(10,30);
    eyecolor=random(0,150);
    colorR=random(0,255);
    colorG=random(0,255);
    colorB=random(0,255);
    light1=random(0,200);
    light2=random(100,200);
    light3=random(0,80);
    light1X=random(0,50);
    light1Y=random(0,480);
    light2X=random(400,600);
    light2Y=random(0,480);
    light3X=random(420,600);
    light3Y=random(200,480)
}

This is Sushi Head Man at a party.

Project-02-Varying faces

sketch

//Sihan Dong
//sihand@andrew.cmu.edu
//Section B
//this program generates different faces of yound women


//setting up the variables and the default image (no mouse pressed)
var headpar = 150;
var mouthpar = 20;
var neckl = 50;
var bodwidth = 130;
var bodheight = 600;
var bulbstroke = 0;
var browarch = 40;
var eyestroke = 7;
var eyeht = 250;
var vertexX = 350;
var vertexY = 100;
var noi = 5;

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

function draw() {
  background(245,231,146);//creating the notebook effect
  var noteline1 = color(212,201,140);
  stroke(noteline1);
  line(0,40,480,40);
  line(0,80,480,80);
  line(0,120,480,120);
  line(0,160,480,160);
  line(0,200,480,200);
  line(0,240,480,240);
  line(0,280,480,280);
  line(0,320,480,320);
  line(0,360,480,360);
  line(0,400,480,400);
  line(0,440,480,440);
  line(0,480,480,480);
  line(0,520,480,520);
  line(0,560,480,560);
  line(0,600,480,600);
  var noteline2 = color(195,159,105);
  stroke(noteline2);
  line(80,0,80,640);
  line(85,0,85,640);

  var ballpt = color(52,57,136);//created the doodle face
  noFill();
  stroke(ballpt);
  strokeWeight(5);
  ellipse(290,250,headpar,1.25*headpar);//headshape
  ellipse(290-headpar/2+70,280,mouthpar,mouthpar);//mouthshape

  line(290,250+1.25*headpar/2,290, 250+1.25*headpar/2+neckl);//neckline_1
  line(290+noi,250+1.25*headpar/2,290+noi, 250+1.25*headpar/2+neckl);//neckline_2

  ellipse(290,250+1.25*headpar/2+neckl+bodheight/2,bodwidth,bodheight);//body
  ellipse(290,250+noi+1.25*headpar/2+neckl+bodheight/2,bodwidth-noi,bodheight-noi);

  arc(250,230,browarch,browarch,PI+QUARTER_PI, TWO_PI-QUARTER_PI);//left brow
  arc(320,230,browarch,browarch,PI+QUARTER_PI, TWO_PI-QUARTER_PI);//right brow

  strokeWeight(eyestroke);//eyes
  line (235,eyeht,255,eyeht);
  line (315,eyeht,335,eyeht);

  //a bulb will appear when the person gasps, so will the eyes open up
  // have fun clicking! :D
    if (mouthpar>35) {
      bulbstroke = 3;
      eyestroke = 25;
      strokeWeight(2);
      textSize(20);
      text("Eureka!",vertexX-150,vertexY-20);
      noFill();
      stroke(ballpt);//the bulb will not appear if the mouth is not open wide enough
      strokeWeight(bulbstroke);
      beginShape();
      vertex(vertexX,vertexY);
      vertex(vertexX+15,vertexY);
      vertex(vertexX+15,vertexY+20);
      vertex(vertexX, vertexY+20);
      endShape(CLOSE);
      line(vertexX,vertexY+10,vertexX+15,vertexY+10);
      ellipse(vertexX+15/2, vertexY-25,50,50);//the outer ellipse
      ellipse(vertexX+15/2, vertexY-15,15,30);//the inner ellipse
    }
    if (mouthpar<35) {
      bulbstroke = 0
      eyestroke = 7;
    }
}

//generating doodles
function mousePressed() {
  headpar = random(130,180);
  mouthpar = random(10,40);
  neckl = random (40,60);
  bodwidth = random (100,200);
  browarch = random (35,45);
  noi = random (-15,15);
  eyeht = random(245,255);
  //the light bulb shows up around the figure's head
  vertexY = random (80,120);
  vertexX = random (150,400);

}

This project was inspired by the ballpoint doodles I used to draw on my notes. I recreated the notebook background and the stroke color according to an online picture. A user can play with the doodle by clicking until the light bulb appears, signifying the “eureka” moment.

Owen Fox generative faces

generative-faces

//Owen Fox
//Section C
//olf@andrew.cmu.edu
//generative faces
var rectX = 300;
var rectY = 300;
var eyeX = 100;
var eyeY = 50;
var eyeball = 20;
var mW = 100;
var mH = 20;
var n = 25

function setup() {
    createCanvas(600, 600);
}

function draw() {
    var w = width/2;
    var h = height/2;
    background(120);
    //head
    fill("#ff0080");
    rectMode(CENTER);
    noStroke();
    rect(w,h,rectX,rectY);
    //eyes
    fill("#ffe6f2");
    ellipse(w-100,h,eyeX,eyeY);
    ellipse(w+100,h,eyeX,eyeY);
    //eyeballs
    fill("#660033");
    ellipse(200,300,eyeball,eyeball);
    ellipse(400,300,eyeball,eyeball);
    //nose
    fill("#e60073")
    quad(w-n,h-2*n,w+n,h-2*n,w+2*n,h+2*n,w-2*n,h+2*n);
    fill("#b30059");
    quad(w-n,h-2*n,w,h-2*n,w,h+2*n,w-2*n,h+2*n);
    //mouth
    fill("#ff99cc");
    rect(width/2,height/2+rectY/3,mW,mH,mH/2);

}

function mousePressed() {
    rectX = random(150, 450);
    rectY = random(150, 450);
    eyeX = random (50,150);
    eyeY = random (25,75);
    eyeball = random (10,30);
    n = random (15,35);
    mW = random (75,125);
    mH = random (15,35);
}