Self-Portrait

For this project, I made a self-portrait using processing. I decided to create a fairly basic human-looking face and incorporated a few features that I thought were very characteristic of me. This includes my really big eyebrows, along with my hair which frequently changes.

When any key is pressed, the hair changes between three different states: a top hat, a mohawk, and bald. I added more interaction by allowing the user to control which direction my mohawk was going in through the use of the mouse. Lastly, my pupils follow the mouse as well when the user moves it around.

I found it difficult to use the arc tool at first, but I was able to get it to do what I wanted more or less, though I still cannot say that I mastered it.

Here is the code I used for the project:

boolean hair1 = true;
boolean hair2 = false;
boolean hair3 = false;

int state = 0;

void setup() {
  size(400, 500); 
  rectMode(CENTER);  
  background(131, 206, 210);
}


void draw() {
  background(131, 206, 210);
  //create my white t-shirt
  fill(255, 255, 255);
  noStroke();
  beginShape();
  vertex(0, 500);
  vertex(160, 421);
  vertex(241, 421);
  vertex(400, 500);
  endShape(CLOSE);
  //hair 1 back of head
  if (hair1) {
    fill(0, 0, 0);
    strokeWeight(10);
    ellipse(200, 140, 80, 80);
  }
  //neck
  fill(224, 192, 134);
  noStroke();
  rect(200, 370, 80, 105);
  //ears 
  strokeWeight(14);
  fill(242, 160, 147);
  stroke(234, 192, 134);
  ellipse(100, 220, 40, 40);
  ellipse(300, 220, 40, 40);

  // face 
  noStroke();
  fill(234, 192, 134);
  ellipse(200, 250, 200, 250);

  //mouth
  strokeWeight(10);
  stroke(205, 115, 115);
  arc(200, 290, 60, 60, 0, PI);  // upper half of circle
  //more of hair 1 (on top of hair)
  if (hair1) {
    fill(0, 0, 0);
    noStroke();
    strokeWeight(20);
    arc(200, 145, 125, 50, 0, PI, OPEN);
    ellipse(200, 140, 105, 30);
  }
  //eyes
  noStroke();
  fill(255, 255, 255);
  ellipse(155, 220, 35, 35);
  ellipse(240, 220, 35, 35);

  //pupil
  strokeWeight(7);
  stroke(0, 0, 0);
  fill(139, 69, 19);
  ellipse(constrain(mouseX, 152, 158), constrain(mouseY, 217, 223), 8, 8);
  ellipse(constrain(mouseX, 237, 243), constrain(mouseY, 217, 223), 8, 8);

  //eyebrows
  strokeCap(ROUND);  
  strokeWeight(14);
  fill(0, 0, 0);
  line(125, 190, 178, 190);
  line(215, 190, 268, 190);

  strokeWeight(6);
//assign states of hair to change
  if (state == 0) {
    hair1 = true; 
    hair3 = false;
  } 

  if (state == 1) {
    hair1 = false; 
    hair3 = false;
  }  
  if (state == 2) {
    hair3 = true; 
    hair1 = false;
  }    
  if (hair3) {
    strokeWeight(20);
    line(160, 140, constrain(mouseX, 70, 210), constrain(mouseY, 60, 80));
    line(175, 140, constrain(mouseX, 90, 230), constrain(mouseY, 60, 80));
    line(190, 140, constrain(mouseX, 110, 250), constrain(mouseY, 60, 80));
    line(205, 140, constrain(mouseX, 130, 270), constrain(mouseY, 60, 80));
    line(220, 140, constrain(mouseX, 150, 290), constrain(mouseY, 60, 80));
  }
}

void keyPressed() {
    state += 1;
    if (state == 3) {
      state = 0;
    }
  }

 

 

Leave a Reply