egg time(r)

hours = yolks in the pan. minutes = rotation of pan. month = eggs in carton. this one hurt my brain the most so far!

sketch

// jaden luscher
// jluscher@andrew.cmu.edu
// section a
// project-06: abstract clock
// EGG CLOCK
// the egg clock counts hours as eggs cracked in the pan,
// months as eggs in the carton, and minutes as the rotation of the pan.

// INITIATING VARIABLES
var xYolk = 0;    // first yolk starts north-facing
var yYolk = 40;   // distance between yolk and center of pan
var hr;
var mo;

function setup() {
  createCanvas(400, 300);
  noStroke();
  angleMode(DEGREES);
  frameRate(10);
}

function draw() {
  background(240);
  translate(150, 150);  // center of pan

  hr = hour() % 12; // convert 24 hour clock to 12
  mo = month();

  stovetop();

  // EGG WHITE
  fill(255);
  ellipse(0, 0, randomGaussian(110,1));

  // EGG YOLK
  push();
  for (var i = 0; i <= hr; i++) {
    eggYolk(xYolk, yYolk);
    rotate(360 / hr);
  }
  pop();

  // EGG CARTON
  eggcarton();
  monthcounter();
}

function stovetop() {
  // SHADOWS
  push();
  fill(220);
  rect(90, 90, -15, -240);
  rect(-90, 90, -15, -240);
  rect(90, 90, -240, -15);
  // GRATES
  noFill();
  strokeWeight(4);
  stroke(120);
  line(-150, 90, 90, 90);
  line(-150, 0, 90, 0);
  line(-150, -90, 90, -90);
  line(90, 90, 90, -150);
  line(0, 90, 0, -150);
  line(-90, 90, -90, -150);
  pop();
  // PAN
  push();
  fill(150);    // grey for pan
  rotate(minute()*6);
  minutecounter();
  ellipse(0, 0, 140);   // pan outer circle
  fill(120);
  ellipse(0, 0, 130);    // pan inner circle
  pop();
}

function eggYolk(xYolk, yYolk) {
  fill(255, 180, 0);
  ellipse(xYolk + noise(-1, 1), yYolk + noise(-1, 1), random (18, 20));
}

// PAN HANDLE ROTATES 360 DEGREES BY THE HOUR
function minutecounter() {
  push();
  fill(220, 20, 20);
  rect(-8, -80, 16, -50);
  ellipse(0, -130, 16);
  pop();
  rect(-6, 0, 12, -80);
}

function eggcarton() {
  push();
  fill(240, 230, 210);  // light grey
  rect(145, -95, 70, 190);
  fill(220, 220, 210);  // darker grey
  rect(215, -95, 35, 190);
  translate(165, -75);
  var x = 0;
  var y = 0;

  // EMPTY EGG CARTON (GREY DOTS)
  for (var j = 0; j < 2; j++) {
    for (var i = 0; i < 6; i++) {
      ellipse(x, y, 28);
      y += 30;
    }
    y = 0;
    x += 30;
  }
  pop();
}

function monthcounter() {
  push();
  translate(165, -75);
  fill(255);
  var x = 0;
  var y = 0;
  // EGGS FOR JANUARY TO JUNE
  for (var j = 0; j < constrain(mo, 0, 6); j++) {
    ellipse(x, y, 22);
    y += 30;
  }
  // EGGS FOR MONTHS JULY TO DECEMBER
  y = 0;
  x += 30;
  for (var j = 6; j < mo; j++) {
    ellipse(x, y, 22);
    y += 30;
  }
  pop();
}

Leave a Reply