Petunia

5:00 11:00 1:00

A recent obsession of mine – having read “The Coming Technological Singularity” by Vinge Vernor in my writing course –  is the notion of humans playing machine roles. What would a person look like as a vacuum cleaner? Toaster? Clock? Petunia the Clockman has a biological affinity with time, as represented by seconds, hours, and minutes. That is, the boils on his forehead correspond to the current number of hours, and the movement of the flower on his head to the number of seconds in the current minute. He blinks the current number of minutes in binary every six seconds (one second per bit). Golan pointed out that the blinking aspect of the clock has nothing to do with the boil aspect – a criticism I agree with. So an improved version of the clock might rely on just one display mechanism instead of three working in tandem. Or it might dispose of the 12-hour clock altogether. That said, I’m pleased with the way in which Petunia’s eyes follow the flower on his head.

Man man;
PImage ball;

void setup() {
  size(400, 400);
  man = new Man();
  ball = loadImage("ball.png");
  smooth();
}

void draw() {  
  background(224,255,228);
  tint(254,219,255);
  man.update();
  man.drawMe();
}

void mousePressed() {
 saveFrame(); 
}
class Antennae {
  PVector pos;
  PImage antennae;
  PImage petunia;
  float rot, initRot;
  int scaleDown = 2;
  int num;

  Antennae(PVector _pos, float _rot, int _num) {
    pos = _pos;
    initRot = _rot;
    num = _num;
    antennae = loadImage("antennae.png");
    petunia = loadImage("petunia.png");
  } 

  void update() {
    float theta = map(millis()%60000,0,59999, 0, TWO_PI);
    rot = map(sin(theta), -1, 1, -.19, .19);
  }

  void draw() {
    translate(pos.x, pos.y - (antennae.height/(scaleDown*2)));
    rotate(initRot);
    for (int i = 0; i < num; i++) {
      image(antennae, 0, 0, 1.3*(antennae.width/scaleDown), antennae.height/(scaleDown*2)); 
      translate(0, .8 * (antennae.height/(scaleDown*2)));
      rotate(rot);
      pushMatrix();
      rotate(millis()/5000.0); 
      if(i == num-1) {
        image(petunia,-petunia.width/2,-petunia.height/2);
      }
      popMatrix();
    }
  }
}
class Man {

  ArrayList a = new ArrayList();
  PImage closeEyes, eyes, headCloseEyes, headOpenEyes, openEyes;
  PImage[] pimps = new PImage[12];
  PVector lEyePos = new PVector(373, 367), rEyePos = new PVector(436, 367);
  int bobAmp = 3;
  int blinkFrame = 0;
  int numAntennae = 1;
  int eyesX;

  Man() {
    loadImages();
    generateAntennae();
  }

  void update() {
    blink();
  }

  void blink() {
    String binMinutes = Integer.toBinaryString(minute());
    int blinkBracket  = second()/10;
    int numToAdd = 6 - binMinutes.length();
    for (int i = 0; i < numToAdd; i++) {
      binMinutes = "0" + binMinutes;
    }    

    if (binMinutes.charAt(second() % 6) == '1' && abs(frameCount - blinkFrame) >= 30) {
      blinkFrame = frameCount;
    }
  }

  void drawMe() {
    translate(0, height*.2);
    pushMatrix();
    drawHead();
    popMatrix();
    drawAntennae();
  }

  void loadImages() {

    for (int i = 0; i < 12; i++) {
      pimps[i] = loadImage((i + 1) + ".png");
    }

    closeEyes = loadImage("close-eyes.png");
    eyes = loadImage("eyes.png");
    headCloseEyes = loadImage("head-close-eyes.png");
    headOpenEyes = loadImage("head-open-eyes.png");
    openEyes = loadImage("open-eyes.png");
  }

  void generateAntennae() {
    for (int i = 0; i < numAntennae; i++) {
      a.add(new Antennae(new PVector(206, 153), random(2, 3), 10));
    }
  }

  void drawHead() {    
    float bobHead = map(frameCount % 200, 0, 199, 0, TWO_PI);
    pushMatrix();
    image(headOpenEyes, 0, 0, width, height);
    pushMatrix();
    float eyeCreep = map(cos(atan2(eyesX+width/2, height/2)), 0, 1, 7, -5);
    translate(eyeCreep, 0);
    image(eyes, 0, 0, width, height);
    popMatrix();
    image(openEyes, 0, 0, width, height);
    if (frameCount == blinkFrame || 
      (mousePressed && mouseX > width * .35 && mouseX < width * .682)) {
      image(headCloseEyes, 0, 0, width, height);
      image(closeEyes, 0, 0, width, height);
    }    
    int hour = ((hour()+1) > 12) ? hour() - 12 : hour();
    for (int i = 0; i < hour; i++) {
      image(pimps[i], 0, 0, width, height);
    }
    popMatrix();
  }

  void drawAntennae() {
    for (int i = 0; i < numAntennae; i++) {
      Antennae _a = (Antennae) a.get(i);
      pushMatrix();
      _a.update();
      _a.draw();
      popMatrix();
      eyesX = int(map(_a.rot, 0, .19, 0, width));
    }
  }
}

Comments are closed.