lrchu – project 06 – abstract clock

lrchu

// lee chu
// section c
// lrchu@andrew.cmu.edu
// project - 06

var h;
var m;
var s;
var rad = 50;
var start = 58;

var mer;
var ce;
var des;

function setup() {
    createCanvas(480, 300);
    mer = 12;
    ce = 30;
    des = 30;
}

function draw() {
    background(252, 245, 225);
    h = hour();
    m = minute();
    s = second();

    // spinning animation
    mer += 1/60 ; ce += 1/12 ; des += 1/12;

    // digits
    firstDigit(start, 90);
    secondDigit(start + 2 * rad, 90);
    thirdDigit(start + 4.25 * rad, 90);
    fourthDigit(start + 6.25 * rad, 90);

    // second counting dots
    fill(150);
    strokeWeight(0);
    if (s % 2 == 0) {
        ellipse(start + 3.625 * rad, 90 + rad / 2, 10, 10);
        ellipse(start + 3.625 * rad, 90 + 3 * rad / 2, 10, 10);
    }
}

// conditinals for each digit
function firstDigit(x, y) {
    if (h < 10) {
        zero(x, y);
    }
    else if (h > 9 & h < 20) {
        one(x, y);
    }
    else if (h > 19) {
        two(x, y);
    }

}

function secondDigit(x, y) {
    if (h % 10 == 0) {
        zero(x, y);
    }
    else if (h % 10 == 1) {
        one(x, y);
    }
    else if (h % 10 == 2) {
        two(x, y);
    }
    else if (h % 10 == 3) {
        three(x, y);
    }
    else if (h % 10 == 4) {
        four(x, y);
    }
    else if (h % 10 == 5) {
        five(x, y);
    }
    else if (h % 10 == 6) {
        six(x, y);
    }
    else if (h % 10 == 7) {
        seven(x, y);
    }
    else if (h % 10 == 8) {
        eight(x, y);
    }
    else if (h % 10 == 9) {
        nine(x, y);
    }
}

function thirdDigit(x, y) {
    if (m < 10) {
        zero(x, y);
    }
    else if (m > 9 & m < 20) {
        one(x, y);
    }
    else if (m > 19 & m < 30) {
        two(x, y);
    }
    else if (m > 29 & m < 40) {
        three(x, y);
    }
    else if (m > 39 & m < 50) {
        four(x, y);
    }
    else if (m > 49 & m < 60) {
        five(x, y);
    }
}

function fourthDigit(x, y) {
    if (m % 10 == 0) {
        zero(x, y);
    }
    else if (m % 10 == 1) {
        one(x, y);
    }
    else if (m % 10 == 2) {
        two(x, y);
    }
    else if (m % 10 == 3) {
        three(x, y);
    }
    else if (m % 10 == 4) {
        four(x, y);
    }
    else if (m % 10 == 5) {
        five(x, y);
    }
    else if (m % 10 == 6) {
        six(x, y);
    }
    else if (m % 10 == 7) {
        seven(x, y);
    }
    else if (m % 10 == 8) {
        eight(x, y);
    }
    else if (m % 10 == 9) {
        nine(x, y);
    }
}

// pre-assigned positions for each number variation
function zero(x, y) {
    clock(x, y, 3, 30, 15);
    clock(x, y + rad, 12, 30, 0);
    clock(x, y + 2 * rad, 12, 15, 0);
    clock(x + rad, y, 9, 30, 45);
    clock(x + rad, y + rad, 12, 30, 0);
    clock(x + rad, y + 2 * rad, 12, 45, 0);
}

function one(x, y) {
    // mer ce des
    clock(x, y, mer, ce, des);
    clock(x, y + rad, mer, ce, des);
    clock(x, y + 2 * rad, mer, ce, des);

    clock(x + rad, y, 6, 30, 30);
    clock(x + rad, y + rad, 12, 30, 30);
    clock(x + rad, y + 2 * rad, 12, 0, 0);
}

function two(x, y) {
    clock(x, y, 3, 15, 15);
    clock(x + rad, y, 9, 30, 45);
    clock(x + rad, y + rad, 12, 45, 0);
    clock(x, y + rad, 3, 30, 15);
    clock(x, y + 2 * rad, 12, 15, 0);
    clock(x + rad, y + 2 * rad, 9, 45, 45);
}

function three(x, y) {
    clock(x, y, 3, 15, 15);
    clock(x + rad, y, 9, 30, 45);
    clock(x + rad, y + rad, 12, 30, 45);
    clock(x, y + rad, 3, 15, 15);
    clock(x, y + 2 * rad, 3, 15, 15);
    clock(x + rad, y + 2 * rad, 12, 45, 0);
}

function four(x, y) {
    clock(x, y, 6, 30, 30);
    clock(x, y + rad, 12, 15, 15);
    clock(x + rad, y, 6, 30, 30);
    clock(x + rad, y + rad, 12, 30, 45);
    clock(x + rad, y + 2 * rad, 12, 0, 0);
    clock(x, y + 2 * rad, mer, ce, des);
}

function five(x, y) {
    clock(x, y, 3, 30, 15);
    clock(x + rad, y, 9, 45, 45);
    clock(x, y + rad, 12, 15, 15);
    clock(x + rad, y + rad, 9, 30, 45);
    clock(x, y + 2 * rad, 3, 15, 15);
    clock(x + rad, y + 2 * rad, 12, 45, 0);
}

function six(x, y) {
    clock(x, y, 3, 30, 15);
    clock(x + rad, y, 9, 45, 45);
    clock(x, y + rad, 12, 30, 15);
    clock(x, y + 2 * rad, 12, 15, 0);
    clock(x + rad, y + rad, 9, 30, 45);
    clock(x + rad, y + 2 * rad, 12, 45, 0);
}

function seven(x, y) {
    clock(x, y, 3, 15, 15);
    clock(x + rad, y, 9, 30, 45);
    clock(x + rad, y + rad, 12, 30, 0);
    clock(x + rad, y + 2 * rad, 12, 0, 0);
    clock(x, y + rad, mer, ce, des);
    clock(x, y + 2 * rad, mer, ce, des);
}

function eight(x, y) {
    clock(x, y, 3, 30, 15);
    clock(x + rad, y, 9, 30, 45);
    clock(x + rad, y + rad, 12, 30, 45);
    clock(x, y + rad, 12, 30, 15);
    clock(x, y + 2 * rad, 12, 15, 0);
    clock(x + rad, y + 2 * rad, 12, 45, 0);
}

function nine(x, y) {
    clock(x, y, 3, 30, 15);
    clock(x + rad, y, 9, 30, 45);
    clock(x, y + rad, 12, 15, 0);
    clock(x + rad, y + rad, 12, 30, 45);
    clock(x + rad, y + 2 * rad, 12, 0, 0);
    clock(x, y + 2 * rad, mer, ce, des);
}

// basic clock unit

function clock(x, y, h, m, s) {
    push();
    translate(x, y);
    strokeWeight(0);
    fill(150);
    circle(5, 5, rad - 2);
    strokeWeight(0.75);
    fill('white');
    circle(0, 0, rad - 2);

    // hour hand
    push();
    strokeWeight(2);
    rotate(h / 12 * 2 * PI);
    line(0, 0, 0, -rad / 2 + 6);
    pop();

    // minute hand
    push();
    strokeWeight(2);
    rotate(m / 60 * 2 * PI);
    line(0, 0, 0, -rad / 2 + 4);
    lastM = m;
    pop();

    // second hand
    push();
    strokeWeight(1.5);
    rotate(s / 60 * 2 * PI);
    line(0, 0, 0, -rad / 2 + 3);
    lastS = s;
    pop();
    pop();
}

I had seen a clock made of multiple clocks somewhere on the internet before, and I wanted to replicate that effect. However, a main issue I had a difficult time grasping was having each clock rotate its hands to the next assigned position, which would probably require arrays of the old positions and new positions.

Alec Albright – Project 06 – Abstract Clock

sketch

// Alec Albright
// aalbrigh@andrew.cmu.edu
// Section B
// Project 06

var quartPossibleTop = [] // possible upper y values for quarter notes
var quartPlacesTop = [] // actual upper y values for quarter notes
var quartPossibleBottom = [] // possible lower y values for quarter notes
var quartPlacesBottom = [] // actual lower y values for quarter notes
var halfPossibleTop = [] // possible upper y values for half notes
var halfPlacesTop = [] // actual upper y values for half notes
var halfPossibleBottom = [] // possible lower y values for half notes
var halfPlacesBottom = [] // actual lower y values for half notes
var wholePossible = [] // possible y values for whole notes
var wholePlaces = [] // actual y values for whole notes

function setup(){
    createCanvas(480, 480);
    ellipseMode(CENTER);

    // defining possible quarter note y values
    for(i = 20; i < 92; i += 8){
        quartPossibleTop.push(i);
    }
    for(i = 115; i < 185; i += 8){
        quartPossibleBottom.push(i);
    }
    // predetermines random vertical placements on the staff
    for(i = 0; i <= 30; i++){
        quartPlacesTop.push(random(quartPossibleTop));
    }
    for(i = 0; i <= 30; i++){
        quartPlacesBottom.push(random(quartPossibleBottom));
    }
    
    // defining possible half note y values
    for(i = 205; i < 275; i += 8){
        halfPossibleTop.push(i);
    }
    for(i = 300; i < 370; i += 8){
        halfPossibleBottom.push(i);
    }
    // predetermines random vertical placements on the staff
    for(i = 0; i <= 30; i++){
        halfPlacesTop.push(random(halfPossibleTop));
    }
    for(i = 0; i <= 30; i++){
        halfPlacesBottom.push(random(halfPossibleBottom));
    }
    
    // defining possible whole note y values
    for(i = 390; i < 460; i += 8){
        wholePossible.push(i);
    }
    // predetermines random vertical placements on the staff
    for(i = 0; i < 24; i++){
        wholePlaces.push(random(wholePossible));
    }
}

function draw(){
    // record current time
    var h = hour();
    var m = minute();
    var s = second();

    background("white");
    stroke("black");
    strokeWeight(1.5);

    // drawing seconds
    fill("black")
    for(i = 1; i <= s; i++){
        // draws a quarter note depending on minute
        if(i <= 30){
            // head
            ellipse(15 * i, quartPlacesTop[i], 10, 8);
            // stem
            // top half
            if(quartPlacesTop[i] < 52){
                line(15 * i + 5, quartPlacesTop[i], 15 * i + 5,
                     quartPlacesTop[i] - 15);
            // bottom half
            } else {
                line(15 * i - 5, quartPlacesTop[i], 15 * i - 5,
                     quartPlacesTop[i] + 15);
            }
        } else {
            ellipse(15 * (i - 30), quartPlacesBottom[(i - 30)], 10, 8);
            // stem
            // top half
            if(quartPlacesBottom[(i - 30)] < 147){
                line(15 * (i - 30) + 5, quartPlacesBottom[(i - 30)],
                 15 * (i - 30) + 5, quartPlacesBottom[(i - 30)] - 15);
            // bottom half
            } else {
                line(15 * (i - 30) - 5, quartPlacesBottom[(i - 30)],
                 15 * (i - 30) - 5, quartPlacesBottom[(i - 30)] + 15);
            }
        }
    }

    // drawing minutes
    fill("white")
    for(i = 1; i <= m; i++){
        // draws a half note depending on minute
        if(i <= 30){
            // head
            ellipse(15 * i, halfPlacesTop[i], 10, 8);
            // stem
            if(halfPlacesTop[i] < 237){
                line(15 * i + 5, halfPlacesTop[i], 15 * i + 5,
                     halfPlacesTop[i] - 15);
            } else {
                line(15 * i + 5, halfPlacesTop[i], 15 * i + 5,
                     halfPlacesTop[i] + 15);
            }
        } else {
            // head
            ellipse(15 * (i - 30), halfPlacesBottom[(i - 30)], 10, 8);
            // stem
            // top half
            if(halfPlacesBottom[(i - 30)] < 348){
                line(15 * (i - 30) + 5, halfPlacesBottom[(i - 30)],
                 15 * (i - 30) + 5, halfPlacesBottom[(i - 30)] - 15);
            // bottom half
            } else {
                line(15 * (i - 30) - 5, halfPlacesBottom[(i - 30)],
                 15 * (i - 30) - 5, halfPlacesBottom[(i - 30)] + 15);
            }
        }
    }

    // drawing hours
    for(i = 1; i <= h; i++){
        // draws a whole note
        ellipse(36 * i, wholePlaces[i], 10, 8);
    }   

    // drawing staves
    // seconds
    strokeWeight(1);
    drawStaff(20);
    drawStaff(115);
    // connecting
    line(10, 20, 10, 179);
    strokeWeight(3);
    line(5, 15, 5, 184);
    line(5, 15, 15, 12);
    line(5, 184, 15, 188);
    // resetting strokeweight
    strokeWeight(1);
    
    // minutes
    drawStaff(205);
    drawStaff(300);
    // connecting
    line(10, 205, 10, 364);
    strokeWeight(3);
    line(5, 200, 5, 369);
    line(5, 200, 15, 197);
    line(5, 369, 15, 372);
    // resetting strokeweight
    strokeWeight(1);

    // hours
    drawStaff(390)
}

// function to draw a staff
function drawStaff(startY){
    stroke("black");

    // draw a consistent staff
    for(i = 0; i < 80; i += 16){
        let lineY = startY + i
        line(10, lineY, width, lineY);
    }
}

In the creation of this clock, I wanted to see whether some interesting musical elements could be added, leading me to represent various elements of time by different rhythms, with notes placed randomly every increment of time. In this way, a new “piece” of music can be generated every second, with very low likelihood of being reproduced by any replication of this program due to the amount of randomness involved. Though unorthodox, this method of keeping time is certainly interesting. Particularly difficult was managing the spacing of the staves and the notes within a line, simply due to the fact that there can be as many as 30 notes on one line at a time in this representation.

Initial sketch of idea

YouieCho-Project-06-Abstract-Clock

sketch

/* Youie Cho
   Section E
   minyounc@andrew.cmu.edu
   Project-06-Abstract-Clock*/

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

function draw() {
    background(0);

    // Current time
    var M = minute(); // MIN: face width
    var S = second(); // SEC: face color, mouth curve, sparkling background
    var H = hour(); // HR: eyebrow angle, white bar progression
    noStroke();

    // SEC background sparkles as one frame is displayed per second
    for (var i = 0; i < 60; i ++) {
        frameRate(1);
        var x = random(0, width);
        var y = random(0, height);
        var diam = random(0.1, 2);
        ellipse(x, y, diam, diam);
    }

    // MIN face changes from narrow to wide from 0 to 59 minutes
    var face = map(M, 0, 59, 120, 230);
    // SEC face color gets redder from 0 to 59 seconds
    var g = map(S, 0, 59, 197, 21);
    var b = map(S, 0, 59, 143, 0);
    fill(225, g, b);
    ellipse(150, 150, face, 195);

    //SEC mouth changes from a downward to an upward curve from 0 to 59 seconds
    fill(255, 116, 74);
    var mouth  = map(S, 0, 59, 0, width);
    bezier(110, 180, 130, 220 - mouth / 3, 170, 220 - mouth / 3, 190, 180);

    //HR eyebrows move from horizontal lines to angled lines from 0 to 23 hours
    stroke(255);
    strokeWeight(7);
    var brow = map (H, 0, 23, 95, 75);
    line(105, 95, 130, brow);
    line(170, brow, 195, 95);

    //HR white bar progresses from left until the flame icon from 0 to 23 hours
    noStroke();
    fill(30);
    rect(67, 350, 176, 20);
    fill(255);
    var HBar = map(H, 0, 23, 0, 176);
    rect(67, 350, HBar, 20);

    //static elements:
    //eyes
    stroke(0);
    fill(0);
    ellipse(120, 120, 8, 8);
    ellipse(180, 120, 8, 8);
    //flame icon
    ellipseMode(CENTER);
    noStroke();
        //outer flame
    fill(168, 45, 0);
    ellipse(238, 364, 31, 31);
    triangle(223, 359, 238, 329, 253, 359);
        //inner flame
    fill("yellow");
    ellipse(238, 369, 21, 21);
    triangle(228.5, 364, 238, 349, 247, 364);
}

The idea I had for this project was showing stress level throughout the day in a comical way, because I was particularly very tired and frustrated when I began working on this. The face shows a sad expression, redder color, etc. as the time passes, and the bar at the bottom shows how much you are through the day. I could really understand how a clock can work by starting with the base code. I think it was a good opportunity for me to clarify what different variables can mean. For instance, if I make a “second” variable, I have to know if I am referring to the exact number, or a variable that somewhat represents the change of numbers. Overall, it was fun.

Ian Kaneko Project-06-Abstract-Clock

ikaneko abstract clock

// Ian Kaneko
// Project-06

var h = 180; // candle height
var w = 40; // candle width
var b = 340; //y position of the bottom of the candle
var ww = 5; // wick width
var wh = 20; // wick height
var w2 = 150; // outer glow width
var h2 = 190; // outer glow height
var glow1 = 0; // outer glow color
var w3 = 80; // inner glow width
var h3 = 120; // inner glow height
var glow2 = 0; // inner glow color
var fw = 20; // flame width
var fh = 30; // flame height
var w4 = 450; // outer bottom glow width
var h4 = 80; // outer bottom glow height



function setup(){
    createCanvas(480, 480);
    frameRate(1);
    glow1 = color(250, 240, 150);
    glow2 = color(250, 170, 50);
        
}

function draw() {
    background(0);
    noStroke();

    glow1.setAlpha(100);
    glow2.setAlpha(130);
    
    h = 180 - (minute() * (160 / 60)); // Height decreases each minute

    for(i = 0; i < hour(); i ++) { // The number of background candles represents hours
        fill(glow1);
        ellipse(15 + (470 / 24) * i, 100, 20, 40);
        fill(glow2);
        ellipse(15 + (470 / 24) * i, 100, 12, 20);
        fill(250, 240, 240);
        ellipse(15 + (470 / 24) * i, 100, 5, 7); 

        }  
    

    //candle

    //The candle will decrease in height every minute and reset on the hour
    
    glow1.setAlpha(100); // Bottom glow of the candle
    fill(glow1);
    ellipse(width / 2, b, w4, h4);

    fill(220, 210, 210); //The candle itself
    rect(width / 2 - w / 2, b - h, w, h);
    ellipse(width / 2, b, w, 15);
    fill(250, 240, 240);
    ellipse(width / 2, b - h, w, 15);
    fill(0);
    rect(width / 2 - ww / 2, b - h - wh, 5, wh)

    
    fill(glow1); // Outer glow of flame
    ellipse(width / 2, b - h - wh, w2, h2);

    glow2.setAlpha(130); // Inner glow of flame
    fill(glow2);
    ellipse(width / 2, b - h - wh, w3, h3);

    fill(250, 240, 240); // Flame on the candle
    ellipse(width / 2, b - h - wh, fw, fh);


    //The candle flickers every second
    w2 = random(130, 170);
    h2 = random(180, 210);
    w3 = random(70, 90);
    h3 = random(110, 130);
    fw = random(18, 22);
    fh = random(30, 35);
    w4 = random(430, 480);
    h4 = random(75, 85);

   

    

}   

For this project the hardest part was trying to conceptualize a way of telling time that would not just look like a clock. I started to think about what kinds of things naturally change shape overtime. My original idea was an iceberg melting, then I thought of a moon waxing and waning. I ended up choosing a candle melting though because I liked the idea of playing with opacity to show it emitting light. While my clock doesn’t exactly document how many seconds have passed, it does react by randomizing the candle glow every second. The candle gets shorter every minute, and a candle in the distance is lit every hour.

My quick candle sketch done on staff paper because I don’t have normal paper

Caroline Song – Project 06 – Abstract Clock

sketch

//Caroline Song
//Section E
//chsong@andrew.cmu.edu
//Project 06 - Abstract Clock

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

function draw(){
    background(127, 227, 250);
    //calling current time values
    var S = second();
    var M = minute();
    var H = hour(); 
    var arcSize = 200;

    //fitting time values to arcs
    var mappedS = map(S, 0, 59, 180, 360);
    var mappedM = map(M, 0, 59, 180, 360);
    var mappedH = map(H, 0, 23, 180, 360);
    //outer ring for seconds
    angleMode(DEGREES);
    noFill();
    stroke(252, 177, 228);
    strokeWeight(30);
    arc(width/2, height/2, arcSize + 120, arcSize + 120, 180, mappedS);
    //middle ring for minutes
    noFill();
    stroke(250, 247, 100);
    strokeWeight(30);
    arc(width/2, height/2, arcSize + 60, arcSize + 60, 180, mappedM);
    //inner ring for hours
    noFill();
    stroke(0, 209, 24);
    strokeWeight(30);
    arc(width/2, height/2, arcSize, arcSize, 180, mappedH);

    //draw clouds
    fill("white");
    noStroke();
    //cloud1
    ellipse(45, height/2 + 75, 60, 60);
    ellipse(95, height/2 + 65, 95, 95);
    ellipse(130, height/2 + 60, 80, 80);
    ellipse(165, height/2 + 80, 60, 60);
    //cloud2
    ellipse(width/2 + 50, height/2 + 70, 75, 75);
    ellipse(width/2 + 100, height/2 + 70, 100, 100);
    ellipse(width/2 + 150, height/2 + 70, 85, 85);
    ellipse(width/2 + 175, height/2 + 95, 50, 50);
}

Initial sketch of clock design

For this project, I wanted to communicate time in a lighthearted manner. For all those times that people are stressed or in a bad mood when looking at time, I wanted to combat those feelings with an engaging and colorful depiction of time.

*the pink seconds arc makes a full 360 arc each time it reaches 60 seconds, but it’s only supposed to return back to 180 degrees and repeat, which it does in Sublime but not when I embed it into WordPress.

Monica Chang – Project 06 – Abstract Clock

sketch

//Monica Chang
//mjchang@andrew.cmu.edu
//Section D
//Project 06 - Abstract Clock

var prevSec;
var millisRolloverTime;

var rVal = 50;
var bVal = 50;

//--------------------------
function setup() {
    createCanvas(480, 480);
    millisRolloverTime = 0;
    frameRate(5);
    r = random(255);
    g = random(255);
    b = random(255);
}

//--------------------------


function draw() {
    background(0);
  
    //millis is represented in drawGrid
    drawGrid();
    
    // Fetch the current time
    var H = hour(); 
    var M = minute();
    var S = second();
    var a = H*3600 + M*60 + S;
    
    // Reckon the current millisecond, 
    // particularly if the second has rolled over.
    // Note that this is more correct than using millis()%1000;
    if (prevSec != S) {
        frameRate(25);
        millisRolloverTime = millis();
    }
    prevSec = S;
    var mils = floor(millis() - millisRolloverTime);
    
    fill(128,100,100);
    stroke(128,100,100);
    text("Hour: "   + H, 10, 22);
    text("Minute: " + M, 10, 42);
    text("Second: " + S, 10, 62);
    text("Millis: " + mils, 10, 82);
    
    var hourCircSize = map(H, 0, 23, 0, width);
    var minuteBarWidth = map(M, 0, 59, 0, width);
    
    var blueChange = map(S, 0, 60, 0, 255); //blue changing color
    var radiusChange = map(S, 0, 60, 0, 400); //increasing circle size
  
  // hours
    fill(3);
    noStroke();
    ellipse(width / 2, height / 2, hourCircSize / 2);
    

  //minutes
  
    rectMode(CORNER);
    noStroke();
    fill(20);
    rect(50, height / 2, 380, 20);//darker background
    noStroke();
    fill(r, g, b);
    rect(50, height / 2, minuteBarWidth, 20); //minutes passed
    strokeWeight(1);
  
  
  //seconds: empty, blue circles getting bigger and bigger.
    noFill();
    stroke(66, blueChange, 244);
    ellipse(width / 2, height / 2, radiusChange);
    a = a + 1;
    
 
  
  //analog clock
    fill(128,100,100);
    noStroke();
    textAlign(LEFT);
    text(H % 12, width / 2 - 20, 460);

    textAlign(CENTER);
    text(M, width / 2 , 460);
  
    textAlign(LEFT);
    text(S, width / 2 + 7, 460);
    
}

//millis
function drawGrid() {
  // noprotect
    for (var y = 0; y < 490; y += 10) {
        for (var x = 0; x < 650; x += 10) {
            frameRate(millis());
            rVal = (rVal - 1) % 200;
            bVal = (bVal + 3) % 200;
            //color gradient
            fill(rVal, 0, bVal);
            noStroke();
            ellipse(x, y, 10, 10);
            
        }
  }
}

It was really interesting how much I had to think about the readability of this concept. To make something that we look at daily, making it abstract can arguably take more time for it to function regularly like it does now for it. With this idea, I concentrated on abstracting the form of the clock while also allowing it to still require not that much cognitive processing to understand.

my sketch

Xu Xu – Project 06 – Abstract Clock

sketch

//Claire Xu
//xux1@andrew.cmu.edu
//Section B
//Project 05
var spacing = 400/30;
var distance = 400/30;
var diam = 4;

function setup() {
    createCanvas(400, 400);

}
function draw() {
    let s = second();
    let m = minute();
    let h = hour();
    background(245);
    //hour
    fill(33, 72, 39);
    arc(width/2, height/2, 350, 350, 0 + TWO_PI * h/12, PI + TWO_PI * h/12);
    noFill();
    strokeWeight(2);
    stroke(100);
    strokeCap(SQUARE);
    arc(width/2, height/2, 220, 220, 0 + TWO_PI * h/12, PI + TWO_PI * h/12);
    arc(width/2, height/2, 190, 190, 0 + TWO_PI * h/12, PI + TWO_PI * h/12);
    arc(width/2, height/2, 160, 160, 0 + TWO_PI * h/12, PI + TWO_PI * h/12);
    //minute
    noStroke();
    fill(163, 199, 139);
    arc(width/2, height/2, 325, 325, 0 + TWO_PI * m/60, PI + TWO_PI * m/60);
    noFill();
    strokeWeight(2);
    stroke(205);
    strokeCap(SQUARE);
    arc(width/2, height/2, 250, 250, 0 + TWO_PI * m/60, PI + TWO_PI * m/60);
    arc(width/2, height/2, 220, 220, 0 + TWO_PI * m/60, PI + TWO_PI * m/60);
    arc(width/2, height/2, 190, 190, 0 + TWO_PI * m/60, PI + TWO_PI * m/60);
    //second
    noStroke();
    fill(241, 225, 191);
    arc(width/2, height/2, 300, 300, 0 + TWO_PI * s/60, PI + TWO_PI * s/60);
    noFill();
    strokeWeight(2);
    stroke(255);
    strokeCap(SQUARE);
    arc(width/2, height/2, 280, 280, TWO_PI * s/60, PI + TWO_PI * s/60);
    arc(width/2, height/2, 250, 250, TWO_PI * s/60, PI + TWO_PI * s/60);
    arc(width/2, height/2, 220, 220, TWO_PI * s/60, PI + TWO_PI * s/60);
    //clock center
    noStroke();
    fill(241, 225, 191);
    circle(width/2, height/2, 100);
    fill("black");
    circle(width/2, height/2, 10);
}

For this project I was inspired by an abstract clock that I saw online, which abstracts the second/minute/hour hands, where it would have entire half-circle plates rotating to count the time. I used arc to draw the half-circles, and instead of trying to rotate the arc through the center, I discovered that I could just redraw the arc at new positions every frame according to the time. I wish I could figure out how to have holes in the half-circle plates like in the real abstract clock images. Unlike the real abstract clock reference, the line that’s tangent to the flat side of the half-circle is where the time is pointed at.

Ghalya Alsanea – Project 06-Abstract Clock

A modern clepsydra

a timepiece in which time is measured by the regulated flow of liquid.

sketch

//Ghalya Alsanea
//Section B
//galsanea@andrew.cmu.edu
//Project-06

//configure sizes of each water bowl
var secBowl = 25;
var minBowl = 18;
var hrBowl = 20;
//define x coordinates and y start points for each bowl
var secX = 200;
var secY = 150;
var minX = 300;
var minY = 60;
var hourX = 150;
var hourY = 90;
//water drop animation start X and Y positions 
var startX = 0;
var startY = 0; 

//set up fill matrix for the seconds
//row is time intervals (s)
//columns are fill for the seconds bowls
var fills =[['blue' , 255   , 255   , 255   ],
            [255    , 'blue', 255   , 255   ],
            ['blue' , 'blue', 255   , 255   ],
            [255    , 255   , 'blue', 255   ],
            ['blue' , 255   , 'blue', 255   ],
            [255    , 'blue', 'blue', 255   ],
            ['blue' , 'blue', 'blue', 255   ],
            [255    , 255   , 255   , 'blue'],
            ['blue' , 255   , 255   , 'blue'],
            [255    , 'blue', 255   , 'blue'],
            ['blue' , 'blue', 255   , 'blue'],
            [255    , 255   , 'blue', 'blue'],
            ['blue' , 255   , 'blue', 'blue'],
            [255    , 'blue', 'blue', 'blue'],
            ['blue' , 'blue', 'blue', 'blue'],
            ]


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

function draw() {
    background("pink");
    
    //background mechanisms --> graphics
    noStroke();
    //top
    fill(255);
    arc(width/2, 20, 50, 50, 0, 180);
    fill('blue');
    arc(width/2, 30, 40, 28, 0, 180);
    //bottom
    circle(width/2, height -50, 50);
    //connecting tubes
    rect(width/2 - 3, 32, 6, height - 100);
    rect(minX - 2,  minY + minBowl * 0.6 * 29, 4, minBowl + 10);
    //blue lines
    noFill();
    strokeWeight(3);
    stroke('blue');
    //minute connectors
    line(minX, (minY + minBowl * 31 * 0.6), width/2, height - 50);
    line(minX - minBowl +2, minY + minBowl * 0.6 * 30, minX, minY + minBowl * 0.6 * 30);
    //seconds connectors
    line(secX, secY + secBowl*6, secX, secY + secBowl*7);
    line(secX, secY + secBowl*7, width/2, secY + secBowl*8);
    line(secX, secY, secX, secY - secBowl*3);
    arc(secX + 8, secY - secBowl*3, 16, 16, 180, 360);
    line(secX + 16, secY - secBowl*3, secX + 16, secY - secBowl*2);
    arc(secX + 24, secY - secBowl*2, 16, 16, 0, 180);
    line(secX + 32, secY - secBowl*2, secX + 32, 35);
    //don't start filling up hours if it's noon or midnight
    if(hour() == 12) {
        stroke(255);
    } else {
        stroke('blue');
    }
    //hour connectors
    line(minX - minBowl*2,  hourY + hrBowl * 1.2 * 12, hourX, hourY + hrBowl * 1.2 * 12);
    line(hourX, hourY + hrBowl * 1.2 * 11, hourX, hourY + hrBowl * 1.2 * 12);
    //purely white lines
    stroke(255);
    arc(minX- minBowl*1.5 + 2, minY, minBowl, minBowl, 180, 360);
    line(minX - minBowl*2 + 2,  minY, minX - minBowl*2 + 2, hourY);
    line(hourX, hourY-25, hourX, hourY);
    line(hourX, hourY-25, width / 2 - 15, 25);

    //do the math to figure out the times in useful numbers
    //since the cycle is in 2 minute intervals
    //you have to shift the seconds in the second minute
    if(minute() % 2 == 0) {
        var s = floor(second() / 8);
    } else {
        var s = floor((60 + second())/8);
    }
    //if minutes is divisible by 2, fill one of the minute bowls
    var m = floor(minute()/2);
    //every hour, fill one hour bowl
    var h = hour() % 12;

    //seconds base
    for (i = 0; i < 4; i++) {
        noStroke();
        //assign each bowl to it's color        
        fill(fills[s][i]);
        circle(secX, secY + secBowl * 1.5 * i, secBowl + 4*i);
        rect(secX - 3.5,  secY + secBowl * 1.5 * i, 7, secBowl + 4*i);
    }


    //minutes base
    strokeWeight(0.5);
    for (i = 0; i < 30; i++) {
        noStroke();
        //figure out if bowl should be filled with water
        if(30 - i <= m){
            fill("blue");
        }
        else {
            fill(255);
        }
        //bowls
        ellipse(minX, minY + minBowl * i * 0.6, minBowl, minBowl / 2);
        rect(minX - 2,  minY + minBowl * 0.6 * i, 4, minBowl / 2);
        //siphon tube
        rect(minX - minBowl,  minY + minBowl * 0.6 * i, 4, minBowl);        
        //tick marks for every 10 minutes
        if (i % 5 == 0) {
            push();
            translate(minX + minBowl, minY + minBowl * i * 0.6);
            stroke("blue");
            for(var a = 0; a < 30 - i; a+=5){
                line(0, 0, a/2 + 2, 0);
            }
            pop();
        }
    }

    //hours base
    for (i = 0; i < 12; i++) {
        noStroke();
        //figure out if bowl should be filled with water
        if(12 - i <= h){
            fill("blue");
        }
        else {
            fill(255);
        }
        //bowls
        circle(hourX, hourY + hrBowl*1.2*i, hrBowl);
        rect(hourX - 3,  hourY + hrBowl * 1.2 * i, 6, hrBowl);        
        //siphon tube
        rect(minX - minBowl*2,  hourY + hrBowl * 1.2 * i, 4, hrBowl*2);
    }

    // water dripping annimation
    push();
    translate(secX, secY - secBowl);
    stroke('blue');
    strokeWeight(3);
    //draw dashed line
    for (i = 0; i < 160; i+=20) {
        var y = map(startY, 0, secBowl*8, 0, 100);
        line(startX, y+i, startX, y + i + 5);
    }
    //animate line
    startY = startY + 2;
    //reset after 3 bowls
    if (startY > secBowl*3) {
        startY = 0;
    }
    pop();
}

For this project I was inspired by this clock in a mall I used to go to back home, which is the oldest mall in Kuwait. I used to sit in the main lobby as a child and stare at the sculpture for hours. Here’s a video…

I started by doing a lot of research about water clocks and how they work. You can find a brief history here. I decided to take the modern approach of the scientist, Bernard Gitton’s. I used this animation to visually understand how the clock works, and I used the explanations behind the physics of the timepiece and the calculations found on this page to figure out the code necessary to simulate the water clock.

The biggest challenge was trying to understand how the seconds were working. I used an excel sheet to understand when each of the bowls need to be filled during which second, and mapped that to a 2D array matrix.

Zee Salman- Abstract Clock-Project-06

sketch

//Zee Salman
//SECTION E
//fawziyas@andrew.cmu.edu
//SectionE
//Project 06


function setup(){
  createCanvas(460,400);
}


function draw(){ 

var s = second(); 
// controls seconds
var m = minute();
//control mintutes
var h = hour()%12;

var mappedH = map(h, 0,23, 0,width);
var mappedM = map(m, 0,59, 0,width);
var mappedS = map(s, 0,59, 0,width);
//control hours

//main backgrougnd
  background(219, 184, 255);

// outline box background
  noStroke();
  fill(246, 201, 255);
  rect(20 , 40 , 410 , 320);

//hour outline box
  rect(30 , 50 , 200 , 300);
//min outline box
  rect(250 , 50 , 100 , 300);
//sec outline box
  // strokeWeight(5);
  stroke(107, 56, 128);
  rect(370 , 50 , 50 , 300);

 
  

//seconds box
  noFill();
  stroke(107, 56, 128);
  for(i = 0; i < mappedS; i++){
      strokeWeight(2);
      rect(370 , 50 , 50 , 300 - i / 1.55);
  }
    
  //hours box
  noFill();
  stroke(84, 64, 135);
  for(i = 0; i < mappedH; i++){
    strokeWeight(5);
    rect(30 , 50 , 200 , 300 - i / 1.55 );
  }

  //minutes box
  noFill();
  stroke(227, 61, 147);
  for(i = 0; i < mappedM; i++){
    strokeWeight(4);
    rect(250 , 50 , 100 , 300 - i/ 1.55);
  }
 

  


}


For my abstract clock, I first wanted to use words to go about my design, but I felt that it would be a bit too complicated. I felt the purpose of this project was to make it easy to still tell time while making it more interesting to do so. I really enjoyed making this project because I went through a lot of trial and error models until I found something I really liked. I also like the different sized in the boxes just to make it vary a bit more. When the Hour Box is full, that represents 24 hours. When the Minute Box is full that represents 60 minutes. When the Second Box is full, that represents 60 seconds.

Claire Lee – Project 06 – Abstract Clock

project06

var starX = [];
var starY = [];
// star position arrays

function setup() {
    createCanvas(600, 600);
    for (i = 0; i < 100; i++) {
        starX[i] = random(width);
        starY[i] = random(height);
    } // randomizing star x and y positions
}

function draw() {
    background(0, 0, 10);

    noStroke();
    fill(255, 210, 10); 
    ellipse(300, 300, 50, 50);
    //sun

    stroke(200);
    strokeWeight(1.5);
    noFill();
    ellipse(300, 300, 500, 500);
    // outer orbit

    stroke(200);
    strokeWeight(1);
    noFill();
    ellipse(300, 300, 350, 350);
    // middle orbit

    stroke(200);
    strokeWeight(0.5);
    noFill();
    ellipse(300, 300, 250, 250);
    // inner orbit

    var S = second();
    var M = minute();
    var H = hour();
    var mappedS = map(S, 0, 59, 0, 354);
    var mappedM = map(M, 0, 59, 0, 354);
    var mappedH = map(H, 0,23, 0, 354);
    // time variables

    push();
    //stars
    for (i = 0; i < 100; i++) {
        noStroke();
        fill(255, 255, 255, 75);
        ellipse(starX[i], starY[i], 2, 2);
    } 
    translate(300, 300);
    // red planet
    rotate(radians(mappedH));
        noStroke();
        fill(230, 50, 15);
        ellipse(0, -250, 20, 20);
    // grey planet
    rotate(radians(mappedS));
        noStroke();
        fill(150);
        ellipse(0, -125, 10, 10); 
    pop();

    var moonX = 300 + -175 * (cos(radians(mappedM)));
    var moonY = 300 + -175 * (sin(radians(mappedM)));
    // circle math!
    push();
    translate(moonX, moonY);
        noStroke();
        fill(70, 210, 200);
        ellipse(0, 0, 25, 25);
        // blue planet

        stroke(200);
        strokeWeight(0.5);
        noFill();
        ellipse(0, 0, 60, 60);
        // moon orbit

        rotate(radians(mappedS));
        noStroke();
        fill(150);
        ellipse(0, -30, 10, 10);
        // moon
    pop();
}

This project was really interesting to do because I got to revisit and experiment with the translate() and rotate() functions. I also incorporated arrays into my piece, and was really satisfied with the result. One thing I learned that I don’t think I remember seeing before is the map() function, which I think made it a lot easier to convert measures of time into evenly-spaced coordinates without hard-coding in the math.