Project 06 – Abstract Clock – srauch

Here is my abstract clock. It’s a beach with tides: high tide is at noon and low tide is at midnight. The grass rustles in the breeze, and the beach is strewn with starfish and shells. It’s dark from 8 pm to 5am. Sunrise is from 6am to 7am, and sunset is from 7pm to 8pm.

sketch

//Sam Rauch, section B, srauch@andrew.cmu.edu, project 06: abstract clock
//this code creates a beach with a tide. High tide is at noon, and low tide is at midnight.
//the grass rustles in the sea breeze. it gets darker from 7pm 8 pm and lighter from 6 to 7am. 

var grasslength = []; //length of blades of grass
var sandspotX = []; //x position of specks in sand
var sandspotY = []; //y position of specks in sand
var waveY; //height of the tide
var waveShift; //amount the water's edge fluctuates by 
var daytime; //the time of day in minutes
var darkness; //amount of darkness it is

function setup() {
    createCanvas(400, 400);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);

    //initializing x position of specks in sand
    for (var i = 0; i < 50; i++){
        sandspotX[i] = random(0, width);
    }

    //initializing y position of specks in sand
    for (var i = 0; i < 50; i++){
        sandspotY[i] = random(200, 400);
    }

    frameRate(5);

    //creating y position of tide. High tide is at noon, low tide is at midnight
    daytime = hour()*60 + minute(); //time of day, in minutes
    if (daytime < 690) { //if before noon
        waveY = map(daytime, 0, 690, 400, 200); //before noon, wave gets higher with time
    } else { //if after noon
        waveY = map(daytime, 690, 1380, 200, 400); //after noon, wave gets lower with time
    }

    //making it get lighter and darker at sunrise and sunset
    if (daytime >= 300 & daytime < 360) { //if from 5 to 6 am, it gets lighter
        darkness = map(daytime, 300, 360, 120, 0);
    } else if (daytime >= 1140 & daytime < 1200) { //from 7 to 8 pm, it gets darker
        darkness = map(daytime, 1140, 1200, 0, 120);
    } else if (daytime >= 360 & daytime < 1140) { //in the middle of the day, it's not dark
        darkness = 0;
    } else { //in the middle of the night, it's dark
        darkness = 120;
    }
}

function draw() {
    noStroke();
    background(155, 207, 207);

    //row of grass bunches
    for (var i = 0; i <2; i++){
        for(var j = 0; j<=width; j += 20) {
        grass(j, 220);
        }
    }
    
    //sand
    fill(196, 178, 122);
    rect(0, 200, width, 200);

    //little specks in sand
    strokeWeight(3);
    stroke(146, 128, 72)
    for (var i = 0; i<50; i++){
        point(sandspotX[i], sandspotY[i]);
    }
    noStroke();

    //assorted shells and starfish
    starfish(250, 250, color(120, 130, 120), 10);
    starfish(50, 340, color(50, 74, 64), 50);
    starfish(180, 370, color(120, 79, 97), 5);
    shell(140, 260, color(60, 50, 70), color(100, 80, 107), 60);
    shell(300, 300, color(80, 50, 50), color(120, 80, 97), -5);

    //waves
    waveShift = randomGaussian(1, 2);
    fill(30, 100, 155, 240);
    rect(0, waveY+waveShift, width, 300);
    fill(30, 100, 155, 100);
    rect(0, waveY-(random(1,3))+waveShift, width, 300);

    //rectangle that makes darkness and lightness of environment using alpha channel
    blendMode(MULTIPLY);
    fill(35, 50, 70, darkness);
    rect(0,0,width,height);
    blendMode(BLEND);
}

//makes starfish
function starfish(x,y, color, spin){
    push();
    translate(x,y);
    rotate(radians(spin));
    strokeWeight(4);
    stroke(color);
    for (var i = 0; i<5; i++){ //draw five arms from 0,0, rotating after each one
        line(0,0,0,-10);
        rotate(radians(72));
    }
    noStroke();
    pop();
}

//makes seashells
function shell(x,y, color1, color2, spin) {
    push();
    translate(x,y);
    rotate(radians(spin));
    strokeWeight(1);
    stroke(color1);
    fill(color2);

    var radius = 7; //radius of seashell, ie distance from circles to center
    var size = 12; //size of circles themselves
    var angle = radians(0); //theta of circle location
    for (var i = 0; i<20; i++) { //draw circles that get smaller as they get closer to the center
        ellipse ( cos(angle)*radius, sin(angle)*radius, size);
        angle-=radians(24);
        size -= i/20; //decrease size of circles
        radius -= i/30; //decrease radius of seashell       
    }
    noStroke();
    pop();
}

//makes a bunch of grass
function grass(x,y){
    push();
    translate(x,y);
    stroke(65, 100, 52);
    strokeWeight(2);
    rotate(radians(-40));
    for (var i = 0; i < 20; i++){ //creating each blade of grass in a bunch
        for (var j = 0; j < 20; j++){ //creating random lengths for each blade of grass
            grasslength[j] = random(35, 40);
        }
        line(0,0,0, -1*grasslength[i]);
        rotate(radians(4));
    }

    pop();
}

Project-06-Abstract-Clock

Clock

sketch
//Brody Ploeger
//Section C
//jploeger@andrew.cmu.edu
//Assignment-06



function setup() {
    createCanvas(450, 450);
    background(220);
    //text("p5.js vers 0.9.0 test.", 10, 15);
}

function draw() {
var s = second()
var m = minute()
var h = hour()
background(0)

//hours
for(var n = 0; n<h*height/24; n+=height/24){
    noStroke();
    fill('orange');
    rect(0,0,width,n+20);
}

//hours
for(var n = 0; n<h*height/24; n+=height/24){
    noStroke();
    fill('red');
    circle(width-20,0+n+10,20);
}

//minute counter
for(var j = 0; j<m*7.5; j+=7.5){
    strokeWeight(2)
    stroke(255)
    line(0+j,0,0+j,height)
}

//move origin for second counter
push();
translate(width/2,height/2)
//secondcounter
for(var i = 0; i<s; i++){
    rotate(radians(6));
    secondcounter(0,0)
}
secondcounter(0,0)
pop();
}

//seconds function
function secondcounter(x,y){
stroke('green');
strokeWeight(10);
noFill();
arc(x,y,width/2,width/2,0,radians(6))
}

Project 06 – Abstract Clock

For this project, I thought about the growth of plants as a representation of time. However, I decided to combine that concept by creating a method where by looking at the image, one can know in a more literal sense what time of day it is while still being an abstract representation.

The stem grows a little longer each minute and refreshes from the bottom once it reaches 59. This allows the viewer to know what minute of the hour it is. The number o pedals is representative of the hour and the shade change of the pedals represents the seconds. The background also changes from night to day depending on the typical times when the sun and moon are out.

clock sketch
// Sandy Youssef
// syoussef@andrew.cmu.edu
// section D
//Assignment 6
var x; 
var y;
 
function setup() {
    createCanvas(400, 480);

   
}

function draw() {
    x = width/2;
    y = 450;
    

    // draw sun or moon depending on time of day where sun or moon are typically out
    var h = hour(); // current hour of day 0-23
    
    if ( h > 6 & h < 17) {
        background(205,236,255);
        //sun
        fill("yellow");
        ellipse(70, 70, 70);  
    
    } else  {
        background(32,58,131); 
        // draw moon
        fill("white")
        ellipse(330,70,70);
        fill(32,58,131);
        ellipse(310, 70,70);
        
    }
    //clouds 
    var xc = 100; // x cloud
    var xy = 100; // y cloud
    
    fill("white");
    //left cloud
    ellipse(xc + 25, xy +15, 50,25);
    ellipse(xc+ 55, xy + 35, 50,33);
    ellipse( xc, xy + 35, 60, 40);
    ellipse(xc +35, xy + 37, 50, 50);
    //right cloud
    push();
    translate(190,90);
    ellipse(xc + 25, xy +15, 50,25);
    ellipse(xc+ 55, xy + 35, 50,33);
    ellipse( xc, xy + 35, 60, 40);
    ellipse(xc +35, xy + 37, 50, 50);
    pop();
    
    //dirt
    noStroke();
    fill("brown");
    rect(0, 460, width, height);
    
   
    //stem
    var m = minute(); // current minute in hour 0-59
    fill(74,115,69);
    rect(x-10,y-10- (m *5), 5, 300); // every minute the stem will grow and once it reaches 59 it will start over. 
  

   
    var s = second(); // current seconds 0-59
    var h = hour(); // current hour of day 0-23
    for (var i = 0; i < h; i ++) { // loop that creates a new pedal at each hour to count hour
        push();
        translate(x-10 +3, y-10- (m*5)); // translates pedals to the center of flower 
        rotate(radians(360/24)*i);
        stroke("yellow")
        strokeWeight(1);
        // count seconds by changing shade of pedals at each second
        if (s %2) { // if second is odd make light pink
           fill(227,180,242);
        } else {
            fill(225,154,246); // if second is even make dark pink
        }
        ellipse(5 , (-15), 10, 25);
        pop();
        
    }
   

    // center of flower
    fill(243,255,131); // yellow
    ellipse(x-10 + 3 , y-10- (m *5) , 20);
    
     
   

    // grass 
    for (var x = 1; x < width; x = x+ 4) { 
        fill(0,240,0);
        triangle(x,480, x+ 5 , 480, x +2.5, 440);
    }


    

   
}
brainstorming process
messy brainstorming process

Project 06

l

sketch
//Keng Pu (Paul) Li
//section A 

var minuteX = [];
var minuteY = [];
var minuteColor = [];
var sec;
var mnth;
var hr;

function setup() {
    createCanvas(300,400);
    rectMode(CENTER);
    //assigns array for minute fn

}

function draw() {
    background(40,10,10);
    sec = second()+1;

    //allows minute circles to produce jittering effect
     for(var i = 0; i<=minute(); i++){
        minuteX[i] = min(56+i*random(2.5,3),245);
        minuteY[i] = max(340-i*random(3,5),100);
        minuteColor[i] = minute()*4;
    }

    timeMonth();
    timeHours();
    timeMinutes();
    frameRate(sec); //higher the second faster the frame-> quickker jitters
}

function timeMonth(){
    mnth = month();
    noStroke();
    //changes color depending to season, fall = orange, winter =  blue, spring =  pink, summer = green, code in that order
    //also places circle on diff corner of that color depending on the season
    if(mnth>=9 & mnth<12){
        fill(255,160,70);
        circle(20,20,30);
    } else if(mnth>=12 & mnth<3){
        fill(18,130,210);
        circle(width-20,20,30);
    } else if(mnth>=3 & mnth<6){
        fill(255,100,220);
        circle(width-20,height-20,30);
    }else{
        fill(30,230,70);
        circle(20,height-20,30);
    }
    rect(width/2,height/2,200,300);
}


// draws a strike every hour and resets every 12 hr on top of the orange cube,, resets to 0 strikes each 24 hr

function timeHours(){
    hr = hour();
    var strikeW = (200/24) - 13;
    var strikeH = 30;
    fill(255,40,40);
    stroke(0.5);
    if(hr<24){
        for (var i = 0; i<hr; i++){
            rect((55+strikeW/2)-i*(strikeW-200/48),50-strikeH/2,strikeW,strikeH);
        }
    }else{
        var i = 0;
        for (var i = 0; i<hr; i++){
            rect((55+strikeW/2)-i*(strikeW-200/48),50-strikeH/2,strikeW,strikeH);
        }
    }
}

//for every minute, a ball is added into the orange box, and as time goes on the color of the balls get lighter, the spread also goes further ddepending on time

function timeMinutes(){
    noStroke();
    fill(0,0,0,0);
   for(var i = 0; i<=minute(); i++){
        circle(minuteX[i],minuteY[i],10);
        fill(minuteColor[i]);
    }
   

}

Project 06: Abstract-Clock

For this project, the inner circle represents every second, the outer circle shows the seconds turning to minutes, the different colored rays of the “sun” show the different minutes, and the pink background shows the number of hours in the day!

sketch
function setup() {
    createCanvas(350, 350);
    background(173, 216, 230);
}

function draw() {
    background(173, 216, 230);
    hoursBackground();
    minutesCircle();
    secondsCircle();
}

function hoursBackground() { //creates pink rectangles every hour
    push();
    for(var i = 0; i < hour(); i++) {
        strokeWeight(0.1);
        fill(243, 196, 207);
        rect(0,0, width/24, height);
        translate(width/24,0);
    }
    pop();
}

function minutesCircle() { //every minute, a new ray appears coming out of the inner circle
    push();
    strokeWeight(11);
    translate(width/2, height/2);
    for (var i = 0; i < minute(); i ++) {
        angleMode(DEGREES);
        if(i % 2 == 0) { //if i mod 2 is 0, then a short yellow line is drawn
            stroke(253, 253, 150, 200);
            line(0,0, 0, -100);
            rotate(6);
        }else{ // else a long orange line is drawn
            stroke(255, 179, 71, 200);
            line(0,0, 0, -125);
            rotate(6);
        }   
    }
    pop();
}

function secondsCircle() {
        fill(173, 216, 230); //creates inner blue circle
        strokeWeight(0.1);
        circle(width/2, height/2, 40);

        strokeWeight(10); //creates outer white circle that counts 60 seconds in a minute
        stroke(255);
        noFill();
        arc(width/2, height/2, 250, 250, 270, 270 + second()*6);

        strokeWeight(1); // creates inner circle that visually shows every second
        fill(255);
        arc(width/2, height/2, 30, 30, 270, 270 + millis()*0.36);
}

Project 06 Abstract Clock

The way time is tracked in this piece of design is by having the little blue fish tracking seconds, the little pink fish tracking minutes, and the rainbow tracking hours. So the blue fish moves right a bit every second and when the minute increases the pink fish moves right. the rainbow goes from red to blue every hour and it restarts from red again when the full rainbow is done.

sketch
//Jenny Wang
//Section B
//jiayiw3@andrew.cmu.edu
//Project 06 Abstract Clock

//set variables
var H;//hour
var M;//min
var S;//sec
var bx;//blue fish x
var px;//piink fish x

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

} 

function draw() {
    background(199,137,201);//purple
    
    //current time
    H = hour();
    M = minute();
    S = second();

    //rainbow (hour)
    if(H == 6 || H == 12 || H==18 || H==24){
        noStroke();
        fill(122,153,229);//blue
        ellipse(240,140,560,470)
        fill(131,226,210);//teal
        ellipse(240,140,480,390);
        fill(151,226,134);//green
        ellipse(240,140,400,310);
        fill(239,232,101);//yellow
        ellipse(240,140,320,230);
        fill(229,156,90);//orange
        ellipse(240,140,240,150);
        fill(247,129,87);//red
        ellipse(240,140,160,70);
    }
    else if(H == 5 || H == 11 || H==17 || H==23){
        noStroke();
        fill(131,226,210);//teal
        ellipse(240,140,480,390);
        fill(151,226,134);//green
        ellipse(240,140,400,310);
        fill(239,232,101);//yellow
        ellipse(240,140,320,230);
        fill(229,156,90);//orange
        ellipse(240,140,240,150);
        fill(247,129,87);//red
        ellipse(240,140,160,70);
    }
    else if(H == 4 || H == 10 || H== 16 || H== 22){
        noStroke();
        fill(151,226,134);//green
        ellipse(240,140,400,310);
        fill(239,232,101);//yellow
        ellipse(240,140,320,230);
        fill(229,156,90);//orange
        ellipse(240,140,240,150);
        fill(247,129,87);//red
        ellipse(240,140,160,70);
    }

    else if(H == 3 || H == 9 || H== 15 || H== 21){
        noStroke();
        fill(239,232,101);//yellow
        ellipse(240,140,320,230);
        fill(229,156,90);//orange
        ellipse(240,140,240,150);
        fill(247,129,87);//red
        ellipse(240,140,160,70);
    }

    else if(H == 2 || H == 8 || H== 14 || H== 20){
        noStroke();
        fill(229,156,90);//orange
        ellipse(240,140,240,150);
        fill(247,129,87);//red
        ellipse(240,140,160,70);
    }

    else if(H == 1 || H == 7 || H== 13 || H== 19){
        noStroke();
        fill(247,129,87);//red
        ellipse(240,140,160,70);
    }

    //ocean
    fill(198,230,227);
    rect(0,132,480,351);

    //bluefish(sec)
    bx = width/59;
    bluefish(S*bx,height/2);

    //pink fish(min)
    px = width/59
    pinkfish(M*px,3*height/4);
}
 
function bluefish(x,y){
    //tail
    fill(44,170,213);
    triangle(x-38,y+13,x-38,y-13,x,y);
    //fin on top and bottom
    fill(144,214,235);
    triangle(x+5,y-17,x-10,y-23,x-10,y+10);
    //body
    fill(44,170,213);
    ellipse(x,y,55,34);
    //fin
    fill(144,214,235);
    triangle(x-15,y-6,x-15,y+6,x,y-2);
    //head
    fill(144,214,235);
    ellipse(x+16,y,23,27);
    //eye
    fill(73,64,24);
    ellipse(x+15,y-3,5,5);
    fill("white");
    ellipse(x+14,y-4,2,2);
    //smile
    stroke(73,64,24);
    strokeWeight(1);
    point(x+19,y+6);
    point(x+20,y+6.5);
    point(x+21,y+7);
    point(x+22,y+7.3);
    point(x+23,y+7);
    point(x+24,y+6.5);
}

function pinkfish(x,y){
    //tail
    noStroke();
    fill(193,82,144);//dark pink
    triangle(x-38,y+13,x-38,y-13,x,y);
    //fin on top and bottom
    fill(233,171,205);//light pink
    triangle(x+5,y-17,x-10,y-23,x-10,y+10);
    //body
    fill(193,82,144);
    ellipse(x,y,55,34);
    //fin
    fill(233,171,205);
    triangle(x-15,y-6,x-15,y+6,x,y-2);
    //head
    fill(233,171,205);
    ellipse(x+16,y,23,27);
    //eye
    fill(73,64,24);
    ellipse(x+15,y-3,5,5);
    fill("white");
    ellipse(x+14,y-4,2,2);
    //smile
    stroke(73,64,24);
    strokeWeight(1);
    point(x+19,y+6);
    point(x+20,y+6.5);
    point(x+21,y+7);
    point(x+22,y+7.3);
    point(x+23,y+7);
    point(x+24,y+6.5);
}

Project 06

For my abstract clock, the day/night period is from 7 am to 7 pm & vice versa. This means that the sun rises & sets at 7 am & 7 pm, respectively. The number of stars displayed on screen references what minute it is, and one complete rotation of a star = 1 minute. The half-circle path that the sun/moon takes can be used to tell the hour.

sketch
//Lily van Veen, section B, lvanveen@andrew.cmu.edu, project 6
var r; //red value
var g; //green value
var b; //blue value
var h; //hour
var m; //min
var s; //sec
var x = []; //x value of top point of stars
var y = []; //y value of top point of stars
var t = 0; // rotation/turn of stars

function setup() {
	frameRate(30);
    createCanvas(480, 480);
    background(235, 205, 124);
    for(var i = 0; i < 60; i++){ 
    	x[i] = random(30, width-30);
    	y[i] = random(30, height-240);
    }
}

function draw() {
	let h = hour();
    let m = minute();
    let s = second();
	if(h > 7 & h < 19){ //"sunrise" and "sunset" will happen @ 7 am & 7 pm respectively
    	r = 235; //yellow
    	g = 205;
    	b = 124;
    	background(r, g, b);
    }else if(h < 7 || h > 19){
    	r = 48; //blue
    	g = 68;
    	b = 133;
    	background(r, g, b);
    }else if(h == 7){
    	r += .01; // w/ .01 change in color @ 30 fps, will take abt 2 min to fully shift from day to night (also about the same time a sunset/sunrise takes :) )
    	g += .01;
    	b -= .01;
    	background(min(r, 235), min(r, 205), max(b, 124));
    }else if(h == 19){
    	r -= .01;
    	g -= .01;
    	b += .01;
    	background(max(r, 48), max(g, 68), min(b, 133));
    }

    for(var i = 0; i < m; i++){ // i is used to count the # of minutes; this is the section to draw the star - initally was going to put this under a function called drawStar(); but didn't function properly
    	push();
        translate(x[i], y[i]);
        rotate(radians(s*6));
    	fill(255, 249, 201); //light yellow
	    strokeWeight(0);
	    triangle(0, -5, -5, 5, 5, 5);
	    triangle(-5, 5, -7.5, 10, 0, 7.5);
	    triangle(5, 5, 7.5, 10, 0, 7.5);
	    triangle(0, 7.5, -5, 5, 5, 5);
	    triangle(-5, 5, -10, 0, 0, 0);
	    triangle(5, 5, 10, 0, 0, 0);
	    pop();
    }
    	push(); //creates path of sun to better indicate hour of the day, "sun" visible from 7 am -> 7 pm
    	translate(240, 480);
    	rotate(radians((((h-7)*60)+m)*(360/1440)));
    	strokeWeight(0);
    	fill(255, 248, 189);
    	ellipse(-215, 0, 50, 50);
    	pop();

    	push(); //creates path of sun to better indicate hour of the day, "sun" visible from 7 pm -> 7 am
    	translate(240, 480);
    	rotate(radians((((h-7)*60)+m)*(360/1440)+180));
    	strokeWeight(0);
    	fill(255, 248, 189);
    	ellipse(-215, 0, 50, 50); //so the ellipse to carve out moon shape is the same as bg :)
    	if(h > 7 & h < 19){ //"sunrise" and "sunset" will happen @ 7 am & 7 pm respectively
      	    r = 235;

Project: 06 – Abstract Clock

Crop Circles

I was inspired by crop circles for my clock. Each node is one hour in a day. The crops in the background grow with the mouse.

Sketch
sketch
/* Evan Stuhlfire
** estuhlfi@andrew.cmu.edu, section B
** Project 06: Abstract Clock  */

var r = 90; // radius of center circle, noon
var deg = 360; // degrees in a circle
var nodeCount = 24; // 24 hours, each node is one hour
var c = []; // color array
var x = []; // x position of circle
var theta = []; //angle
var size = []; // diam of the circles
var defaultColor;
var tempSize = 0; // allows the nodes to grow with time
var pSize = 25;

function setup() {
    createCanvas(480, 480);
    background(127, 198, 164);
    fillArray(); // fill arrays with start values

}

function draw() {
    var thetaRotate = 40; // canvas rotation

    background(127, 198, 164);
    drawCrops();

    // build color array
    buildColorArray();

    stroke(93, 115, 126);
    // settings to draw circles (nodes)
    push(); // save settings
    translate(width/2, height/2); // reset origin to center
    rotate(radians(thetaRotate)); // rotate canvas to draw at an angle

    // call function to draw the nodes
    drawNodes();
    pop(); // restore settings

    // make crops reactive to mouse location and time
    pSize = mouseX/hour();
}

function drawCrops() {
    var rows = width/30;
    var cols = height/30;
    var incr = width/16;
    
    var s1 = width/16;
    var s2 = height/16;
    var len = pSize;
    var a = len/4; 

    // loop over double for loop to add colums and rows of crops
    for(var i = 0; i < rows; i++) {
        for(var j = 0; j < cols; j++) {
            push();
            translate(s1/2, s2/2);
            drawOne(len, a); 
            pop();
            s2 += 2 * incr;
        }
        s1 += 2 * incr;
        s2 = incr;
    }
}

function drawOne(len, a) {
    // function to draw on plant for crops
    stroke(93, 115, 126, 60);
    line(0, -a, 0, len);
    line(-a, -a, 0, len/2);
    line(a, -a, 0, len/2);
}

function buildColorArray() {
    // set the default color
    defaultColor = color(242, 245, 234);

    // fill array with colors
    for(var i = 0; i < x.length; i++){
        if(i < 3) {
            c[i] = color(93, 115, 126);    
        } else if(i < 6) {
            c[i] = color(118, 129, 179);
        } else if(i < 9) {
            c[i] = color(214, 248, 214);
        } else if(i < 11) {
            c[i] = color(163, 213, 255);
        } else if(i < 14) {
            c[i] = color(250, 243, 62);
        } else if (i < 16) {
            c[i] = color(163, 213, 255);
        } else if (i < 19) {
            c[i] = color(214, 248, 214);
        } else if (i < 22) {
            c[i] = color(118, 129, 179);
        } else if (i < 25) {
            c[i] = color(93, 115, 126)
        }
    }
}

function fillArray() {
    var angle = 30; // nodes are positioned 30 degrees apart
    var angle2 = 150; // starting point for second set of nodes
    var dist = 65; // nodes begin at dist from center
    var offset = 1.2 // distance offset 
    var offset2 = .8 
    var minSize = 15; // can be no smaller than minSize

    // fill arrays with start values
    x.push((-deg/2) + 10);
    theta.push(180);
    size.push(r * offset2); // 80% size of center

    // fill array with first 12 nodes
    for(var i = 1; i < nodeCount/2; i++) {
        x[i] = dist;
        theta[i] = angle * i;
        size[i] = max(r * i/18, minSize);

        dist = dist + i * offset;
    }

    // push center circle into array
    x.push(deg/2 - 10);
    theta.push(0);
    size.push(r);

    dist = dist - i * offset; // undo last dist calc
    // fill array with last 12 nodes
    // loop backward so that decreasing i can be used to decrease size
    for(i = x.length; i > 2; i--) {
        x.push(dist);
        theta.push(angle2);
        size.push(max(r * i/22, minSize));

        dist = dist - i * offset2;
        angle2 -= angle;
    }

    // push last circle into array, midnight
    x.push(0);
    theta.push(0);
    size.push(r * offset2); // 80% size of center
}

function drawNodes() {
    var h = hour();
 
    stroke(93, 115, 126);
    // draw line behind center node so that it is behind
    line(0, 0, deg/2, 0);

    // draw the satellite nodes
    push();

    translate(x[0], 0); // reset origin to top circle
    loopAndDraw(0, x.length/2, h);

    // draw top midnight circle
    fill(c[0]);
    circle(0, 0, r * .8);
    pop();

    push();
    translate((deg/2) -10, 0);
    loopAndDraw(int(x.length/2) + 1, x.length, h);

    pop();
}

function loopAndDraw(start, end, h) {
    var dx;
    var dy;
    var current = false; // identify the current node

    // iterate over arrays
    for(var i = start; i < end; i++) {
        dx = x[i] * cos(radians(theta[i]));
        dy = x[i] * sin(radians(theta[i]));

        // midnight
        if(h == 0) {
            h = 24;
        }
        // if the hour has passed or is the current hour use fill
        if(i < h){
            fill(c[i]);
        } else if (i == h) {
            current = true;
            fill(c[i]);
        } else {
            fill(defaultColor);
        }

        stroke(93, 115, 126);
        line(0, 0, dx, dy);
        circle(dx, dy, size[i]);

        if(current) {
            currentHour(i, dx, dy);
        }

        current = false;
    }
}

function currentHour(i, dx, dy) {
    // add time elements to nodes to track time
    // subtract to adjust for rotation of canvas
    var s = second() * 6 - 140;
    var m = minute() * 6 - 140;
    var h = hour() * 30 + minute()/2 - 140; 

    fill(c[i]); // use the color stored in the array
    push();
    translate(dx, dy);
    // make current circle bigger
    tempSize = size[i] * 1.32;
    circle(0, 0, tempSize);

    // have a second hand orbit the current hour
    if(i > 3 & i < 23) {
        fill(c[i - 3]); //use previous color.
    } else {
        fill(defaultColor);
    }
    // mark hours
    var hx = size[i] * .6 * cos(radians(h));
    var hy = size[i] * .6 * sin(radians(h));
    circle(hx, hy, tempSize * .25);

    // mark minutes
    var mx = size[i] * .3 * cos(radians(m));
    var my = size[i] * .3 * sin(radians(m));
    
    circle(mx, my, tempSize * .2);

    // mark seconds
    var armX = size[i] * .55 * cos(radians(s));
    var armY = size[i] * .55 * sin(radians(s));
    strokeWeight(1);
    circle(armX, armY, tempSize * .15);
    pop();
}

Project 06

Abstract Clock

For my clock, I attempted to represent time using the method of burning candles. As we progress into the hour, the candle will become shorter and shorter until the 59th minute is reached. Then, the candle will reset to the original height. The light stripes in the background represent the hour of day on a 24-hour basis.

sketch
// Theresa Ye
// Section E
// thye@andrew.cmu.edu
// Project-06

var x = [16,16,8,12,14,15,16,16,24,28,16,16];
var y = [0,0,-8,-24,-16,-12,-24,-32,-20,-8,0,0];

function setup() {
    createCanvas(400, 400);
    frameRate(7);
}

function draw() {
    background(179,217,217);

    // make background stripes (light stripes = hour)
    strokeWeight(10);
    stroke(102,179,179);
    for (var i = 1; i < hour(); i++) {
        line(0,i*height/hour(),width,i*height/hour());
    }

    translate(width/2 - 16, 400 - 16);

    //make candle :> (candle burning = minutes)
    fill('yellow');
    stroke(0);
    strokeWeight(2);
    rect(6,0,20,-300 + 5*minute()+ 3)
    ellipse(16,-300 + 5*minute() + 3,20,10);

    //make flame :>
    var npoints = x.length;
    fill('pink');
    beginShape();
    for (var i = 0; i < 12; i++) {
        curveVertex(x[i] + random(-3,3),-300 + 5*minute() + y[i] + random(-3,3));
    }
    endShape(CLOSE);
}

Project 6 abstract clock

I sort of messed around with the changing of these blocks for a while. I had them as notches for a second but I liked how at midnight it’ll turn to a black screen and slowly become red green and blue again. I also liked the layering effect of seconds in front of minutes in front of hours. It would be interesting to try to make it into more of a shifting gradient of red green and blue.

sketchDownload
//felix cooper fcooper D
var secs = {x:200, y:240, w:100, r:0};
var mins = {x:100, y:240, w:100, g:0};
var hours = {x:0, y:240, w:100, b:0}; //initializes each time box as an object

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

function draw() {
    let s=second(); //sets a variable connected to each set of time
    let m=minute();
    let h=hour();

    background(255);

    fill(0,0,hours.b);
    noStroke();
    rect(hours.x,hours.y-4,300,240); //draws rectangle across canvas
    hours.y=map(hour() + norm(minute(), 0, 60),0,24,0,240); //mapps y value to hours
    hours.b=map(hour() + norm(minute(), 0, 60),0,24,0,255);//same for b value, the norm function makes it move in minute incriments
    if(h == 0){
        hours.y=240; //resets at midnight
    }

    fill(0,mins.g,0);
    noStroke();
    rect(mins.x,mins.y-4,300,240); //does the same stuff just for minutes 
    mins.y=map(minute() + norm(second(), 0, 60),0,60,0,240);
    mins.g=map(minute() + norm(second(), 0, 60),0,60,0,255);
    if(m == 0){
        mins.y=240;
    }

    fill(secs.r,0,0);
    noStroke(); //does the same stuff just for seconds 
    rect(secs.x,secs.y-4,300,240);
    secs.y=map(second(),0,60,0,240);
    secs.r=map(second(),0,60,0,255);
    if(s == 0){
        secs.y=240;
    }

}