Project 02 – face generator – srauch

This face generator makes lots of cool folks to chill with! About half of the characteristics of each person — for instance, the shirt size and color, the background, and the skin tone — are completely random, while other components such as the eye color or headwear/hairstyle are randomly selected from a list of options. Writing this code really dusted off the ol’ middle school algebra. Some of said algebra is visible in the positively chicken-scratch notebook hieroglyphs I made while figuring out some of the first few variables. Once I had those established, though, I found I wasn’t writing anything down, instead just relying on the variables I’d already defined to write the next ones–quite the departure from how I worked through last week’s homework.

sketch

var width = 480;
var height = 640;

//background color
var backgroundR = 100;
var backgroundG = 0;
var backgroundB = 0;

//shirt color and size
var shirtR = 200;
var shirtG = 200;
var shirtB = 0;
var shirtWide = 400;
var shirtTall = 100;

//skintone
var skinR = 47;
var skinG = 39;
var skinB = 32;

//neck
var neckTall = 250;
var neckWide = 100;
var neckY = 200;

//head
var headWide = 250;
var headTall = 300;
var headX = width/2;
var headY = 200;

//ears
var earSize = 40;

//eyes
var eyeColor = 1;
var eyeSize = 30;
var eyeDistance = 30;

//nose
var noseLong = 20;
var noseWide = 10;

//mouth
var mouthSelector = 1;

//eyebrows
var eyebrowTall = 30;
var eyebrowWide = 30;
var eyebrowColorSelector = 1;
var eyebrowWeight = 10;

//hair
var hairstyle = 1;

function setup() {
    createCanvas(480, 640);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
}

function draw() {
    noStroke();
    background(backgroundR, backgroundG, backgroundB);

    // sleeve location variables -- have to be here (not global) so will update with new shirtWide values 
    var shirtCornerStar = ((width-shirtWide)/2)+((shirtWide/4)/2); //x coord of starboard sleeve
    var shirtCornerPort = width-shirtCornerStar; //x coord of port sleeve

    //shirt
    fill(shirtR, shirtG, shirtB);
    //rect(((width-shirtWide)/2), (height-shirtTall), shirtWide, shirtTall); 
    rect(shirtCornerStar, (height-shirtTall), (shirtWide-(shirtWide/4)), shirtTall);

    //sleeves
    fill(shirtR-20, shirtG-20, shirtB-20); //makes sleeves slightly darker than shirt
    triangle(shirtCornerStar, (height-shirtTall), shirtCornerStar, height, (shirtCornerStar-((shirtWide/4)/2)), height); //starboard sleeve
    triangle( shirtCornerPort, (height-shirtTall), shirtCornerPort, height, (shirtCornerPort+((shirtWide/4)/2)), height); //port sleeve

    //neck
    neckWide = shirtWide/3
    neckY = height-neckTall-shirtTall+(shirtTall/6);
    fill(skinR-20, skinG-20, skinB-20);
    rect(width/2-neckWide/2, neckY, neckWide, neckTall);
    ellipse(width/2, neckY+neckTall, neckWide, neckTall/4);

    //head
    headX = width/2
    headY = neckY
    fill(skinR, skinG, skinB);
    ellipse(headX, headY, headWide, headTall);

    //ears
    fill(skinR-10, skinG-10, skinB-10);
    ellipse(headX-(headWide/2), headY, earSize, earSize*1.5); //starboard ear
    ellipse(width-(headX-(headWide/2)), headY, earSize, earSize*1.5); //port ear

    //redraw head to cover ears, theres prob a better way to do this but ears rely on the head variables
    fill(skinR, skinG, skinB);
    ellipse(headX, headY, headWide, headTall);

    //nose (length and width)
    strokeWeight(noseWide);
    stroke(skinR, skinG-20, skinB-20);
    line(headX, headY, headX, headY+noseLong);
    noStroke();

    //eyes (color and distance from center of head)
    if (eyeColor <= 1) {
        fill(54, 43, 17); //brown
    } else if (eyeColor <= 2) {
        fill(52, 95, 45); //green
    } else if (eyeColor <= 2.8) {
        fill(13, 200, 200); //blue
    } else {
        fill(255, 20, 0); //red!
    }
    ellipse((width/2)-eyeDistance, headY, eyeSize);
    ellipse((width/2)+eyeDistance, headY, eyeSize);


    //mouth (arc of different size and stroke color)
    if (mouthSelector <= 1) { //open smile
        fill(61, 32, 31);
        arc(headX, headY+noseLong*2, headWide/3, headTall/4, radians(0), radians(180));
    } else if (mouthSelector <= 2) { //closed smile
        noFill();
        stroke(skinR+20, skinG-20, skinB-20);
        strokeWeight(20);
        arc(headX, headY+noseLong*2, headWide/3, headTall/5, radians(10), radians(170));
        noStroke();
    } else { //bubblegum
        fill(40, 0, 0);
        ellipse(headX+10, headY+(headTall/2)-(headTall/6), 30); //mouth
        fill(238, 168, 234, 70); //pink transparent
        ellipse(headX+10, headY+(headTall/2)-(headTall/6), 175, 175); //bubble1
        ellipse(headX+10, headY+(headTall/2)-(headTall/6), 180, 180); //bubble 2
        fill(255, 240, 240, 90);
        ellipse(headX+40, headY+(headTall/2)-headTall/3, 30, 30); //highlight
    }

    //and finally, hair!
    if (hairstyle <=1) { //bald
        //do nothing
    } else if (hairstyle <=2) { //beanie
    strokeWeight(12);
    strokeCap(ROUND);
        if (hairstyle <= 1.3){
            fill(168, 47, 47); //red hat
            stroke(168-10, 47-10, 47-10);
        } else if (hairstyle <=1.6) {
            fill(200 , 120, 218); //pink hat
            stroke(200-10, 120-10, 218-10);
        } else {
            fill(86, 93, 200); //perriwinkle hat
            stroke(86-10, 93-10, 200-10);
        }
        arc(headX, headY-(headTall/2)+40, headWide+5, headTall-60, radians(180), radians(360));
        rect(headX-(headWide/2)-10, headY-(headTall/2)+40, headWide+20, 60);
    } else { //bowl cut
        if (hairstyle <= 2.3){
            fill(45, 40, 30); //dark brown
            stroke(45, 40, 30);
        } else if (hairstyle <=2.8) {
            fill(130, 96, 57); //light brown
            stroke(130, 96, 57);
        } else if (hairstyle <=2.9 & skinR > 80 && skinG > 80 && skinB >30) {
            fill(222, 129, 25); //red
            stroke(222, 129, 25);
        } else {
            fill(25, 183, 222); //blue
            stroke(25, 183, 222);
        }
        arc(headX, headY-headY/4, headWide+5, headTall-60, radians(180), radians(360));
    }

    //eyebrows
    if (eyebrowColorSelector <=1) {
        stroke(40, 35, 20); //dark brown
    } else if (eyebrowColorSelector <=2) {
        stroke(230, 230, 138); //blonde
    } else {
        stroke(140, 230, 200); //blue
    }

    noFill();
    strokeWeight(eyebrowWeight);
    arc((width/2)-eyeDistance, headY-eyebrowTall, eyebrowWide, 20, radians(200), radians(340));
    arc((width/2)+eyeDistance, headY-eyebrowTall, eyebrowWide, 20, radians(200), radians(340));
    noStroke();

}

function mousePressed() {
    //background color change
    backgroundR = random(0, 255);
    backgroundG = random(0, 255);
    backgroundB = random(0, 255);

    //shirt color and size change
    shirtR = random(0, 255);
    shirtG = random(0, 255);
    shirtB = random(0, 255);
    shirtWide = random((width-(width/3)), (width-20));
    shirtTall = random((height/6), (height/4));

    //neck and skin changes
    skinR = random(60, 200);
    skinG = random(skinR, skinR-10);
    skinB = random(skinR-20, skinR-30);
    neckTall = random(200, 250);

    //head
    headWide = random(neckWide+100, neckWide+150);
    headTall = random(headWide, headWide*1.4);
    earSize = random(50, 60);

    //eyes
    eyeColor = random(0,3); 
    eyeSize = random(20, 40);
    eyeDistance = random(30, headWide/2-30);

    //nose
    noseLong = random(headTall/10, headTall/6);
    noseWide = random(25, 40);

    //mouth
    mouthSelector = random(0, 3);

    //eyebrows
    eyebrowColorSelector = random(0,2.1);
    eyebrowWeight = random(10, 18);
    eyebrowTall = random(20, 40);

    //hair
    hairstyle = random(0,3);
}

Project-02: Variable Faces; Face Variables

This project displays monkey’s emotions and also uses animations like the monkey’s eyes shaking and the monkey shedding tears.

Ideation
//Alicia Kim
//Section B

var w = 26+(1/3);
var h = 26+(1/3);
var eyeWidth = 52+(2/3)
var eyeHeight =79
var v= 1
var r=255
var g=223
var b= 196
var change =0
var tear=0
var eyew=0
var eyeh=0


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

function draw() {
    // background(180);
//normal happy
    if (v==1){
    tear=0
    background(245,245,220);// pastel yellow
    //ears
        fill(255,223,196); //skin
        ellipse(3.7*w, 11*h, 4*w, 3*h);
        ellipse(14.2*w,11*h, 4*w, 3*h);

    //inner ears //pink
        fill(222,165,164);
        ellipse(4*w, 11.2*h, 2*w, 2*h);
        ellipse(14*w,11.2*h, 2*w, 2*h);
        r=255;
        g=223;
        b=196;
    }
//surprised
    else if (v==2){
        background(153,153,204);// purple
    //ears
        fill(255,223,196); //skin
        ellipse(3.7*w, 11*h, 6*w, 1.5*3*h);
        ellipse(14.2*w,11*h, 6*w, 1.5*3*h);

    //inner ears //pink
        fill(222,165,164);
        ellipse(4*w, 11.2*h, 3*w, 3*h);
        ellipse(14*w,11.2*h, 3*w, 3*h);
        r=255;
        g=223;
        b=196;

    }
// shy
    else if (v==3){
        background(250,218,221); //shy pink
    //ears
        fill(255,204,203); //baby pink
        ellipse(3.7*w, 11*h, 4*w, 3*h);
        ellipse(14.2*w,11*h, 4*w, 3*h);

    //inner ears //pink
        fill(222,165,164);
        ellipse(4*w, 11.2*h, 2*w, 2*h);
        ellipse(14*w,11.2*h, 2*w, 2*h);

        r=252;
        g=202;
        b=191;

    }
// sad
    else if (v==4){
        background(100);
    //ears
        fill(255,223,196); //skin
        ellipse(3.7*w, 11*h, 4*w, 3*h);
        ellipse(14.2*w,11*h, 4*w, 3*h);

    //inner ears //pink
        fill(222,165,164);
        ellipse(4*w, 11.2*h, 2*w, 2*h);
        ellipse(14*w,11.2*h, 2*w, 2*h);

        r=255;
        g=223;
        b=196;

    }

//face outline
    strokeWeight(1);
    fill(155,103,60);
    beginShape();
  
    curveVertex(7*w,2*h);
    curveVertex(7*w,2*h);
    curveVertex(8*w,4.5*h);
    curveVertex(10*w,4.6*h);
    curveVertex(13*w,5*h);
    curveVertex(15.5*w,7*h);
    curveVertex(14*w,11*h);
    curveVertex(16*w,14*h);
    curveVertex(13*w,16*h);
    curveVertex(9.5*w,16.5*h);
    curveVertex(5*w,16*h);
    curveVertex(2*w,14*h);
    curveVertex(4*w,11*h);
    curveVertex(2.8*w,8.5*h);
    curveVertex(3*w,6*h);
    curveVertex(5*w,4.5*h);
    curveVertex(5.5*w,2.5*h);
    curveVertex(6.5*w,4.5*h);
    curveVertex(7*w,2*h);
    curveVertex(7*w,2*h);
    endShape();   


//inner face outline
    strokeWeight(1);
    fill(r,g,b);
    beginShape();
    curveVertex(9.5*w,8*h);

    curveVertex(9.5*w,8*h);
    curveVertex(11.3*w,7*h);
    curveVertex(13.3*w,8.5*h);
    curveVertex(12.8*w,12.5*h);
    curveVertex(14*w,14*h);
    curveVertex(12.5*w,16*h);
    curveVertex(5.7*w,15.9*h);
    curveVertex(4.4*w,14*h);

    curveVertex(5.5*w,12.5*h);

    curveVertex(5*w,8.5*h);
    curveVertex(7*w,7*h);
    curveVertex(9.5*w,8*h);

    curveVertex(9.5*w,8*h);
    endShape();

//normal happy
    if (v==1){
        eyeh=0
        eyew=0
        //eyes
        fill (255,255,255); //white
        ellipse(7.5*w,11.2*h, eyeWidth, eyeHeight);
        ellipse(11*w, 11.2*h, eyeWidth, eyeHeight);

        //mouth
        fill(255,120,144); //dark pink
        arc (9.25*w, 15*h, 2*w,1.5*h , 0, PI, CHORD);

        //blush
        fill(222,165,164); //pink
        ellipse(7.1*w,14.2*h,1*w,0.5*h);
        ellipse(11.4*w,14.2*h,1*w,0.5*h);

        // inner eyes
        fill(0,0,0);
        ellipse(7.8*w, 11.5*h, 0.5*eyeWidth, (2/3)*eyeHeight);
        ellipse(10.7*w, 11.5*h, 0.5*eyeWidth, (2/3)*eyeHeight);

        //nose
        fill(0,0,0);
        ellipse(9*w, 13.5*h, 0.3*w, 0.5*h);
        ellipse(9.5*w, 13.5*h, 0.3*w, 0.5*h);

    }
//surprised
    else if (v==2){
        //eyes
        fill (217,33,33); //red
        ellipse(7.5*w,11.2*h, eyeWidth*1.5, eyeHeight*1.5);
        ellipse(11*w, 11.2*h, eyeWidth*1.5, eyeHeight*1.5);

        //mouth
        fill(255,120,144); //dark pink
        arc (9.25*w, 15*h, 4.5*w,3*h , 0, PI, CHORD);

        // inner eyes
        // fill(0,0,0);
        // ellipse(7.8*w, 11.5*h, eyeWidth, (4/3)*eyeHeight);
        // ellipse(10.7*w, 11.5*h, eyeWidth, (4/3)*eyeHeight);

        fill(0,0,0);
        if (eyew<eyeWidth){
            eyew+=.4
        }
        
        if (eyeh<eyeHeight){
            eyeh+=.4
        }
        ellipse(7.8*w, 11.5*h, eyew, eyeh);
        ellipse(10.7*w, 11.5*h, eyew, eyeh);
        
        //nose
        fill(0,0,0); //black
        ellipse(8.9*w, 13.5*h, 0.7*w, 1*h);
        ellipse(9.7*w, 13.5*h, 0.7*w, 1*h);
    }

//shy
    else if (v==3){
        //eyes
        fill (255,255,255); //white
        ellipse(7.5*w,11.2*h, eyeWidth, eyeHeight);
        ellipse(11*w, 11.2*h, eyeWidth, eyeHeight);

        //heart eyes

        //mouth
        fill(255,120,144); //dark pink
        arc (9.25*w, 15*h, 2*w,1.5*h , 0, PI, CHORD);

        //blush
        fill(255,204,203); //baby pink
        ellipse(7.1*w,14.2*h,3*w,1.5*h);
        ellipse(11.4*w,14.2*h,3*w,1.5*h);

        // inner eyes
        fill(0,0,0);
        if (change>7){
            change=-2
        }
        else if (change<=-10){
            change=2
        }
        else {
            change+=0.5
        }

        ellipse(7.8*w+change, 11.5*h, 0.5*eyeWidth, (2/3)*eyeHeight);
        ellipse(10.7*w+change, 11.5*h, 0.5*eyeWidth, (2/3)*eyeHeight);

        //nose
        fill(0,0,0);
        ellipse(9*w, 13.5*h, 0.3*w, 0.5*h);
        ellipse(9.5*w, 13.5*h, 0.3*w, 0.5*h);
    }
//sad
    else if (v==4){
        //eyes
        fill (0,255,255); //cyan
        ellipse(7.5*w,11.2*h, eyeWidth, eyeHeight);
        ellipse(11*w, 11.2*h, eyeWidth, eyeHeight);

        //mouth
        fill(255,120,144); //dark pink
        arc (9.25*w, 15*h, 2*w,1.5*h , PI, 2*PI, CHORD);

        // inner eyes
        fill(0,0,0);
        ellipse(7.8*w, 11.5*h, 0.3*eyeWidth, (2/3)*eyeHeight);
        ellipse(10.7*w, 11.5*h, 0.3*eyeWidth, (2/3)*eyeHeight);

        //nose
        fill(0,0,0);
        ellipse(9*w, 13.5*h, 0.3*w, 0.5*h);
        ellipse(9.5*w, 13.5*h, 0.3*w, 0.5*h);
        //tears

        tear+=2
        fill (0,255,255); //cyan
        ellipse(11*w, 13*h+tear, 0.1*eyeWidth, 0.1*eyeHeight);
        ellipse(11*w, 13.5*h+tear, 0.1*eyeWidth, 0.1*eyeHeight);
        ellipse(11*w, 14*h+tear, 0.1*eyeWidth, 0.1*eyeHeight);
        ellipse(11*w, 12.5*h+tear, 0.1*eyeWidth, 0.1*eyeHeight);
        ellipse(7.5*w, 13*h+tear, 0.1*eyeWidth, 0.1*eyeHeight);
        ellipse(7.5*w, 13.5*h+tear, 0.1*eyeWidth, 0.1*eyeHeight);
        ellipse(7.5*w, 14*h+tear, 0.1*eyeWidth, 0.1*eyeHeight);
        ellipse(7.5*w, 12.5*h+tear, 0.1*eyeWidth, 0.1*eyeHeight);

    }
   
   






 
 }
 function mousePressed(){
   
    v+=1;
    if (v>4){
        v=1;
    }

    }   
.

Blog 02 – Generative Art – srauch

I’m inspired by the landscape-generating algorithm Minecraft uses to build its maps. Each Minecraft world has a completely unique map, but they are generated piecemeal rather than all in one go–the map is built one 16×16 block “chunk” at a time under the player as they wander. The worlds are built a layer at a time, using a 64-bit random number called a seed that determines the shape, biome, and finally content of each chunk, though the game also relies on “smoothing” functions that ensure biomes blend logically into one another–for example, there won’t be a snowy forest next to a desert. 

The landscape-generating algorithm Minecraft is the soul of the game. It creates in the player a sense of thrill and wonder about exploring a completely unknown landscape spreading out around them – a feeling that’s hard to come by in a highly connected 21st-century world. In a more technical sense, it’s also nifty in that it allows the game itself to be quite small–the whole thing, fresh out of the box (so to speak), takes up less than a gigabyte, making for an easy download.

credit: Minecraft.net

Project 2

this is my second portrait.

sketch


var eyeSizeX = 14;
var eyeSizeY = 20; 
var faceWidth = 100;
var faceHeight = 150;
var hairR = 80;
var hairG = 60;
var hairB = 50;
var mouth = 4;
var hairSizeX = 160;
var hairSizeY = 150;

 function setup() {
    createCanvas(640, 480);
}
 
function draw() {
    angleMode(DEGREES);
    //hair    
    background(180);
    strokeWeight(0);
    fill(hairR, hairG, hairB);
    ellipse(width/2, height/2-45, hairSizeX, hairSizeY);
    
    //face size
    fill(240, 221, 210);
    ellipse(width/2, height / 2, faceWidth,  faceHeight);

    //eyes
    strokeWeight(0);
    var eyeLX = width/2 - faceWidth * 0.2;
    var eyeRX = width/2 + faceWidth * 0.2;
    fill(0);
    ellipse(eyeLX, height/2, eyeSizeX, eyeSizeY);
    ellipse(eyeRX, height/2, eyeSizeX, eyeSizeY);
    fill(255, 255, 255, 170);
    ellipse(eyeLX-2, height/2, eyeSizeX/3, eyeSizeY/3);
    ellipse(eyeRX-2, height/2, eyeSizeX/3, eyeSizeY/3);
    
    
    //eyebrow 
    var BrowLX1 = width/2 - faceWidth*0.15;
    var BrowLY1 = height/2 - faceHeight*0.15;
    var BrowLX2 = width/2 - faceWidth*0.35;
    var BrowLY2 = height/2 - faceHeight*0.15;
    var BrowRX1 = width/2 + faceWidth*0.15;
    var BrowRY1 = height/2 - faceHeight*0.15;
    var BrowRX2 = width/2 + faceWidth*0.35;
    var BrowRY2 = height/2 - faceHeight*0.15;
    stroke(0);
    strokeWeight(3);

    line(BrowLX1, BrowLY1, BrowLX2, BrowLY2);
    line(BrowRX1, BrowRY2, BrowRX2, BrowRY2);
   
    //mouth
    var mouthLX = width/2 - faceWidth*0.2;
    var mouthLY = height/2 + faceHeight*0.2;
    var mouthRX = width/2 + faceWidth*0.2;
    var mouthRY = height/2 + faceHeight*0.2;

    if (mouth <= 1) {
        //happy
        strokeWeight(3);
        stroke(0);
        fill(50);
        beginShape();
        curveVertex(mouthLX, mouthLY);
        curveVertex(mouthLX, mouthLY);
        curveVertex((mouthLX+mouthRX)/2-faceWidth*0.08, mouthLY+faceHeight*0.07);
        curveVertex((mouthLX+mouthRX)/2+faceWidth*0.08, mouthLY+faceHeight*0.07);
        curveVertex(mouthRX, mouthRY);
        curveVertex((mouthLX+mouthRX)/2+faceWidth*0.08, mouthLY+faceHeight*0.15);
        curveVertex((mouthLX+mouthRX)/2-faceWidth*0.08, mouthLY+faceHeight*0.15);
        curveVertex(mouthLX, mouthLY);
        curveVertex(mouthLX, mouthLY);
        endShape();
    } else if (mouth > 1 & mouth <=2) {
        //sad
        strokeWeight(3);
        stroke(0);
        fill(50);
        beginShape();
        curveVertex(mouthLX, mouthLY+14);
        curveVertex(mouthLX, mouthLY+14);
        curveVertex((mouthLX+mouthRX)/2-faceWidth*0.08, mouthLY-faceHeight*0.07+14);
        curveVertex((mouthLX+mouthRX)/2+faceWidth*0.08, mouthLY-faceHeight*0.07+14);
        curveVertex(mouthRX, mouthRY+14);
        curveVertex((mouthLX+mouthRX)/2+faceWidth*0.08, mouthLY-faceHeight*0.15+14);
        curveVertex((mouthLX+mouthRX)/2-faceWidth*0.08, mouthLY-faceHeight*0.15+14);
        curveVertex(mouthLX, mouthLY+14);
        curveVertex(mouthLX, mouthLY+14);
        endShape();
    } else if (mouth > 2 & mouth <=3) {
        //shock
        fill(20);
        strokeWeight(3);
        ellipse((mouthLX+mouthRX)/2, mouthLY+10, 10, 20);
    } else if (mouth > 3 & mouth <= 4){
        strokeWeight(4);
        line(mouthLX, mouthLY+10, mouthRX, mouthRY+10);
    }
}


function mousePressed() {
    faceWidth = random(75, 120);
    faceHeight = random(90, 140);
    eyeSizeX = random(15, 20);
    eyeSizeY = random(15,25);
    hairR = random(80, 255);
    hairB = random(100, 200);
    hairSizeX = random(130, 190);
    hairSizeY = random(130, 160);
    mouth = random(0, 4);
}

Project 02

Left Side = :|, Right Side = :), Middle = : , Click the Shirt to Change Colors/Scale, Click and Hold on Face = ???

sketch
//Brody Ploeger
//Section C


var faceWidth = 175;
var faceHeight = 200;
var backcolor1 = 2;
var backcolor2 = 10;
var backcolor3 = 20;
var backrectcolor1 = 215;
var backrectcolor2 = 210;
var backrectcolor3 = 240;
var backrectcolor2 = 200
var circlecolor1 = 110;
var circlecolor2 = 150;
var circlecolor3 = 190;
var shirtcolor1 = 250;
var shirtcolor2 = 200;
var shirtcolor3 = 215;



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

function draw() {
    background(backcolor1, backcolor2, backcolor3)

    strokeWeight()

    //background rect
    fill(backrectcolor1, backrectcolor2, backrectcolor3, 75)
    rect(640/2,0,640/2,480)

    
    //shirt
    fill(shirtcolor1,shirtcolor2,shirtcolor3);
    circle(640/2, 480/2+faceHeight, faceHeight*1.5)
   

    //right side of face
    fill(circlecolor1, circlecolor2, circlecolor3)
    ellipse(640/2, 480/2, faceWidth, faceHeight)
    
    //left side of face
    fill(200, 75)
    beginShape();
    vertex(640/2-faceWidth/2, 480/2-faceHeight/2);
    vertex(640/2,480/2-faceHeight/2);
    vertex(640/2,480/2-faceHeight/10);
    vertex(640/2-faceWidth/10,480/2+faceHeight/6);
    vertex(640/2,480/2+faceHeight/2);
    vertex(640/2-faceWidth/2,480/2+faceHeight/2);
    endShape();

    //right eye
    fill(backcolor1, backcolor2, backcolor3);
    rect(640/2+faceWidth/8,480/2-faceHeight/10, faceWidth/5, faceHeight/5);

    //right pupil
    fill(backrectcolor1, backrectcolor2, backrectcolor3)
    ellipse(640/2+faceWidth/4.5,480/2, faceWidth/10, faceHeight/10)

    //left eye
    fill(backrectcolor1, backrectcolor2, backrectcolor3);
    ellipse(640/2-faceWidth/4,480/2, faceWidth/4, faceHeight/4);

    //left pupil
    stroke(backcolor1, backcolor2, backcolor3) ;  
    strokeWeight(faceWidth/40+faceHeight/40);
    line(640/2-faceWidth/3.25, 480/2, 640/2-faceWidth/5, 480/2);

if (mouseX<640/4){

    //straight mouth
    stroke(backcolor1, backcolor2, backcolor3);   
    strokeWeight(faceWidth/50+faceHeight/50);
    line(640/2-faceWidth/5, 480/2+faceHeight/3.5, 640/2+faceWidth/5, 480/2+faceHeight/3.5);  

    //left straight eyebrow 1
    stroke(backcolor1, backcolor2, backcolor3);   
    strokeWeight(faceWidth/50+faceHeight/50);
    line(640/2-faceWidth/2.8, 480/2-faceHeight/5, 640/2-faceWidth/7, 480/2-faceHeight/5);

    //right straight eyebrow 2
    stroke(backcolor1, backcolor2, backcolor3);  
    strokeWeight(faceWidth/50+faceHeight/50);
    line(640/2+faceWidth/2.8, 480/2-faceHeight/5, 640/2+faceWidth/7, 480/2-faceHeight/5);
} else if(mouseX>640*3/4){
    
    //mouth smile
    fill(backrectcolor1, backrectcolor2, backrectcolor3);
    strokeWeight(faceWidth/50+faceHeight/50);
    arc(640/2, 480/2+faceHeight/4, faceWidth/2, faceHeight/4,0,PI,PIE);
    
 // left tilt eyebrow 1
    stroke(backcolor1, backcolor2, backcolor3);   
    strokeWeight(faceWidth/50+faceHeight/50);
    line(640/2-faceWidth/2.8, 480/2-faceHeight/5, 640/2-faceWidth/7, 480/2-faceHeight/4);

    //right tilt eyebrow 2
    stroke(backcolor1, backcolor2, backcolor3);  
    strokeWeight(faceWidth/50+faceHeight/50);
    line(640/2+faceWidth/2.8, 480/2-faceHeight/5, 640/2+faceWidth/7, 480/2-faceHeight/4);
}

    if(mouseIsPressed){
    if (dist(mouseX, mouseY, 640/2,480/2)<faceHeight/3+faceWidth/5){
   
    faceWidth = random(100, 250);
    faceHeight = random(150,400); 
    backcolor = random(0,75);
    backcolor2 = random(0,75);
    backcolor3 = random(0,75);
    backrectcolor1 = random(210,255);
    backrectcolor2 = random(210,255);
    backrectcolor3 = random(210,255);
    circlecolor = random(100,200);
    circlecolor2 = random(100,200);
    circlecolor3 = random(100,200);
    shirtcolor1 = random (200,255);
    shirtcolor2 = random (200,255);
    shirtcolor3 = random (200,255);
    


    strokeWeight(faceWidth/50+faceHeight/50)
    noFill();
    beginShape();
    vertex(640/2-faceWidth/5, 480/2+faceHeight/4);
    vertex(640/2-faceWidth/5.5, 480/2+faceHeight/3.5)
    vertex(640/2-faceWidth/10, 480/2+faceHeight/4)
    vertex(640/2-faceWidth/15, 480/2+faceHeight/3.5)
    vertex(640/2+faceWidth/15, 480/2+faceHeight/4)
    vertex(640/2+faceWidth/10, 480/2+faceHeight/3.5)
    vertex(640/2+faceWidth/5.5, 480/2+faceHeight/4)
    vertex(640/2+faceWidth/5, 480/2+faceHeight/3.5);
    endShape();

    // other left tilt eyebrow 1
    stroke(backcolor1, backcolor2, backcolor3);   
    strokeWeight(faceWidth/50+faceHeight/50);
    line(640/2-faceWidth/2.8, 480/2-faceHeight/4, 640/2-faceWidth/7, 480/2-faceHeight/5);

    //other right tilt eyebrow 2
    stroke(backcolor1, backcolor2, backcolor3);  
    strokeWeight(faceWidth/50+faceHeight/50);
    line(640/2+faceWidth/2.8, 480/2-faceHeight/4, 640/2+faceWidth/7, 480/2-faceHeight/5);

    faceWidth += 10;
    faceHeight += 10;

}
}

print(faceHeight)


}


function mousePressed() {

//if circle clicked, shape of head changes
if (dist(mouseX, mouseY, 640/2, 480/2+faceHeight)<faceHeight/2+faceWidth/2){
    faceWidth = random(100, 250);
    faceHeight = random(150,400); 
    backcolor = random(0,75);
    backcolor2 = random(0,75);
    backcolor3 = random(0,75);
    backrectcolor1 = random(210,255);
    backrectcolor2 = random(210,255);
    backrectcolor3 = random(210,255);
    circlecolor = random(100,200);
    circlecolor2 = random(100,200);
    circlecolor3 = random(100,200);
    shirtcolor1 = random (200,255);
    shirtcolor2 = random (200,255);
    shirtcolor3 = random (200,255);

 
}
 
}

Project 2: My (Variable) Self Portrait

I took my original self portrait and modified it to be variable, as that’s what I thought originally we were supposed to do. My bad for misinterpreting, if I did. But the idea here is that the hair length and color, as well as skin and eye color will change randomly as you click. You may also notice some weird little ditties in the code, as well as the fact that the eyes follow your mouse. Those are the animations I thought we were supposed to do (again, my bad for misinterpreting!) that are now just fun little easter eggs to play with!

sketch
let leftbrowx = 210; //x coordinate of the original vertex of the left brow
let browY = 185; //y coordinate of both brows
let rightbrowx = 273; //x coordinate of the original vertex of the right brow
haircenterX = 225; //x coordinate of the point around which hair rotates and from which it originates
haircenterY = 170; //y coordinate of the point around which hair rotates and from which it originates

let lefteyex = 262; //x coordinate of the center of the left eye
let righteyex = lefteyex-40; //x coordinate of the center of the right eye
let eyey = 198; //y coordinate of the center of both eyes
let mouthY = 225; //y coordinate of the vertices of the mouth
let eyeRed = 33; //Red tint of the iris
let eyeGreen = 6; //Green tint of the iris
let eyeBlue = 4; //Blue tint of the iris
let hairRed = 40; //Red tint of the hair
let hairBlue = 26; //Green tint of the hair
let hairGreen = 34; //Blue tint of the hair
let skinRed = 255; //Red tint of the skin
let skinGreen = 233; //Green tint of the skin
let skinBlue = 199; //Blue tint of the skin
let hairLen = 50; //Length of hair in the back of the head
performingAnim = false; //determines whether or not an animation is occurring, and retains the face until the animation has stopped and the face returns to default (not default color, as in expression)


function setup() {
    createCanvas(500, 500);
    background(255,138,120);
}
function draw() {
    background(255,138,120);

    //behind head hair
    noStroke();
    fill(hairRed, hairGreen, hairBlue);
    beginShape();
    vertex(haircenterX,haircenterY);
    curveVertex(haircenterX,haircenterY);
    curveVertex(haircenterX-20,haircenterY+hairLen/2)
    vertex(haircenterX-10-10,haircenterY+40+(hairLen-30));
    vertex(haircenterX-5-10,haircenterY+53+(hairLen-30));
    vertex(haircenterX+1+10,haircenterY+60+(hairLen-30)+10);
    vertex(haircenterX+4+10,haircenterY+60+(hairLen-30)+10);
    vertex(haircenterX+45+15,haircenterY+62+(hairLen-20));
    vertex(haircenterX+55+15,haircenterY+55+(hairLen-20));
    vertex(haircenterX+63+15,haircenterY+50+(hairLen-20));
    vertex(haircenterX+45+35.5,haircenterY+40+(hairLen-20));
    curveVertex(haircenterX+75,haircenterY+hairLen/2);
    curveVertex(haircenterX+40,haircenterY);
    curveVertex(haircenterX+20,haircenterY-10);
    endShape();
    stroke(hairRed+100, hairGreen+50, hairBlue+50);
    strokeWeight(1)
    arc(haircenterX-10,haircenterY+40+(hairLen-30),30,hairLen,8.5,4.5); //15
    arc(haircenterX+63,haircenterY+50+(hairLen-30),40,hairLen+10,6,8,OPEN); //20
    arc(haircenterX+45,haircenterY+40+(hairLen-30),75,hairLen+10,5.7,6.6,OPEN); //37.5
    arc(haircenterX+55,haircenterY+55+(hairLen-30),40,hairLen+10,6.1,8,OPEN); //20
    arc(haircenterX+45,haircenterY+62+(hairLen-30),40,hairLen+10,6.2,8,OPEN); //20
    arc(haircenterX-5,haircenterY+53+(hairLen-30),30,hairLen,7.6,3.7); //15
    arc(haircenterX+1,haircenterY+60+(hairLen-30),30,hairLen,7.6,3); //15
    arc(haircenterX+4,haircenterY+60+(hairLen-30),30,hairLen,7.6,3); //15
    push();
    rotate(0.1);
    arc(haircenterX+40,haircenterY+40+(hairLen-30),30,hairLen,7.6,3);
    pop();


    //cranium and fillings
    angleMode(RADIANS);
    fill(skinRed,skinGreen,skinBlue);
    noStroke();
    ellipse(246.8,500/2.195-12,71.5,55.8);
    stroke(0);
    arc(249,500/3+8.5,92,90,2.5,7.05,OPEN);
    noStroke();
    ellipse(221,500/2.45,20,30);
    ellipse(282,500/2-42,10,10);
    stroke(0);
    noStroke();
    fill(222, 0, 111);
    ellipse(262,270,100,20);
    triangle(160,500,260,260,388,500);
    stroke(0);
    arc(262,270,100,20,3.2,6.2);

    //neck
    noStroke();
    fill(skinRed,skinGreen,skinBlue);
    beginShape();
    curveVertex(240,245);
    curveVertex(240,245);
    curveVertex(239,258);
    curveVertex(240,268);
    curveVertex(285,266);
    curveVertex(281,250);
    curveVertex(280,223);
    curveVertex(280,223);
    endShape();
    noFill();
    stroke(0);
    arc(230,245,20,50,5.5,8);
    arc(290,225,20,80,7.8,10);
    fill(skinRed,skinGreen,skinBlue);

    //clothes (it's just a blanket)
    fill(222, 0, 111);
    beginShape();
    vertex(240,258);
    vertex(225,255);
    vertex(205,257);
    vertex(190,280);
    vertex(180,350);
    vertex(150,470);
    vertex(162,500);
    vertex(180,520);
    endShape(OPEN);
    beginShape();
    vertex(200,400);
    vertex(240,256);
    vertex(250,268);
    vertex(260,258);
    vertex(300,255);
    vertex(320,257);
    vertex(350,285);
    vertex(365,350);
    vertex(400,440);
    vertex(398,500);
    vertex(360,530);
    endShape(OPEN);
    curve(245,264,240,268,197,270,200,220);
    curve(245,264,240,268,183,340,200,220);
    curve(220,390,208,420,160,460,130,420);
    curve(260,265,255,268,335,270,330,220);
    curve(260,265,255,268,365,350,330,220);
    curve(220,370,200,400,365,440,330,220);
    fill(skinRed,skinGreen,skinBlue);
    beginShape();
    vertex(239,255);
    vertex(235,278);
    vertex(275,256);
    endShape(OPEN);
    line(200,400,240,500);

    //chin segments
    fill(skinRed,skinGreen-50,skinBlue-20);
    noStroke();
    beginShape();
    curveVertex(240,245);
    curveVertex(240,245);
    curveVertex(250,253);
    curveVertex(260,249);
    curveVertex(280,223);
    curveVertex(280,223);
    endShape(OPEN);
    stroke(0);
    fill(skinRed,skinGreen,skinBlue);
    beginShape();
    curveVertex(215,231);
    curveVertex(215,231);
    curveVertex(228,243);
    curveVertex(250,244);
    curveVertex(280,223);
    curveVertex(280,223);
    endShape(OPEN);
    push();
    translate(215, 216.43);
    rotate(-0.2);
    arc(3,0,15,42,8,4.45,OPEN);
    pop();

    //ear
    push();
    translate(284,500/2-32);
    rotate(0.3);
    arc(0,-5,13,26,4.1,8.1,OPEN);
    arc(1,-5,7,15,8,4.6,OPEN);
    pop();
    arc(284.9,500/2-35,4,8,4,7,OPEN);

    //left eye (of body)
    noStroke();
    fill(255);
    ellipse(lefteyex,eyey+1,20,16);
    fill(240);
    arc(lefteyex,eyey-2,20,10,3.2,6.3);
    fill(eyeRed,eyeGreen,eyeBlue);
    noStroke();
    if (mouseY > 208) {
        irisY = eyey+2;
    } else{
        irisY = eyey;
    }
    if (mouseX > 255 & mouseX < 267) {
        leftposX = mouseX
    }
    if (mouseX > 267){
        leftposX = lefteyex+5
    }
    if (mouseX < 255) {
        leftposX = lefteyex-5
    }
    ellipse(leftposX,irisY,10,14) //iris
    fill(eyeRed+200,eyeGreen+150,eyeBlue+150);
    ellipse(leftposX,irisY+4,6,5); //under-pupil highlight
    fill(0);
    ellipse(leftposX,irisY,5,8); //pupil
    fill(255);
    ellipse(leftposX-2,irisY-2,3,6); //over pupil highlight
    stroke(0);
    noFill();
    ellipse(leftposX,irisY,9,13);
    
    arc(222,196,20,10,3.2,6.3)

    //right eye (of body)
    noStroke();
    fill(255);
    ellipse(righteyex,eyey+1,20,16);
    fill(240);
    arc(righteyex,eyey-2,20,10,3.2,6.3);
    fill(eyeRed,eyeGreen,eyeBlue);
    noStroke();
    if (mouseX > 218 & mouseX < 230) {
        rightposX = mouseX;
    }
    if (mouseX > 230){
        rightposX = righteyex+6;
    }
    if (mouseX < 218) {
        rightposX = righteyex-4;
    }
    ellipse(rightposX,irisY,10,14) //iris
    fill(eyeRed+200,eyeGreen+150,eyeBlue+150);
    ellipse(rightposX,irisY+4,6,5); //under-pupil highlight
    fill(0);
    ellipse(rightposX,irisY,5,8); //pupil
    fill(255);
    ellipse(rightposX-2,irisY-2,3,6); //over-pupil highlight
    stroke(0);
    noFill();
    ellipse(rightposX,irisY,9,13);

    arc(262,196,20,10,3.2,6.3);
        

    //mouth
    stroke(0);
    if(mouseX > 235 & mouseX < 248 && mouseY > 183 && mouseY < 191 && mouseIsPressed === true){ //frowning action
        while(mouthY < 245){
            mouthY = mouthY+1;
        }
        curve(228, mouthY, 233, 230, 240, 230, 245, mouthY);
        performingAnim = true;
    } 
    else {
        curve(228, 225, 233, 230, 240, 230, 245, 225);
        performingAnim = false;
    }
    if(mouseX > 230 & mouseX < 240 && mouseY > 220 && mouseY < 235 && mouseIsPressed === true){ //makes my mouth open and close randomly, for no good reason.
        stroke(0);
        fill(227, 85, 66);
        ellipse(236.5, 230,10,8);
        performingAnim = true;
    } 

    //nose
    fill(skinRed,skinGreen-50,skinBlue-20);
    noStroke();
    triangle(240,215,232,215,235,218);
    stroke(0);
    noFill();
    arc(226,208,18,20,6.1,7.1);
    arc(240,213,15,10,8.8,9.2);

    //eyebrows
    noStroke();
    fill(hairRed, hairGreen, hairBlue);
    if(mouseX > 235 & mouseX < 248 && mouseY > 183 && mouseY < 191 && mouseIsPressed === true){ //eyebrow furrowing action
        while (leftbrowx < 215 && browY < 190 && rightbrowx > 268) {
            leftbrowx = leftbrowx+1
            rightbrowx = rightbrowx-1
            browY = browY+1

            push();
            rotate(0.01);
            beginShape();
            curveVertex(leftbrowx,browY);
            curveVertex(leftbrowx+7,browY-5);
            curveVertex(leftbrowx+18,browY-1);
            curveVertex(leftbrowx+25,browY-2);
            curveVertex(leftbrowx+20,browY-8);
            curveVertex(leftbrowx+7,browY-8);
            endShape(CLOSE);
            pop();

            push();
            rotate(-0.02);
            beginShape();
            curveVertex(rightbrowx,browY);
            curveVertex(rightbrowx-7,browY-1);
            curveVertex(rightbrowx-18,browY+3);
            curveVertex(rightbrowx-25,browY+2);
            curveVertex(rightbrowx-20,browY-4);
            curveVertex(rightbrowx-7,browY-4);
            endShape(CLOSE);
            pop();
            performingAnim = true;
        }
        if (leftbrowx >= 215 & browY >= 190 && rightbrowx <= 268){
            push();
            rotate(0.01);
            beginShape();
            curveVertex(leftbrowx-6,browY-5);
            curveVertex(leftbrowx-0,browY-3);
            curveVertex(leftbrowx+15,browY-0);
            curveVertex(leftbrowx+22,browY-1);
            curveVertex(leftbrowx+17,browY-6);
            curveVertex(leftbrowx+4,browY-6);
            endShape(CLOSE);
            pop();

            push();
            rotate(-0.02);
            beginShape();
            curveVertex(rightbrowx-2,browY+2);
            curveVertex(rightbrowx-8,browY+4);
            curveVertex(rightbrowx-19,browY+7);
            curveVertex(rightbrowx-26,browY+6);
            curveVertex(rightbrowx-21,browY+1);
            curveVertex(rightbrowx-8,browY+1);
            endShape(CLOSE);
            pop();
            performingAnim = true;
        }
    } else {
        let leftbrowx = 210;
        let browY = 185;
        let rightbrowx = 273;
        beginShape();
        curveVertex(leftbrowx,browY+3);
        curveVertex(leftbrowx+7,browY+2);
        curveVertex(leftbrowx+18,browY+4);
        curveVertex(leftbrowx+25,browY+3);
        curveVertex(leftbrowx+20,browY-1);
        curveVertex(leftbrowx+7,browY-1);
        endShape(CLOSE);
        beginShape();
        curveVertex(rightbrowx,browY+3);
        curveVertex(rightbrowx-7,browY+2);
        curveVertex(rightbrowx-18,browY+4);
        curveVertex(rightbrowx-25,browY+3);
        curveVertex(rightbrowx-20,browY-1);
        curveVertex(rightbrowx-7,browY-1);
        endShape(CLOSE);
        performingAnim = false;
    }
    

    //hair
    fill(hairRed, hairGreen, hairBlue);
    beginShape();
    vertex(200,175);
    vertex(220,140);
    vertex(228,127);
    vertex(290,139);
    vertex(295,160);
    vertex(295,190);
    vertex(285,190);
    vertex(235,162);
    vertex(225,170);
    endShape();

    stroke(hairRed+100, hairGreen+50, hairBlue+50);
    strokeWeight(1)
    arc(haircenterX-15,haircenterY+10,20,50,8,3.5);
    noStroke();
    rect(haircenterX-16,haircenterY+5,5,5);
    stroke(hairRed+100, hairGreen+50, hairBlue+50);

    beginShape();
    curveVertex(haircenterX-20,haircenterY-2);
    curveVertex(haircenterX-20,haircenterY-2);
    curveVertex(haircenterX-28,haircenterY+2);
    curveVertex(haircenterX-47,haircenterY-9);
    curveVertex(haircenterX-28,haircenterY-7);
    curveVertex(haircenterX-15,haircenterY-10);
    curveVertex(haircenterX-15,haircenterY-10);
    endShape();

    beginShape();
    curveVertex(haircenterX-8,haircenterY);
    curveVertex(haircenterX-8,haircenterY);
    curveVertex(haircenterX-12,haircenterY+8);
    curveVertex(haircenterX-25,haircenterY+10);
    curveVertex(haircenterX-40,haircenterY);
    curveVertex(haircenterX-30,haircenterY+3);
    curveVertex(haircenterX-20,haircenterY-2);
    curveVertex(haircenterX-20,haircenterY-2);
    endShape();

    beginShape();
    curveVertex(haircenterX+10,haircenterY-8);
    curveVertex(haircenterX+10,haircenterY-8);
    curveVertex(haircenterX-1,haircenterY+2);
    curveVertex(haircenterX-5,haircenterY+8);
    curveVertex(haircenterX-15,haircenterY+14);
    curveVertex(haircenterX-27,haircenterY+15);
    curveVertex(haircenterX-16,haircenterY+8);
    curveVertex(haircenterX-8,haircenterY);
    curveVertex(haircenterX-8,haircenterY);
    endShape();

    beginShape();
    curveVertex(haircenterX-15,haircenterY-10);
    curveVertex(haircenterX-15,haircenterY-10);
    curveVertex(haircenterX-28,haircenterY-7);
    curveVertex(haircenterX-50,haircenterY-12);
    curveVertex(haircenterX-35,haircenterY-16);
    curveVertex(haircenterX-15,haircenterY-35);
    curveVertex(haircenterX,haircenterY-30);
    curveVertex(haircenterX,haircenterY-30);
    endShape();

    beginShape();
    curveVertex(haircenterX,haircenterY-30);
    curveVertex(haircenterX,haircenterY-30);
    curveVertex(haircenterX-15,haircenterY-35);
    curveVertex(haircenterX-24,haircenterY-50);
    curveVertex(haircenterX-15,haircenterY-40);
    curveVertex(haircenterX,haircenterY-40);
    curveVertex(haircenterX,haircenterY-40);
    endShape();

    arc(haircenterX+36,haircenterY+5,90,90,5.3,6.9,OPEN);
    arc(haircenterX+28,haircenterY-5,90,90,4,5.8,OPEN);

    beginShape();
    curveVertex(haircenterX+55,haircenterY+28);
    curveVertex(haircenterX+55,haircenterY+28);
    curveVertex(haircenterX+64,haircenterY+33);
    curveVertex(haircenterX+65,haircenterY+45);
    curveVertex(haircenterX+72,haircenterY+35);
    curveVertex(haircenterX+75,haircenterY+28);
    curveVertex(haircenterX+75,haircenterY+28);
    endShape();

    //sideburn
    push();
    rotate(-0.2);
    arc(haircenterX+10,haircenterY+88,10,30,8,5.5,CLOSE);

    //sideswoop
    pop();
    push();
    rotate(-1.4);
    arc(haircenterX-365,haircenterY+145,15,30,7.8,4.8,CLOSE);
    rotate(-0.1);
    arc(haircenterX-390,haircenterY+130,15,30,7.8,4.8,CLOSE);
    arc(haircenterX-385,haircenterY+125,15,30,7.8,4.8,CLOSE);
    pop();

    beginShape();
    curveVertex(haircenterX+10,haircenterY-8);
    curveVertex(haircenterX+10,haircenterY-8);
    curveVertex(haircenterX+20,haircenterY-2);
    curveVertex(haircenterX+28,haircenterY+6);
    curveVertex(haircenterX+40,haircenterY+14);
    curveVertex(haircenterX+65,haircenterY+25);
    curveVertex(haircenterX+48,haircenterY+10);
    curveVertex(haircenterX+40,haircenterY);
    curveVertex(haircenterX+35,haircenterY-8);
    curveVertex(haircenterX+35,haircenterY-8);
    endShape();

}
function mousePressed() {
    if (performingAnim === false) { //runs the code which changes all the variables
        eyeBlue = random(0,100);
        eyeRed = random(0,100);
        eyeGreen = random(0,100);
        hairRed = random(0,80);
        hairGreen = random(0,80);
        hairBlue = random(0,80);
        skinBlue = random(155,215);
        skinGreen = random(skinBlue,245);
        skinRed = random(skinGreen,255);
        hairLen = random(10,100);
    } else { //prevents it from doing that while the mouse is pressed down over the two animation spots
        eyeBlue = eyeBlue;
        eyeRed = eyeRed;
        eyeGreen = eyeGreen;
        hairRed = hairRed;
        hairGreen = hairGreen;
        hairBlue = hairBlue;
        skinBlue = skinBlue;
        skinGreen = skinGreen;
        skinRed = skinRed;
        hairLen = hairLen;
    }
    
}

I misinterpreted the original directions of the project and instead of making the face change, I made it interactive. Because (in all honesty) I was too lazy and didn’t want all my hard work to go to waste, I just left it and incorporated it into the portrait.

Variable Face

I liked uncovering the associations across each variable and being able to articulate those connections in writing to make illustrations. I learned the value of arranging my code and adding required comments for specific lines to help me remember important information when I was making two figures on one canvas.

Ideation
sketch
var eyeSize = 40;
var faceWidth = 100;
var faceHeight = 150;
var diam = 40;
var lipw = 40;
var liph = 25;
var lipr = 50;
var on = false;
var r = 102;  // values of gray
var g = 102;  
var b = 102;
var eyeType = 2

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

}

function draw() {
    background(204, 229, 255);

    fill(0, 0, 0);
    stroke(0, 0, 0);
    ellipse((width/2), (height/2), 200, 250); // hair 

    fill(0, 0, 0);
    stroke(0, 0, 0);
    rect((width/2.9), (height/2.6), 150, 200); // hair
    
    if (on == true) { // stating the color change in the hair
    fill(r, g, b );
    stroke(r, g, b);
    ellipse((width/2), (height/2), 200, 250);
    rect((width/2.9), (height/2.6), 150, 210); 
  } else {
    fill(255-r, 255-g, 255-b);
    stroke(255-r, 255-g, 255-b);
    ellipse((width/2), (height/2), 200, 250);
    rect((width/2.9), (height/2.6), 150, 210);
  }

    fill (215, 180, 146);
    stroke(215, 180, 146);
    ellipse(width/2, height/2, faceWidth, faceHeight); // variable faces


    stroke (195, 43, 79);
    strokeWeight(1);
    fill(195, 43, 79);
    arc((width/2) - 5, (height/2)+40, lipw, liph, lipr, PI + QUARTER_PI); // different mouth expressions

    stroke(0, 0, 0);
    line((width/2)-35, (height/2)-35, (width/2)-10, (height/2)-35);
    line((width/2) + 35, (height/2)-35, (width/2)+ 10, (height/2)-35);// static eyebrows

    
    var eyeLX = width / 2 - faceWidth * 0.25;
    var eyeRX = width / 2 + faceWidth * 0.25;
    
    fill (0,0,0);
    stroke (0, 0, 0);
    ellipse(eyeLX, height / 2, diam, diam);
    ellipse(eyeRX, height / 2, diam, diam);

    if(eyeType > 1 & eyeType < 2) { //altering between two eye types 
        fill(0, 0, 0);

    } else {
        fill(255, 255, 255);
    }
    ellipse((width/2)-(faceWidth/4), height/2, 40, 30);
    ellipse((width/2)+(faceWidth/4), height/2, 40, 30);
     
    if(eyeType > 1 & eyeType < 2) { 
     fill(255, 255, 255);
    } else {
        fill(0, 0, 0);
    }
    ellipse((width/2)-(faceWidth/4), (height/2)+7, 20, 10);
    ellipse((width/2)+(faceWidth/4), (height/2)+7, 20, 10);

}

function mousePressed() {
    faceWidth = random(50, 150);
    faceHeight = random(150, 250);
    lipw = random (20, 50);
    liph = random (10, 30);
    lipr = random (40, 60);
    eyeType = random(0,2);

 
 if (on == false) { // color flip using boolean 
    on = true;
  } else {
    on = false;
  }
  
}




LO: “Hidden Order” Generative Muslim Geometric Art and Music

As a Muslim American I’ve had the privilege of coming from an artistic heritage of geometric graphic art. From the Alhambra to the niche at the CFA, Muslim geometric art is one of the most amazingly simple yet dazzlingly complicated art forms I’ve ever studied. (historical studies, of course. I’m not good enough at drawing it yet!) So naturally I went looking for some Muslim generative geometric art, and I found this amazing project called A Hidden Order, a cross disciplinary collaboration between traditional Muslim-British geometer Sama Mara, and English musician Lee Westwood

By combining sound and geometry they have created a generative art process where the music and sound informs the composition of the piece. First, Lee Westwood (and co) play a pre-composed piece. This is then run through algorithms and code to generate a colorful geometric image which assembles itself over the course of the piece. Some of them could then be photographed and turned into prints like these:


I’m not sure how exactly they might have even approached the algorithms to this. Just the concept boggles my mind. To see them actually performing and having the piece assemble as they play is even more astounding. This was what was said of the project by the author of the Islamic Digital Arts blog: “Each key or note was interpreted by a program that would then convert the sound to form part of a colour and shape system.” And yes, while some might think it looks like a kaleidoscope, it isn’t so simple. These forms are not just refractions of glass but are a part of a sacred geometry which has influenced the architecture and art of large parts of the world for over a millennia. If these were ceramic tiles, I could see them decorating the walls of grand mosques from Morocco to Indonesia. Were they carved stone, I could imagine them as the dazzling domes of the mosques in Isfahan. Not only is there a mathematical and artistic significance here, but a cultural one as well.

At the end of the day, I’m not so concerned with the algorithm as with the intersections and overlap of Western, Islamic, musical and visual arts and math. It’s really a gorgeous representation of how so many seemingly different things can come together to create beautiful art!

Looking Outwards 02: Generative Art _Alicia Kim 

The generative art piece that inspired me was Aaron Koblin’s project called Flight Patterns. This piece of art is created by parsing FAA data and creates different lines and colors according to flight paths. This project is impressive not only because of the technology and algorithm put into it but also the presentation of different colors and how he made multiple days worth of flights into one photo. Especially the intersections between flight paths generate a big spectrum of colors of light and as well as more tones. I suppose that he parsed multiple days of FAA data and made it into a single data piece and the colors represent different time, generating a large spectrum of colors. The different colors for different time was very intentional and generated a beautiful combination of brightness and tone. The creator’s ability to program and analyze data boosted his artistic ability to create this great piece.

http://www.aaronkoblin.com/project/flight-patterns/

,

Project-02: Variable Faces

I enjoyed figuring out different relationships between each variable and being able to write them as expressions to create drawings. In creating two figures on one canvas, I realized the importance of organizing my code and adding necessary comments for particular lines to remind myself about key information.

sketch
// Angela Yang 
// Section C - Project 02

// Variables are set for each facial element. 
var eyeSizeW = 100;
var eyeSizeH = 100;
var eyeSizeW2 = 70;
var eyeSizeH2 = 70;
var pupilSizeW = 50;
var pupilSizeH = 50;
var pupilSizeW2 = 30;
var pupilSizeH2 = 30;
var faceWidth = 200;
var faceHeight = 200;
var faceWidthB = 350;
var faceHeightB = 250;  
var mouthType = 2;
var noseType = 1;
var r = 200; 
var g = 100;
var b = 150;
var on = false; 


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

function draw() {
  if(on) {
    background(243, 200, 174);
  } else {
    //background changes from yellowish-green to a pink tone with 30% transparency. 
    background(219, 226, 175, 30);
  }
  

   
//LEFT FIGURE
    //Body
    fill(r, g, b);
    stroke("white");
    ellipse(width/4, height/2 + 200, width/1.5, height/1.5);
  
    // Face base
    noStroke();
    fill(r, g, b);
    ellipse(width / 4, height / 2, faceWidth,  faceHeight);
  
    // Eyes
    stroke(r, g, 50);
    strokeWeight(1);
    fill(255);
    var eyeLX = width / 4 - faceWidth * 0.25;
    var eyeRX = width / 4 + faceWidth * 0.25;
    ellipse(eyeLX, height / 2, eyeSizeW, eyeSizeH);
    ellipse(eyeRX, height / 2, eyeSizeW, eyeSizeH);
    fill(r-100, g+50, b+50);
    var pupilLX = width / 4 - faceWidth * 0.25;
    var pupilRX = width / 4 + faceWidth * 0.25;
    ellipse(pupilLX, height/2, pupilSizeW, pupilSizeH);
    ellipse(pupilRX, height/2, pupilSizeW, pupilSizeH);

  
    //Nose Variations
    fill("white");
  
    if (noseType >= 0 & noseType <= 1.5){
       noStroke();
       rect(width/4 - faceWidth*0.03, height/2 + faceHeight*0.1, 10, 20);
       //When the value of nose type is >= to 0 and <= 1.5, a rectangular nose is drawn. 
      
    } else if(noseType > 1.5 & noseType <= 3){
        noStroke();
        ellipse(width/4, height/2 + faceHeight*0.1, faceWidth/5, faceHeight/10);
        //When the value of nose type is greater than 1.5 and smaller+equal to 3, 
        //a circular nose is drawn. 
      
    } else if(noseType > 3 & noseType <= 4.5){
        stroke("white");
        strokeWeight(4);
        line(width/4, height/2, width/4+15, height-230);
        //When the value of nose type is greater then 3 and smaller+equal to 4.5, 
        //a linear nose is drawn. 
      
    } else{
        noStroke();
        triangle(width/4, height/2, width/4+15, height-230, width/4-15, height-230);      
      //When the value of nose type is equal to all other numbers in the range of 0~6, 
      //a triangular nose is drawn. 
    }

  
   // Mouth Variations   
    if (mouthType >= 0 & noseType <= 1.5){
       stroke("white");
       fill(r-60, g, b);
       rect(width/4 - faceWidth*0.05, height/2 + faceHeight*0.35, 20, 5);
       // A confusing mouth is drawn. 
      
    } else if(mouthType > 1.5 & mouthType <= 3){
        stroke("white");
        strokeWeight(1);
        fill(r, g, b+80);
        ellipse(width/4, height/2 + faceHeight*0.35, faceWidth/6, faceHeight/10);
        //A shocking mouth is drawn. 
      
    } else if(mouthType > 3 & mouthType <= 4.5){
        noStroke();
        triangle(width/4 - faceWidth*0.05, height/2 + faceHeight*0.35, width/4+15, height-190, width/4-15, height-190); 
        //A happy mouth is drawn. 
      
    } else{
        stroke("white");
        strokeWeight(1);
        fill(r, g+60, b);
        ellipse(width/4, height/2 + faceHeight*0.35, faceWidth/2, faceHeight/8);
        //A shocking mouth is drawn. 

    }
  
  
  
// RIGHT FIGURE 
    //Body
    fill(0, g, b+50);
    stroke("white");
    ellipse(width/1.4, height/2 + 200, width/1.5, height/1.5);
  
    // Face base
    noStroke();
    fill(0, g, b+50);
    ellipse(width/1.4, height/2, faceWidthB, faceHeightB);
  
    // Eyes
    stroke(r, g, 100);
    strokeWeight(1);
    fill(255);
    var eyeLX2 = width / 1.4 - faceWidthB * 0.25;
    var eyeRX2 = width / 1.4 + faceWidthB * 0.25;
    ellipse(eyeLX2, height / 2, eyeSizeW2, eyeSizeH2);
    ellipse(eyeRX2, height / 2, eyeSizeW2, eyeSizeH2);
    fill(r-100, g+50, b+50);
  
    var pupilLX2 = width / 1.4 - faceWidthB * 0.25;
    var pupilRX2 = width / 1.4 + faceWidthB * 0.25;
    ellipse(pupilLX2, height/2, pupilSizeW2, pupilSizeH2);
    ellipse(pupilRX2, height/2, pupilSizeW2, pupilSizeH2);

  
    //Nose Variations
    fill("white");
  
    if (noseType >= 0 & noseType <= 1){
       noStroke();
       ellipse(width/1.4, height/2 + faceHeightB*0.1, faceWidthB/5, faceHeightB/10);
      
    } else if(noseType > 2 & noseType <= 4){
       noStroke();
       fill("white");
       rect(width/1.4 - faceWidthB*0.03, height/2 + faceHeightB*0.1, 30, 10);
      
    } else if(noseType > 4 & noseType <= 5.5){
        stroke("white");
        strokeWeight(5);
        line(width/1.4, height/2, width/1.4+15, height-230);
      
    } else{
        noStroke();
        triangle(width/1.4, height/2, width/1.4+50, height-220, width/1.4+50, height-220);      
    }
  
  
     // Mouth Variations   
    if (mouthType >= 0 & noseType <= 1.5){
       stroke("white");
       fill(r-60, g, b);
       rect(width/1.4 - faceWidthB*0.05, height/2 + faceHeightB*0.35, 20, 5);
      
    } else if(mouthType > 1.5 & mouthType <= 3){
        stroke("white");
        strokeWeight(1);
        fill("black");
        ellipse(width/1.4, height/2 + faceHeightB*0.35, faceWidthB/6, faceHeightB/10);
      
    } else if(mouthType > 3 & mouthType <= 4.5){
        noStroke();
        triangle(width/1.4 - faceWidthB*0.05, height/2 + faceHeightB*0.35, width/1.4+15, height-190, width/1.4-15, height-190); 
      
    } else{
        stroke("white");
        strokeWeight(1);
        fill(r, g+60, b);
        ellipse(width/1.4, height/2 + faceHeightB*0.35, faceWidthB/10, faceHeightB/8);
}
}

function mousePressed() {
    // when the user clicks, these variables are reassigned
    // to random values within specified ranges. For example,
    // 'faceWidth' gets a random value between 100 and 300.
    faceWidth = random(100, 300);
    faceHeight = random(100, 400);
    faceWidthB = random (100, 300);
    faceHeightB = random (200, 450);
    noseType = random(0, 6);
    mouthType = random(0, 8);
    eyeSizeW = random(10, 80);
    eyeSizeH = random(10, 80);
    eyeSizeW2 = random(30, 70);
    eyeSizeH2 = random(30, 70);
    pupilSizeW = random(5,30);
    pupilSizeH = random(5,20);
    pupilSizeW2 = random(10, 30);
    pupilSizeH2 = random (5, 30);
    r = random(0, 255);
    g = random(0, 255);
    b = random(0, 255);
    if(mouseX > 250 & mouseX < 350 && mouseX);
    on = !on;

}