Brandonhyun- Project-06-Clock

sketch

//Brandon Hyun
//bhyun1@andrew.cmu.edu
//15104 SectionB
//Project06-Clock

var fryingPan;
var innerFryingpan;
var value;
var c;
var yolk;
var limit;
var changeeggwhiteColor;
var rpos1;
var rpos2;
var changePositionegg;
var prevSec;
var millisRolloverTime;



function setup() {
  createCanvas(400, 400);
	fryingPan = 0;
	limit = 120;
	innerFryingpan = 40;
	yolk = color(255, 204, 0);
  millisRolloverTime = 0;

}

function draw() {
  var H = hour();
  var M = minute();
  var S = second();
  var areaCircle = ellipse(width/2,height/2,280,280);
  var rcircle = random(areaCircle);

background(220);
	changeeggwhiteColor = map(S, 0, 60, 40, 255, true);
  changePositionegg = map(S, 0, 60, 100, 400, true);
  //print(changePositionegg);

	c = color(200, 200, 200, changeeggwhiteColor);

  value = alpha(c);

  if (prevSec != S) {
       millisRolloverTime = millis();
   }
   prevSec = S;
   var mils = floor(millis() - millisRolloverTime);

   fill(128,100,100);
   text("Hour: "   + H, 10, 22);
   text("Minute: " + M, 10, 42);
   text("Second: " + S, 10, 62);
   text("Millis: " + mils, 10, 82);

   var hourBarWidth   = map(H, 0, 23, 0, width);
   var minuteBarWidth = map(M, 0, 59, 0, width);
   var secondBarWidth = map(S, 0, 59, 0, width);

	fill(fryingPan);
	ellipse (width/2,height/2,300,300);
	fill(innerFryingpan);
	ellipse (width/2,height/2,280,280);



  var i = map(S, 0, 60, 200, 400, true);
  if (i > 300) i = 600 - i;
  var j = width - sqrt(90000 - i*i);
  print(i);
  print(j);






  fill(value);
	noStroke();
	ellipse (i,j-100,100,100);
	ellipse (i-40,j-100,50,50);
	ellipse (i-30,j-70,40,50);
	ellipse (i+30,j-80,60,60);
	ellipse (i-10,j-130,60,60);
	ellipse (i+20,j-120,60,60);
  // ellipse (i,j,100,100);
	// ellipse (i-40,j,50,50);
	// ellipse (i-30,j+30,40,50);
	// ellipse (i+30,j+20,60,60);
	// ellipse (i-10,j-30,60,60);
	// ellipse (i+20,j-20,60,60);
//yolk
	fill(yolk);
	ellipse (i+10,j-110,50,50);




}

For this Assignment, I tried to emulate egg cooking on a frying pan. As minute passes, the egg gets fried and the egg yolk becomes whiter.

I had some difficulty getting the entire egg in a random position every time a minute passes. However, it was really nice working with the time variable and pitch my interest of cooking into this project.

Leave a Reply