Catherine Coyle – Project 06 – Abstract Clock

 

sketch

// Catherine Coyle
// ccoyle@andrew.cmu.edu
// Section C
// Project 6 - Abstract Clock


var notes = [];
var audience = [];
var mouthY = 120;
var dir = .3;

function setup() {
  createCanvas(480, 480);
}

function draw() {
  var H = hour() % 12;
  var M = minute();
  var S = second();

  // this accounts for an off by 1 error that happens in the afternoon
  if (hour() > 12) {
    H = (hour() % 12) - 1;
  }


  // resetting the storage of notes/audience members every
  // new minute/new hour
  if (S == 0) {
    notes = [];
  }

  if (M == 0) {
    audience = [];
  }

  // the basic bg art of the clock is gonna be really complicated
  // so to keep draw() from getting too messy im doing it 
  // in another function
  drawBG();

  // generating randomized notes
  for(var i = 0; i < S; i++) {
    // only add on one per draw call so its not
    // generating a ton of notes every second
      if (i == notes.length) {
        notes.push([random(15,width-10), random(height / 2), 
          random(-3,3), random(-3,3), 1, 1]);
      }
  }

  // do same thing for minutes
  for(var i = 0; i < M; i++) {
      if (i == audience.length) {
        audience.push([random(20, width - 20), random(height / 2 + 80, height - 20)]);
      }
  }


  // i want to draw the notes and have them float around!
  for(var i = 0; i < notes.length; i++) {
      // 0 is x, 1 is y, 2 is xvel, 3 is yvel, 4 is xdir, 5 ydir
      notes[i][0] += notes[i][4] * notes[i][2];
      if (notes[i][0] > width - 10 || notes[i][0] < 15) {
        notes[i][4] = -1 * notes[i][4]
      }
      notes[i][1] += notes[i][5] * notes[i][3];
      if (notes[i][1] > height / 2 + 20 || notes[i][1] < 0) {
        notes[i][5] = -1 * notes[i][5];
      }
      // this whole thing is just basic movement stuff
      // but it looks more complicated bc the values are stored in
      // nested lists
      drawNote(notes[i][0], notes[i][1]);
  }

  // partially hardcoding drawing locations for coffee cups (hours)
  for(var i = 0; i <= H; i++) {
      if (i < 3) {
        drawCoffee(25 + i*45, height / 2 + 20);
      }
      if ((i >= 3) & (i < 5)) {
        drawCoffee(50 + (i - 3) * 45, height / 2 - 23);
      }
      if (i == 5) {
        drawCoffee(75 + (i - 5) * 45, height / 2 - 65);
      }
      if ((i > 5) & (i < 9)) {
        drawCoffee(width - 10 - (i - 5) * 45, height / 2 + 20);
      }
      if ((i >= 9) & (i < 11)) {
        drawCoffee(width - 35 - (i - 8) * 45, height / 2 - 23);
      }
      if (i == 11) {
        drawCoffee(width - 105, height / 2 - 65);
      }
  }

  // i want him to be in front of the music
  drawKK();

  // the audience (minutes) are randomized in front of him
  for(var i = 0; i < audience.length; i++) {
      drawAudience(audience[i][0], audience[i][1]);
  }

  // i want his mouth to move as he sings!
  mouthY += dir;
  if (mouthY > 128) {
    dir = -dir;
  }
  if (mouthY < 120) {
    dir = -dir;
  }

  // drawing the actual mouth
  fill(0);
  stroke(0);
  strokeWeight(3);
  line(width / 2, 105, width / 2, 115);
  line(width / 2, 115, width / 2 + 10, 120);
  line(width / 2, 115, width / 2 - 10, 120)
  noStroke();
  quad(width / 2 + 10, 120, width / 2, 115, width / 2 - 10, 120, width / 2, mouthY);

  // i want him to blink too
  drawEyes(S);

  drawSpotlight();

}



// everything below here is less coding magic and
// more magic numbers for graphics
function drawBG() {
    noStroke();
    background(193, 120, 51);
    // platform top
    fill(197, 155, 113);
    rect(0, height / 2 + 40, width, 200);
    // platform front
    fill(132, 62, 11);
    rect(0, height / 2 + 70, width, 200);
}

function drawKK() {
    // stool legs
    fill(209, 175, 66);
    rect(width / 2 - 60, height / 2, 20, 60);
    rect(width / 2 + 40, height / 2, 20, 60);
    fill(201, 146, 58); // back leg
    rect(width / 2 - 10, height / 2, 20, 45);
    // stool
    fill(201, 146, 58); // stool shadow
    ellipse(width / 2, height / 2 + 3, 150, 38);
    fill(209, 175, 66); // this is the main stool color
    ellipse(width / 2, height / 2, 150, 30);
    // kk body
    fill(255);
    ellipse(width / 2, 180, 90, 120)
    fill(247, 242, 234); // kk shadow color
    ellipse(width / 2, 110, 68, 68);
    // kks head
    fill(255);
    ellipse(width / 2, 75, 90, 90);
    ellipse(width / 2, 100, 70, 70);
    // eyebrowsss
    fill(0);
    ellipse(width / 2 + 22, 65, 23, 25);
    ellipse(width / 2 - 22, 65, 23, 25);
    fill(255);
    ellipse(width / 2 + 22, 70, 24, 15);
    ellipse(width / 2 - 22, 70, 24, 15);
    // ears
    noStroke();
    fill(255);
    triangle(width / 2 + 40, 40, width / 2 + 60, 40, width / 2 + 57.5, 70);
    triangle(width / 2 - 40, 40, width / 2 - 60, 40, width / 2 - 57.5, 70);
    // right leg
    ellipse(width / 2 + 25, height / 2 - 10, 35, 100);
    fill(247, 242, 234);
    ellipse(width / 2 + 30, height / 2 + 40, 30, 30);
    fill(255);
    ellipse(width / 2 + 30, height / 2 + 35, 30, 30);
    //left leg
    fill(255);
    ellipse(width / 2 - 15, height / 2 - 5, 70, 35);
    fill(247, 242, 234);
    ellipse(width / 2 + 18, height / 2, 20, 28);
    fill(255);
    ellipse(width / 2 + 15, height / 2, 20, 30);
    // guitar neck
    fill(160, 109, 27);
    rect(width / 2, height / 2 - 60, 130, 20);
    fill(102, 69, 17);
    rect(width / 2 + 120, height / 2 - 62.5, 30, 25);
    fill(183, 177, 167); // little knobs at the end
    ellipse(width / 2 + 125, height / 2 - 65, 4, 4);
    ellipse(width / 2 + 135, height / 2 - 65, 4, 4);
    ellipse(width / 2 + 145, height / 2 - 65, 4, 4);
    ellipse(width / 2 + 125, height / 2 - 35, 4, 4);
    ellipse(width / 2 + 135, height / 2 - 35, 4, 4);
    ellipse(width / 2 + 145, height / 2 - 35, 4, 4);
    // guitar body
    fill(209, 175, 6);
    beginShape();
    curveVertex(192, 220);
    curveVertex(181, 188);
    curveVertex(187, 160);
    curveVertex(199, 153);
    curveVertex(221, 156);
    curveVertex(234, 163);
    curveVertex(247, 162);
    curveVertex(256, 160);
    curveVertex(267, 167);
    curveVertex(277, 188);
    curveVertex(277, 205);
    curveVertex(268, 213);
    curveVertex(254, 214);
    curveVertex(239, 213);
    curveVertex(228, 217);
    curveVertex(210, 221);
    curveVertex(185, 211);
    curveVertex(181, 188);
    curveVertex(183, 173);
    endShape();
    // guitar details
    fill(175, 123, 40); // background thing
    ellipse(width / 2 + 3, height / 2 - 45, 30, 20);
    fill(102, 69, 17); // hole
    ellipse(width / 2 + 10, height / 2 - 52, 25, 25);
    ellipse(width / 2 - 30, height / 2 - 52, 10, 25);
    // kks hands
    fill(255);
    ellipse(width / 2 - 55, height / 2 - 75, 30, 30);
    ellipse(width / 2 + 70, height / 2 - 35, 30, 30);
}

function drawCoffee(x, y) {
    // mug
    noStroke();
    fill(255);
    rect(x, y, 30, 40);
    ellipse(x + 15, y, 30, 5);
    ellipse(x + 15, y + 40, 30, 5);
    // handle
    stroke(255);
    strokeWeight(5);
    noFill();
    ellipse(x, y + 20, 20, 20);
    // coffee
    noStroke();
    fill(132, 62, 11);
    ellipse(x + 15, y, 25, 2);
}

// will draw music note at given coords
function drawNote(x, y) {
  fill(0);
  stroke(0);
  strokeWeight(5);
  line(x, y, x, y + 20);
  noStroke();
  ellipse(x - 5, y + 20, 15, 10);
  triangle(x, y-2.25, x, y + 5.75, x + 12, y + 1.75);
}

// will draw audience member at coords
function drawAudience(x, y) {
  noStroke();
  fill(239, 239, 208);
  ellipse(x, y-1, 48, 50);
  fill(48, 49, 51);
  ellipse(x, y, 50, 50);
  fill(0);
  ellipse(x, y + 3, 46, 46);
}

function drawEyes(S) {
    if (S % 5 == 0) {
      fill(0);
      ellipse(width / 2, 105, 15, 10);
      strokeWeight(3);
      stroke(0);
      noFill();
      beginShape();
      curveVertex(width / 2 + 11, 85);
      curveVertex(width / 2 + 11, 85);
      curveVertex(width / 2 + 22, 88);
      curveVertex(width / 2 + 34, 85);
      curveVertex(width / 2 + 34, 85);
      endShape();
      beginShape();
      curveVertex(width / 2 - 11, 85);
      curveVertex(width / 2 - 11, 85);
      curveVertex(width / 2 - 22, 88);
      curveVertex(width / 2 - 34, 85);
      curveVertex(width / 2 - 34, 85);
      endShape();

    } else {
      // eyes and nose
      fill(0);
      ellipse(width / 2 + 22, 75, 15, 15);
      ellipse(width / 2 - 22, 75, 15, 15);
      ellipse(width / 2, 105, 15, 10);
      //eyelids
      strokeWeight(3);
      stroke(0);
      beginShape();
      curveVertex(width / 2 + 11, 71);
      curveVertex(width / 2 + 11, 71);
      curveVertex(width / 2 + 22, 68);
      curveVertex(width / 2 + 34, 71);
      curveVertex(width / 2 + 34, 71);
      endShape();
      beginShape();
      curveVertex(width / 2 - 11, 71);
      curveVertex(width / 2 - 11, 71);
      curveVertex(width / 2 - 22, 68);
      curveVertex(width / 2 - 34, 71);
      curveVertex(width / 2 - 34, 71);
      endShape();
    }
}

function drawSpotlight() {
  noStroke();
  fill(0, 0, 0, 30);
  quad(0, 0, width / 2 - 70, 0, width / 2 - 150, height / 2 + 70, 0, height / 2 + 70);
  quad(width, 0, width / 2 + 70, 0, width / 2 + 150, height / 2 + 70, width, height / 2 + 70);
  rect(0, height / 2 + 70, width, 200);
}

I simultaneously had a really fun time with this project while I’m also extremely happy I’m finished.

Anyone who’s played the Nintendo game Animal Crossing will recognize this character as KK Slider. Animal Crossing has always been one of my favorite series, and I thought that it was fitting to do a project related to it for this assignment because the game plays in real time as well.

Here was my initial sketch design for the clock

The musical notes represent seconds, audience members minutes, and coffee mugs hours.

I had a lot more trouble with this than I expected too. I got stuck on more than a few off by one errors, and its probably the most graphically complex project I’ve made for this class so far. I had a really hard time with plotting out the acoustic guitar (it’s still a bit lopsided but much better now). I ended up writing a program that would let me click on the screen where I wanted to place my dots and then would print the array of coordinates. It also removed the most recent coordinate when you clicked a key because it was very easy to mess up, and I didn’t want to have to start over entirely.

Screenshot of the program I mention above (was really useful for this)

Altogether this project was fun and I’m really proud of what I made! (My code is super long so I’m crossing my fingers for no missed style errors.)

Sharon Yang Project 06 Abstract Clock

Project

/*Sharon Yang
Section C
junginny
Project-06
*/

function setup() {
    createCanvas(640, 480);
}

function draw() {
    //fetch time
    var H = hour();
    var M = minute();
    var S = second();
    background(182,211,232);
    angleMode(DEGREES);

    //ground
    fill(109,67,48);
    noStroke();
    rect(0,455,640,480);

    //rain drops for seconds
    strokeWeight(2);
    stroke(255);
    var rainSpeed;
    rainSpeed = 0;
    frameRate(1);
    for (var i = 0; i <= S; i++) {
        push();
        translate(random(10,width-10),rainSpeed);
        line(0,rainSpeed,0,rainSpeed+30);
        rainSpeed+=15; 
        pop();
    }

    //plants for minutes
    var amountMap; //number of plants = minutes
    var plantY;
    fill(97,120,50);
    if (M == 1) {
        strokeWeight(2);
        stroke(97,120,50);
        push();
        translate(width/2,height-25);
        plantY = random(-20,-60);
        line(0,0,0,plantY);
        noStroke();
        ellipse(-5,plantY,10,5);
        ellipse(5,plantY,10,5);
        pop();
    }
    else {
        for (var amount = 1; amount <= M; amount++) {
            amountMap = map(amount-1,0,M-1,15,width-25); 
            strokeWeight(2);
            stroke(97,120,50);
            push();
            translate(0,height-25);
            plantY = random(-20,-60);
            line(amountMap,0,amountMap,plantY);
            noStroke();
            ellipse(amountMap-5,plantY,10,5);
            ellipse(amountMap+5,plantY,10,5);
            pop();
        }
    }

    //petals on the flower for hours
    if (H > 12) { //0~12 hours 
        H = H % 12
    }
    stroke(97,120,50);
    strokeWeight(4);
    line(320,230,320,455);
    noStroke();
    fill(242,155,174);
    for (var i = 0; i < H; i++) {
        push();
        translate(320,220);
        rotate(i * 30);
        ellipse(0,-25,15,60);
        pop();
    }
    noStroke();
    fill(175,23,104);
    ellipse(320,220,40,40);//bigger flower center
    fill(95,40,100);
    ellipse(320,220,25,25);//smaller flower center

}

For this project, I wanted to incorporate graphics with the clock function, and so I decided to make a flower to indicate the hours, the plants to indicate the minutes and the raindrops to indicate the seconds. I encountered several challenges including placing the plants without them overlapping as their number increases each minute. I resolved that my using the map function. The rotation and translation of the flower petals was also quite difficult but it became more simple once I converted the time to 12 hours instead of 24 hours.

Katherine Hua – Project-06 – Abstract Clock

sketch

/* Katherine Hua
Section A
khua@andrew.cmu.edu
Project-06-Abstract-Clock */

var prevSec;
var millisRolloverTime;

function setup() {
    createCanvas(480, 480);
}

function draw() {
	background(0); //setting background to black

	var h = hour();
	var m = minute();
	var s = second();
	var ms = millis();

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

	//creating lines marking the center of the circle
	stroke(75);
	strokeWeight(1);
	line(240, 120, 240, 360);
	line(120, 240, 360, 240);

	//text
	fill(255); 
	textAlign(CENTER); //centering text
	text(nf(h, 2, 0) + ' : ' + nf(m, 2, 0) + ' : ' + nf(s, 2, 0), 240, 400); //using nf function to make numbers have two digits at all times

	//creating the grey outlines of circles based on their width
	for (var x = 0; x < 15; x++) { 
		noFill();
		stroke(50);
		strokeWeight(1);
		ellipse(240, 240, x * 16, 240)
	}

	//creating the grey outline of circles based on their height
	for (var y = 0; y < 15; y++) {
		noFill();
		stroke(50);
		strokeWeight(1);
		ellipse(240, 240, 240, y * 16);
	}

//milliseconds - orange circle: height of circle changes with millisecond; hits full circle every second
	var msHeight = map(mils, 0, 1000, -240, 240); 
	push();
	stroke(238, 99, 43, 255);
	strokeWeight(2);
	noFill();
	ellipse(240, 240, 240, msHeight);
	pop();

//seconds - yellow circle: width of circle changes with second; hits full circle every minute
	var sFrac = s + (mils / 1000.0);
	var sWidth = map(sFrac, 0, 60, -240, 240);
	push();
	stroke(243, 205, 70, 255);
	strokeWeight(2);
	noFill();
	ellipse(240, 240, sWidth, 240);
	pop();

//minutes - pink circle: width of circle changes with minute; hits full circle every hour
	var mFrac = m + (s / 60.0);
	var mWidth = map(mFrac, 0, 60, -240, 240);
	push();
	stroke(224, 83, 152, 255);
	strokeWeight(4);
	noFill();
	ellipse(240, 240, mWidth, 240);
	pop();

//hours - purple circle: height of circle changes with every hour; hits full circle every 24 hours
	var hFrac = h + (m / 60.0);
	var hHeight = map(hFrac, 0, 24, -240, 240);
	push();
	stroke(112, 45, 156, 255);
	strokeWeight(5);
	noFill();
	ellipse(240, 240, 240, hHeight);
	pop();



}

I wanted to create a clock that gives a more spacey-vibe to reflect time’s relationship with the movement of solar systems. I did this by creating the circular grid which can appear like longitude and latitude lines. Each moving element corresponds to its respective time (hour, minute, second, or millisecond). I was inspired by Min Lee’s design with how he used a circle of changing width so my design is based off of what I learned from him. I had a difficult time at first getting the movement of the circle right; it was not moving smoothly or would not complete a full turn. This project helped me familiarize myself more with how time can be utilized in coding.

Justin Yook – Project 06 – Abstract Clock

abstractClock

//Justin Yook
//jyook@andrew.cmu.edu
//Section C
//Project 06

var prevSec;
var millisRolloverTime;

var sizeS = []; // stores sizes for each seconds raindrop drawn
var xS = []; // stores x coordinates for seconds raindrop
var yS = []; // stores y coordinates for seconds raindrop

var sizeM = 0; // starting size of minute raindrop
var sizeH = 0; // starting sizse of hour raindrop

function setup() {
    createCanvas(300, 300);
    background(164, 194, 205);
}

function draw() {
    var S = second(); // keeps track of each second 
    var M = 0; // keeps track of each minute
    var H = 0; // keeps track of each hour

    // make sure that the second matches up properly with milliseconds passed
    if (prevSec != S) {
        millisRolloverTime = millis();
    }
    prevSec = S;
    var mils = floor(millis() - millisRolloverTime);

    // i represents current seconds raindrop
    for (var i = 0; i < S; i++) {
        var rxS = random(0, 300); // random x location of seconds raindrop
        var ryS = random(0, 300); // random y location of seconds raindrop
        xS.push(rxS); // append random x location of seconds raindrop to xS array
        yS.push(ryS); // append random y location of seconds raindrop to yS array

        var osizeS = 0; // all raindrops have size of 0 before expanding
        sizeS.push(osizeS); // append size of seconds raindrop to sizeS array


        fill(75, 105, 125, 200);
        noStroke();
        ellipse(xS[i], yS[i], sizeS[i], sizeS[i]);
        sizeS[i] += 1;
        
        // limit size of second raindrop size
        if (sizeS[i] > 40) {
            sizeS[i] = 40;
            fill(164, 194, 205);
            rect(0, 0, width, height);
        }

        // if second() reaches 59 seconds
        if (S % 59 == 0) {
            sizeS = [];
            xS = [];
            yS = [];
            M += 1; 

            // draw minute raindrop
            fill(75, 105, 125, 200);
            ellipse(width/2, height/2, sizeM, sizeM);
            sizeM += 1;

            // limit size of minute raindrop
            if (sizeM > 80) {
                sizeM = 80;
            }

            // if M reaches 59 minutes
            if (M % 59 == 0) {

                // draw hour raindrop
                fill(75, 105, 125, 200);
                ellipse(width/2, height/2, sizeH, sizeH);
                sizeH += 1;

                // limit size of hour raindrop
                if (sizeH > 120) {
                    sizeH = 120;
                }
            }
        }
    }
}

For this project, I tried to imitate raindrops falling into a pond. Every second, a small raindrop falls. And once it is one minute, a bigger raindrop appears. The hour raindrop follows the same idea. This project was the most difficult by far in my opinion, because I had to fully understand arrays to utilize it properly.

Basic sketch of raindrops on canvas

Hannah Cai—Project 06—Abstract Clock

/* Hannah Cai
Section C
hycai@andrew.cmu.edu
Project-06-Abstract Clock
*/

function setup() {
    createCanvas(480,480);
    background(255);
}

function draw() {
    //background
    //wall
    noStroke();
    fill(222, 255, 251);
    rect(0, 0, 480, 420);
    //table
    fill(255, 192, 224);
    rect(0, 380, 480, 90);

    //tv
    //antennae base
    fill(0);
    ellipse(233, 165, 40, 40); 
    //antennae
    stroke(0);
    strokeWeight(2);
    line(185, 35, 220, 150); 
    line(285, 35, 245, 150); 
    //antennae tips
    strokeWeight(5);
    point(185, 35); 
    point(285, 35); 
    //feet
    noStroke();
    fill(255);
    rect(115, 408, 20, 10, 0, 0, 3, 3); 
    rect(340, 408, 20, 10, 0, 0, 3, 3); 
    //base
    fill(40);
    rect(104, 398, 265, 10); 
    //body
    rect(66, 165, 345, 233, 13, 13, 25, 25); 
    fill(0);
    rect(76, 172, 325, 220, 13, 13, 25, 25);
    //screen
    noStroke();
    fill("White");
    rect(108, 213, 192, 138, 25, 25, 28, 28); 
    //control bar
    fill(80);
    rect(327, 185, 45, 190, 3, 3, 3, 3); 
    fill(0);
    rect(329.5, 269, 40, 11);
    rect(329.5, 283, 40, 90);
    //knob 1
    fill(0);
    ellipse(350, 207, 36, 36);
    fill(80);
    ellipse(350, 207, 12, 12); 
    stroke(0);
    strokeWeight(2);
    line(350, 188, 350, 220);
    //knob 2
    fill(0);
    ellipse(350, 247, 30, 30);
    fill(80);
    ellipse(350, 247, 8, 8);
    line(350, 230, 350, 233);
    //other knobs
    fill(40);
    ellipse(387, 196, 14, 14);
    ellipse(387, 216, 11, 11);
    noFill();
    stroke(255);
    strokeWeight(1);
    ellipse(387, 271, 8, 8);
    ellipse(387, 312, 8, 8);
    ellipse(387, 354, 8, 8);

    //time variables
    // var H = hour();
    // var M = minute();
    // var S = second();
    var H = hour();
    var M = minute();
    var S = second();
    //maps time to screen width
    var mappedH = map(H, 0, 24, 0, 192);
    var mappedM = map(M, 0, 60, 0, 192);
    var mappedS = map(S, 0, 60, 0, 192);
    //color blocks
    push();
    blendMode(DIFFERENCE); //overlays the screen colors
    noStroke();
    fill("Red");
    rect(108, 213, mappedH, 138);
    fill("Green");
    rect(108, 213, mappedM, 138);
    fill("Blue");
    rect(108, 213, mappedS, 138);
    pop();

    //screen border
    noFill();
    stroke(0);
    strokeWeight(20);
    rect(98, 205, 212, 153, 32, 32, 38, 38); 
    stroke(40);
    strokeWeight(2);
    rect(90, 200, 227, 163, 4, 4, 7, 7);

}


For this project, I was initially planning to just have a simple square with overlaid colors, but while writing that code, I was reminded of old tvs, especially those with glitched screens:

I was inspired by that idea, so I sketched up a tv in Illustrator, put it into p5, and then modified my code so that the colors would fit to the screen.

The color layers are red, blue, and green (RBG) under the blend mode “difference,” so as they overlap and interact with each other, the screen’s color palette changes. The colors on the screen do not change only by the minute, but also by the time of day (based on the position of the hours, minutes, and seconds layers in relationship to each other).

Alexandra Kaplan – Project 06- Abstract Clock

sketch

/* Alexandra Kaplan
   aekaplan@andrew.cmu.edu
   Section C
   Project - 06
*/

var dropY = 100;
var dropX = 150
var xarray = [110];
var yarray = [105];

function setup() {
    createCanvas(400, 300); 
    frameRate(30); //each second is 30 frames
}

function draw() {
    background(230, 250, 255);
    var H = hour(); // current hour
    var M = minute(); // current minute
    var S = second(); // current second
    var milli = second(); //current millisecond
    var HWaterHeight = map(M, 0, 59, 0, height); // chages the height of the water according to the minute
    var waterColorb = map(H, 0, 23, 255, 120); // water changes from blue to grey over 24 hours
    var dropW = map(S, 0, 59, 25, 5); // water drops gets smaller as gets closer to a minute 
    
    // draw water level
    strokeWeight(0);
    fill(150, 170, waterColorb); // water changes from blue to grey over 24 hours
    rect(0, height - HWaterHeight, width, HWaterHeight);
    
    //draw water drops
    fill(170, 200, 225);    
    for(var i = 0; i < yarray.length; i++){ // draws water drop falling
    	ellipse(xarray[i], yarray[i], dropW, 20);
			yarray[i] += 5;      
    }

    if(frameCount % 30 === 0){ // every second a new drop is drawn
    	yarray.push(105);
        xarray.push(random(110, 140)) // randomizes x position of water droplets
    }

	faucet(); // draws faucet
}

function faucet(x, y){
	stroke(100);
	fill(120);
	rect(100, 80, 50, 35, 0, 0, 5, 5);
	rect(0, 40, 150, 50, 0, 10, 0, 0);
	stroke(160);
	strokeWeight(1);
	line(101, 113, 149, 109);
	line(100, 108, 149, 104);
	line(100, 103, 149, 99);
	line(100, 98, 149, 94);
}



For this project, I took inspiration from a leaky faucet. It keeps track of time by dripping once per second, the water goes from the bottom to the top every hour, and the color of the water changes from blue to green-brown throughout a 24 hour time period. It was definitely a more difficult project than I originally anticipated, as I had to draw on and combine a lot of concepts we have learned throughout the class. The part that I had the most trouble with was getting a new drop to drip at every second.

Sketch of original concept

Jonathan Liang – Project 6 – Abstract Clock

sketch

//Jonathan Liang
//jliang2
//section A






var ballX = 200;
var ballY = 0;
var speedX = 5;
var count = 0;
var xS = [];
var yS = 0;
var xM = [];
var yM = 0;
var xH = [];
var yH = 0;
var ySpeedS = 10;
var ySpeedM = 5;
var ySpeedH = 3;
var radius = 20;

var action = false;
var dayColor = 255;





function setup() {
    createCanvas(400, 400);
    
 //seconds 
    for (var i = 1; i < 60; i++) {
    	xS[i] = random(20, width - 20);
    	
    }
 //minutes   
    for (var i = 1; i < 60; i++) {
    	xM[i] = random(20, width - 20);
    }
 //hours
 	for (var i = 1; i < 12; i++) {
 		xH[i] = random(20, width - 20);
 	}
}

function draw() {

	frameRate(3);	

//fetching current time
	var H = hour();
    var M = minute();
    var S = second();
    dayColor = map(H, 0, 24, 255, 0);
    H = H % 12;

//background color
	background(dayColor);


//hours
	for (var i = 0; i <= H; i++) {
		noStroke();
		fill(128, 212, 255);
		ellipse(xH[i], yH, radius);
		xH[i] += speedX;
		yH += ySpeedH;
		if (yH > height-20 || yH < 0) {
			ySpeedH = -ySpeedH;
			radius += 10;
		}
		if (xH[i] > height-20 || xH[i] < 0) {
			speedX = -speedX;
			radius += 10;
		}
		

		
	}

//minutes
	for (var i = 0; i <= M; i++) {
		noStroke();
		fill('yellow');
		ellipse(xM[i], yM, 15, 15);
		xM[i] += speedX;
		yM += ySpeedM;
		if (yM > height-20 || yM < 0) {
			ySpeedM = -ySpeedM;
		}
		if (xM[i] > height-20 || xM[i] < 0) {
			speedX = -speedX;
		}
		
	}

//seconds
	for (var i = 0; i <= S; i++) {
		noStroke();
		fill('orange');
		ellipse(xS[i], yS, 10, 10);
		xM[i] += speedX;
		yS += ySpeedS;
		if (yS > height-20 || yS < 0) {
			ySpeedS = -ySpeedS;
		}
		if (xS[i] > height-20 || xS[i] < 0) {
			speedX = -speedX;
		}
		
	}








}

Uh for this project, I start with, with a concept, of the world. The world is so hectic and fast moving that we have trouble keeping track of time. The minutes and seconds represent the stars in the sky and the gradually expanding blue circles (hours) represent the tide of the ocean. The minutes and the seconds move so fast, which is symbolic of how life moves so quickly, that we don’t have time to look at the stars in the sky. This whole paragraph sounds incredibly corny and I’m so sorry that it does.

Jason zhu-Project-06-Abstract Clock

sketch

/* Jason Zhu
jlzhu@andrew.cmu.edu
Section E
Project Abstract Clock
*/

var prevSec;
var millisRolloverTime;

function setup() {
    createCanvas(400, 355);
    background(8, 7, 17);
    millisRolloverTime = 0;
}

function draw() {
    noStroke();
    // Fetch the current time
    var H = hour();
    var M = minute();
    var S = second();
    var MS = millis();

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

    // display hour bar
    if (H==0){
        fill(8, 7, 17);
        rect(30,0,60,360);
    } else {
        for(i=0;i<H;i++){
            var r = (i*(255/23));
            var g = (0);
            var b = (0);
            fill(r,g,b);
            rect(30,(i*(300/23)),60,60);
        }
    }

    // display minute bar
    if (M==0){
        fill(8, 7, 17);
        rect(130,0,60,360);
    } else {
        for(i=0;i<M;i++){
            var r = (0);
            var g = (i*(255/59));
            var b = (0);
            fill(r,g,b);
            rect(130,i*(300/59),60,60);
        }
    }

    // display second bar
    if (S==0){
        fill(8, 7, 17);
        rect(230,0,60,360);
    } else {
        for(i=0;i<S;i++){
            var r = (0);
            var g = (0);
            var b = (i*(255/59));
            fill(r,g,b);
            rect(230,i*(300/59),60,60);
        }
    }

    // display milli/second bar
    if (S==1 || S ==3 || S==5 || S ==7 || S==9 || S ==11 || S==13 || S ==15 || S==17 || S ==19 || S==21 || S ==23 || S==25 || S ==27 || S==29 || S ==31 || S==33 || S ==35 || S==37 || S ==39 || S==41 || S ==43 || S==45 || S ==47 || S==49 || S ==51 || S==53 || S ==55 || S==57 || S ==59){
        fill(8, 7, 17);
        rect(330,0,60,360);
    } else {
            fill(255);
            rect(330,0,60,360);
        }
    
}

For this project I hoped to visualize clocks in a linear and color way. I wanted to represent the individual component of my clock with different R,G,B values. By using color, in addition to slight position cues, the goal was to create another more abstract method of keeping track of the time of the day. I developed the idea by trying to think of other ways that people visualized things. Naturally, color was something that was at the precipice of my mind. Overall, I think I learned a good amount about pulling various information from the world into my code. I imagine additional applications to be things such as pulling weather data or humidity data.

Nina Yoo Project-06-Abstract Clock

sketch

/* Nina Lee Yoo
Section E
nyoo@andrew.cmu.edu
Project-06-Abstract Clock*/

var prevSec;
var millisRolloverTime;
var change = 10

//--------------------------
function setup() {
    createCanvas(300, 300);
    millisRolloverTime = 0;
}

//--------------------------
function draw() {
    background(255,200,200); // My favorite pink
    
    // Fetch the current time
    var H = hour();
    var M = minute();
    var S = second();
    
    // Reckon the current millisecond, 
    // particularly if the second has rolled over.
    // Note that this is more correct than using millis()%1000;
    if (prevSec != S) {
        millisRolloverTime = millis();
    }
    prevSec = S;
    var mils = floor(millis() - millisRolloverTime);
    
    
    var hourBarWidth   = map(H, 0, 23, 0, width);
    var minuteBarWidth = map(M, 0, 59, 0, width);
    var secondBarWidth = map(S, 0, 59, 0, 178);

   

    // the sun is radiating
        noStroke()
        fill(255,205,109)
        ellipse(0,0,mils,mils)

     //sun grows at every hour
      noStroke()
        fill(237,242,109)
        ellipse(0,0,hourBarWidth,hourBarWidth)

        
	 //for the puddle growing every minute
        noStroke();
		fill(108,158,234);
        ellipse(150,200,minuteBarWidth,20);
    

     //for raindrop falling at a rate of a second
        noStroke();
        fill(255);
        triangle(140,secondBarWidth-5,160,secondBarWidth-5,150,secondBarWidth-20);
        fill(255);
        ellipse(150,secondBarWidth,22,22);








    


}



    /*noStroke();
    fill(40);
    ellipse(0, 100, hourBarWidth, 50);
    fill(80);
    ellipse(0, 150, minuteBarWidth, 50);
    fill(120)
    ellipse(0, 200, secondBarWidthChunky, 50);
    fill(160)
    ellipse(0, 250, secondBarWidthSmooth, 50);*/

I wanted to make a raindrop to fall into a puddle because rain is something that has a rythm to it so it reminded me of time. From there on I just added more elements to it pertaining to weather by making the puddles minutes, the drops seconds, the sun the hour, and the radiating part of the sun milliseconds. It was fun doing this project and playing around with the limits in order to create different images.

Elena Deng-Project 6 Abstract Clock

sketch

/*Elena Deng
Section E
  edeng1@andrew.cmu.edu
  Project-06
}
*/

function setup() {
    createCanvas(400, 400);
    // var c=canvas
    // c.rotate(90)
    angleMode (DEGREES);
}

function draw() {

    var H = hour(); //calculates hours
    var M = minute(); //calculates minutes
    var S = second(); //calculates seconds
    var colRatio=2;  //reduces the color gradient each for loop
    noStroke(); //no stroke within the circles

    //does the background
      push();
      translate(200,200); //translates into the middle of the canvas
      background(5,15,53); //sets the background color
      pop();

      //hour hand
      for (var h=0; h<H; h++){
        var r=220; //sets r value
        var g=105; //sets g value
        var b=55; //sets b value
        var colRatio=4; //color value reduces more quickly
          push();
          translate (width/2, height/2);
          rotate((15*h)-.25*360) //24 hour clock
          fill(r+(colRatio*h),g+(colRatio*h),b+(colRatio*h));
          ellipse(35,0,20,20);
          pop();
      }

      //minutes hand
        for(var m =0; m<M; m++){
          var r=250; //sets r value
          var g=175; //sets g value
          var b=65; //sets b value
            push();
            translate (width/2, height/2);
            rotate((6*m)-.25*360); //sets minutes and rotates
            fill(r-(colRatio*m),g-(colRatio*m),b-(colRatio*m));
            ellipse(72,0,15,15);
            pop();
          }


      //seconds hand
        for(var s = 0; s < S; s++) {
        var r=120; //sets r value
        var g=105; //sets g value
        var b=15; //sets b value
        push();
        translate (width/2, height/2); //moves to the middle of canvas
        rotate((6*s)-.25*360); //sets seconds and rotates
        fill(r+(colRatio*s),g+(colRatio*s),b+(colRatio*s)); //sets fill
        ellipse(100,0,10,10);
        pop();
    }


}

This project was pretty fun to do! My favorite part of the result was the color palette as well as the overall effect of the circles. I decided to make it a 24 hour clock so that it can tell the difference between AM and PM.

ideation for Clock (didn’t end up going with these ideas)