Cro­w­d­e­d Faces

by Matthew Chensee
  • Show Sketch
/** @peep sketchcode **/
 
 
void setup() {
  size(200, 200);
  background(204);
  for (int i = 0; i < 50; i++) {
    pushMatrix();
    translate(random(width), random(height));
    float scaleFactor = random(0.15, 0.40);
    scale(scaleFactor);
    if (scaleFactor < 0.20)
    {
      fill(120);
    }
    else if (scaleFactor > 0.30)
    {
      fill(80);
    }
    else
    {
      fill(200);
    }
    strokeWeight(1.0/scaleFactor);
    rotate(radians(random(-10, 10)));
    int fw = random(140, 200);
    int fh = random(180, 200);
    int fx = random(fw/6, 5*fw/6);
    int fy = random(fh/6, 4*fh/6);
    int fgap = random((fw-fx)/5, (fw-fx)/3);
    face(fw, fh, fx, fy, fgap);
    popMatrix();
  }
}
 
void face(int w, int h, int x, int y, int gap) {
  pushStyle();
  pushMatrix();
  translate(-w/2, -h/2);
  rect(0, 0, w, h);
  line(x, 0, x, y);               // Nose Bridge 
  line(x, y, x+gap, y);           // Nose 
  line(x+gap, y, x+gap, h); 
  int mouthY = (h+y)/2;
  line(x, mouthY, x+gap, mouthY); // Mouth 
  fill(0);
  ellipse(x-gap/2, y/2, 5, 5);    // Left eye 
  ellipse(x+gap, y/2, 5, 5);      // Right eye 
  popMatrix();
  popStyle();
}

Comments

Nobody has said anything yet.