Category: Assignment-05-Clock

Worm Clock

The longer this clock is open the more layers it will get. The top of the worm is one third of a millisecond, the bottom is a year, and everything else follows accordingly.

sketch10

//int f= millis();
function setup() {
  createCanvas(180, 900);
  background(255);
  smooth();
}

function draw() {
  var j = millis() % 60;
  var g = (millis() / 10) % 60;
  var f = (millis() / 100) % 60;
  var s = second();
  var m = minute();
  var h = hour();
  var q = day();
  var w = month();
  var e = year() % 60;
  //background(255);




  strokeWeight(3);
  //line(60, 0,60 , 800);  

  var jFade = map(j, 0, 60, 255, 0);
  //  stroke (jFade);
  //  strokeWeight(1);
  //  line(j, 0, j, 50);
  //  line(120-j, 0, 120-j, 50);

  var gFade = map(g, 0, 60, 255, 0);
  fill(gFade);
  strokeWeight(1);


  var fFade = map(f, 0, 60, 255, 0);
  stroke(fFade);

  translate(50, 50);
  
  beginShape();
  
  // please dont ask about the mysterious line at the top
  curveVertex(120 - j, -100);
  curveVertex(120 - j, 0);
  curveVertex((width / 2)-25, -50);
  curveVertex(j, 0);
  curveVertex(j,-100);
  // its a worm i swear
  
  endShape();
  
  
  beginShape();
  curveVertex(e, 600)
  curveVertex(e, 600)
 //curveVertex((width / 2)-50, 750-100);
 curveVertex((width / 2)-25, 725);
   curveVertex(120 - e, 700);
  curveVertex(120-e, 700);
 
  
  endShape();

 
 

  beginShape();

  curveVertex(width / 2, 700); //bottom
  curveVertex(e, 600)
  curveVertex(w, 500)
  curveVertex(q * 4, 400);
  curveVertex(h, 300);
  curveVertex(m, 225);
  curveVertex(s, 150);
  curveVertex(f, 100);
  //curveVertex(g, 100); 
  curveVertex(g, 50);
  curveVertex(j, 0);



  //Positive right side ^^
  //leftside  vv


  curveVertex(120 - j, 0);

  curveVertex(120 - j, 50);
  curveVertex(120 - g, 100);
  //curveVertex( 120-f, 100);
  curveVertex(120 - f, 150);
  curveVertex(120 - s, 225);
  curveVertex(120 - m, 300);
  curveVertex(120 - h, 400);
  curveVertex(width - q * 4, 500);
  curveVertex(120 - w, 600);
  curveVertex(120 - e, 700);
    curveVertex(120-e, 700);
// //  curveVertex(120-e, 600);
//   curveVertex(120-w, 800);
// //  curveVertex(120-w, 500);
//   curveVertex(width - q*4, 900);
// // curveVertex(width - q*4, 400);
//   curveVertex(120-h, 1000);
// // curveVertex(120-h, 300);
//   curveVertex( 120- m, 1075);
//   //curveVertex( 120-m, 225);
//   curveVertex(120- s, 1150);
//   //curveVertex(120-s, 150);
//   curveVertex(120- f, 1200);
//   //curveVertex( 120-f, 100);
//   curveVertex( 120- g, 1250);
//   //curveVertex(120- g, 50);
//   curveVertex( 120-j,1300 );
//   //curveVertex(120-j, 0);
//   curveVertex(width/2, 1300);


  endShape();

}

Sin clock

Clock sketch

////////////////////////
// Sin clock
// by Matthew Kellogg
// October 6, 2014
///////////////////////

//three waves, H, M, S
var milliOff, prevSec;

function setup(){
  createCanvas(600,290);
  prevSec = second();
}

function draw(){
  if (milliOff == undefined & prevSec != second()){
    milliOff = millis();
  }
  background(0);
  stroke(255,0,0);
  var mill = millisAligned() % 1000;
  var pMilli = 0.0;
  var pSec = 0.0;
  var pMin = 0.0;
  var pHour = 0.0;
  var sec = secondF();
  var min = minuteF();
  var hour = hourF();
  for (var i = 0; i<width; i++){
    var sigMilli = sin(mill*PI*i*1.0/width);
    var sigSec = sin(sec*PI*i*1.0/width);
    var sigMin = sin(min*PI*i*1.0/width);
    var sigHour = sin(hour*PI*i*1.0/width);
    //draw milli seg
    var waveSize = 30;
    translate(0,40);
    stroke(0,200, 30);
    strokeWeight(1);
    line(i, pMilli*waveSize, i+1, sigMilli*waveSize);
    translate(0,70);
    stroke(0,180, 160);
    strokeWeight(2);
    line(i, pSec*waveSize, i+1, sigSec*waveSize);
    translate(0,70);
    stroke(0, 120, 200);
    strokeWeight(3);
    line(i, pMin*waveSize, i+1, sigMin*waveSize);
    translate(0,70);
    stroke(0,40, 230);
    strokeWeight(4);
    line(i, pHour*waveSize, i+1, sigHour*waveSize);
    translate(0,-250);
    pMilli = sigMilli;
    pSec = sigSec;
    pMin = sigMin;
    pHour = sigHour;
  }
}

function hourF(){
  return hour() + minuteF()/60.0;
}

function minuteF(){
  return minute() + secondF()/60.0;
}

function secondF(){
  return second() + ((millis() - milliOff)%1000)/1000.0;
}

function millisAligned(){
  return (millis() - milliOff) % 1000;
}

I made a clock where each division of time is one half period of a sin wave. From top to bottom there are milliseconds, seconds, minutes, and hours. I made it smoothly transition by fractional parts of a second. Originally I was going to modulate all of them together, but the time was not decipherable from the resulting wave.

color target clock

 

 

clair chin target clock

each section of my target changes color within a range gradually here’s 12:29-12:31.

 

targetgif

float secondHsbVal;

void setup() {
size(600, 600);
strokeWeight(35);
stroke(0);
}

void draw() {
colorMode(HSB,360,100,100);
background(0);
float s = map(second(), 0, 60,178, 302);
float m = map(minute(), 0, 60, 61, 245);
float h = map(hour(), 0, 24, 310, 160);
fill(s,54,99);
ellipse(300,300,600,600);
fill(m,75,99);
ellipse(300,300, 400, 400);
fill(h,73,99);
ellipse(300, 300,200, 200);
}

 

Screen Shot 2014-10-01 at 8.25.22 PM

Beyoncé time

1 PM
1 PM
4 AM
4 AM
10 PM
10 PM

Screen Shot 2014-10-02 at 1.20.29 AM

This is a one-hour sample of a full 24 hour clock (because what even are arrays??? The way I know how, it would have taken me 300 lines HA). Each hour has a different artist/playlist corresponding with the time of day. The hours are divided only by the song and not the actual minutes and seconds.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  void setup() {
    size(600, 150);
  }
  void draw () {
    background (0);
    strokeWeight (3);
    noFill();
    rect (50, 50, 200, 100);
 
 
    //int S=  (  (((hour()*60) +minute()) *60) +second() );
    int S = second()+ 250;
 
 
    println (S);
    textAlign(CENTER);
    PFont font;
    font = loadFont("OratorStd-Slanted-48.vlw");
    textFont(font);
    textSize(18);
    fill (255);
 
    if (S&lt;=257) {                         
      text("Beyoncé \"Pretty Hurts \"", 300, 75);
    } else if (S&lt;=626) {
      text("Beyoncé \"Haunted \"", 300, 75);
    } else if (S&lt;= 1001) {
      text("Beyoncé \"Drunk In Love (feat. Jay-Z) \"", 300, 75);
    } else if (S&lt;= 1504) {
      text("Beyoncé \" Blow\"", 300, 75);
    } else if (S&lt;= 1895) {
      text("Beyoncé \"Partition \"", 300, 75);
    } else if (S&lt;= 2273) {
      text("Beyoncé \" Jealous\"", 300, 75);
    } else if (S&lt;= 2524) {
      text("Beyoncé \"Mine(feat. Drake)\"", 300, 75);
    } else if (S&lt;= 2800) {
      text("Beyoncé \" ***Flawless (feat. Chimamanda Ngozi Adiche)\"", 300, 75);
    } else if (S&lt;=3030 ) {
      text("Beyoncé \"Superpower (feat. Frank Ocean) \"", 300, 75);
    } else if (S&lt;= 3296) {
      text("Beyoncé \" Heaven\"", 150, 100);
    } else if (S&lt;=3600 ) {
      text("Beyoncé \" Blue (feat. Blue Ivy)\"", 300, 75);
    }
  }

Clock : Distortion

My clock concept underwent some serious changes as it progressed. At first, my plan was to have a city which built itself and then destroyed itself every 24 hours, as shown in the schematics below:
clock sketch
Using toxiclibs, I managed to create a class which would create a flat plane in 3D space. As time progressed, boxes would emerge from the plane and grow upwards to a predetermined stop height. The problem was that if the plane was slanted in any direction, the boxes would still go straight up. I spent roughly 12 hours trying to fix this, but without any specific plan or debugging methodology, I only managed to waste loads of time and create more errors with the box generation. I ditched the idea of boxes for lines, which were much less time consuming to deal with. In the end, I managed to create a class which would accept any mesh, and generate lines which grow out of the given mesh in a specific direction. Thus, when a mesh that looks like this:

clock mesh

is fed into the class, this is the result:

screencap 4

captured in motion:

clock-example1

I inserted a shape into a 3D environment:

screencap 5

Originally, I planned to make the lines simply grow in different directions based on the time of day, but that didn’t seem to involve the surrounding terrain at all. Instead, I raised the shape high above the land, and altered the topography:

screencap 0

The beam of light moves to predetermined points (the intersections of the crevices between hills) around the terrain once per minute. A sped up section of random movement is shown here:

moving-round

While at these points, the light will distort the surface of the terrain in one of five ways:

terraform-1
The light pulls the land up toward it
terraform-2
The light expands the land, making it grow outwards
terraform-3
The light collapses the land down to a single point
terraform-4
The light stirs the land around
terraform-5
The light pushes the land away from it

Every hour, the mesh is reset. One can look at the mesh and, judging its degree of distortion, tell how far into the current hour one is. Implementing a way to tell which hour is the next step, but currently this is only a one hour clock.

Here is a timelapse of the clock in action:

one-hour

Code:

import toxi.color.*;
import toxi.color.theory.*;
import toxi.physics2d.constraints.*;
import toxi.physics.*;
import toxi.physics.constraints.*;
import toxi.physics.behaviors.*;
import toxi.math.conversion.*;
import toxi.geom.*;
import toxi.math.*;
import toxi.util.datatypes.*;
import toxi.util.events.*;
import toxi.geom.mesh.subdiv.*;
import toxi.geom.mesh.*;
import toxi.math.waves.*;
import toxi.util.*;
import toxi.math.noise.*;
import java.util.*;
import toxi.processing.*;
import java.util.*;
 
import processing.opengl.*;
int timeChange;
Viewer v;
Mesh3D shape;
ToxiclibsSupport gfx;
SuperStructure struc;
VerletPhysics world;
Land land;
Agent3D zapPos;
int imginc, curMin, curHour;
void setup(){
  size(1700,1000,OPENGL);
  v = new Viewer(-1280,-776,-1109, new Vec3D());
  struc = new SuperStructure(0,-1000,0,(TriangleMesh)new AABB(20).toMesh(),new Vec3D(0,1,0),100,83,2000,1);
  gfx = new ToxiclibsSupport(this);
  world = new VerletPhysics();
  land = new Land(0,50,0,new Vec3D());
  imginc = 0;
  timeChange = 0;
  zapPos = new Agent3D(0,0,0,new Vec3D());
  zapPos.maxSpeed = 15.0;
  zapPos.maxForce = 5.0;
  curMin = minute();
  curHour = hour();
  zapPos.setSeekPt(land.marks.get(int(random(land.marks.size()))));
  struc.zapPoint(zapPos);
}
 
void draw(){
  noCursor();
  background(30,40,90);
 
  if(curMin != minute()){
    zapPos.setSeekPt(land.marks.get(int(random(land.marks.size()))));
    struc.zapPoint(zapPos);
    curMin = minute();
    land.changeRule(int(random(5)));
    imginc++;
  }
  if(curHour != hour()){
    land.reconfiguring = true;
    curHour = hour();
  }
 
  world.update();  
  zapPos.run(gfx);
  Vec3D lightPos = struc.interpolateTo(zapPos,0.8);
  pointLight(220,180,200,lightPos.x,lightPos.y,lightPos.z);
  noStroke();
  struc.run(gfx);
  land.run(gfx);
  v.run();
  if(key == 'c'){
    println(v.campos, v.direction);
  }
}
class Agent3D extends VerletParticle{
  Vec3D targ, direction;
  TriangleMesh shape;
  float maxSpeed, maxForce;
  Agent3D(float x, float y, float z){
    super(x,y,z);
    direction = null;
    shape = new TriangleMesh();
    targ = null;
    maxSpeed = 5.0;
    maxForce = 1.2;
  }
  Agent3D(float x, float y, float z, Vec3D rot){
    this(x,y,z);
    direction = rot;
  }
  Agent3D(float x, float y, float z, Vec3D rot, TriangleMesh shape){
    this(x,y,z,rot);
    this.shape = shape;
  }
  void setSeekPt(Vec3D target){
    targ = target;
  }
  void setDirectionToFace(Vec3D pt){
    direction.set(this.sub(pt).normalize());
  }
  void seek(){
    if(targ != null){
      Vec3D c = this.sub(targ);
      float m = map(c.magnitude(),0,100,0,maxSpeed);
      c = c.normalizeTo(m);
      Vec3D steer = this.getVelocity().sub(c);
      steer = steer.limit(maxForce); 
      this.addVelocity(steer);
    }
  }
 
  void display(ToxiclibsSupport tls){
   tls.translate(this);
   shape = shape.pointTowards(direction);
   tls.mesh((Mesh3D)shape, false);
   tls.translate(new Vec3D().sub(this));
  }
  void run(ToxiclibsSupport tls){
    seek();
    update();
    display(tls);
    clearVelocity();
  }
}
class SuperStructure extends Agent3D{
  int timeOfBirth, age, maxAge, maxBlocks;
  Structure[] structs;
  SuperStructure(float x, float y, float z, Mesh3D m, Vec3D dir, int lifespan, int blockNum, int blockH, int blockW){
    super(x,y,x,dir);
    maxBlocks = blockNum;
    maxAge = lifespan;
    shape = (TriangleMesh)new STLReader().loadBinary(sketchPath("god.stl"),STLReader.TRIANGLEMESH);
    structs = new Structure[m.getFaces().size()];
    for(int i = 0; i < structs.length; i++){
      Face f = (Face)m.getFaces().toArray()[i];
      structs[i] = new Structure(this.x,this.y,this.z,this.direction, blockH, maxAge, blockW, blockH, maxBlocks, f);
    }
  }
  void zapPoint(Vec3D pt){
    setDirectionToFace(pt);
    for(Structure s: structs){
      s.setDirectionToFace(pt);
    }
  }
  void run(ToxiclibsSupport tls){  
    zapPoint(zapPos);
    for(Structure s: structs){
      if(s != null){
        s.grow();
      }
    }
    fill(255);
    this.display(tls);
  }
}
 
class Structure extends Agent3D{
  float baseRadius, maxBlockWidth, maxBlockHeight, blockWidth, blockHeight;
  int timeOfBirth, age, maxAge, maxBlockNum, blockSlot, lifeStage;
  Block[] blocks;
  Triangle3D base;
 
  Structure(float x, float y, float z, Vec3D dir, float top, int lifespan, float wid, float hei, int blockNum, Face baseMake){
    super(x,y,z,dir);
    timeOfBirth = frameCount;
    maxBlockWidth = wid;
    blockSlot = 0;
    maxBlockHeight = hei;
    maxBlockNum = blockNum;
    maxAge = lifespan;
    blocks = new Block[maxBlockNum];
    base = new Triangle3D((Vec3D)baseMake.a, (Vec3D)baseMake.b, (Vec3D)baseMake.c);
    for(int i = 0; i < maxBlockNum; i++){
       Vec3D newPoint = base.a.interpolateTo(base.b.interpolateTo(base.c,random(1)),random(1));  
       blocks[i] = new Block(newPoint.x,newPoint.y,newPoint.z,direction,maxBlockWidth,maxBlockHeight,(int)random(maxAge));
    }
  }
  void setDirectionToFace(Vec3D pt){
    direction = pt.sub(this).normalize();
  }
  Triangle3D buildBase(){
    Vec3D[] corners = new Vec3D[3];
    for(int i = 0; i < 3; i++){
      //creates corners by making flat random vector and then rotating to match structures rotation
      Vec3D newCorner = new Vec3D(random(-1,1)*baseRadius,0,random(-1,1)*baseRadius).rotateX(direction.x).rotateY(direction.y);
      corners[i] = newCorner;
    }
    return new Triangle3D(corners[0],corners[1],corners[2]);
  }
  void grow(){
    gfx.translate(this);
    for(int i = 0; i < maxBlockNum; i++){
      Block b = blocks[i];
        b.grow();
        b.display(gfx);
        if(frameCount-b.birth > b.maxAge){
        Vec3D newPoint = base.a.interpolateTo(base.b.interpolateTo(base.c,random(1)),random(1));  
        blocks[i] = new Block(newPoint.x,newPoint.y,newPoint.z,direction,maxBlockWidth,maxBlockHeight,maxAge);
      }
    }
    gfx.translate(new Vec3D().sub(this));
  }
}
 
class Block extends Agent3D{
  float wdth, hght;
  int tone, birth, maxAge;
  TColor col;
  Vec3D up;
  Vec3D box;
  Block(float x,float y,float z,Vec3D rot, float wt, float ht,int maxAge){
    super(x,y,z,rot);
    birth = frameCount;
    this.maxAge = maxAge;
    wdth = wt;
    hght = ht;
    box = blockFace();
    tone = int(noise(frameCount*0.03)*30);
  }
 
  Vec3D blockFace(){
    return this.add(direction.normalizeTo((frameCount+1-birth)*1.0/maxAge*hght));
  }
 
  void grow(){
    box = blockFace();
  }
  void display(ToxiclibsSupport tls){
    strokeWeight(wdth);
    stroke(180,180,200,tone);
    tls.line(this,box);
  }
}
class Viewer{
  Vec3D direction, campos;
  Viewer(float x, float y, float z, Vec3D dir) {
    direction = dir;
    campos = new Vec3D(x,y,z);
  }
 
  void run() {
    direction.set(sin(map(mouseX,0,width,2*PI,0)),map(mouseY,0,height,-1.5,1.5),cos(map(mouseX,0,width,2*PI,0)));
    direction.addSelf(campos);
 
  // Change height of the camera with mouseY
    camera(campos.x, campos.y, campos.z, // eyeX, eyeY, eyeZ
         direction.x, direction.y, direction.z, // centerX, centerY, centerZ
         0.0, 1.0, 0.0); // upX, upY, upZ
      if(keyPressed){
        Vec3D dir = direction.copy();
        dir.subSelf(campos);
        switch(key){      
          case('a'): 
            dir.set(sin(map(mouseX,0,width,2.5*PI,PI/2)),0,cos(map(mouseX,0,width,2.5*PI,PI/2)));
            campos.addSelf(dir.normalizeTo(3));    
            break;
          case('w'):
            campos.addSelf(dir.normalizeTo(3));
            break;
          case('d'):           
            dir.set(sin(map(mouseX,0,width,2.5*PI,PI/2)),0,cos(map(mouseX,0,width,2.5*PI,PI/2)));
            campos.subSelf(dir.normalizeTo(3));
            break;
          case('s'):
            campos.subSelf(dir.normalizeTo(2));
            break;
        }
    }
  }
}
class Land extends Agent3D{
  TriangleMesh originalShape;
  Terrain terrain;
  ArrayList<Agent3D> marks;
  int ruleNum;
  boolean reconfiguring;
  float reconfigRatio;
  float xCenter = 5.2;
  float zCenter = 5.2;
  Land(float xx,float yy,float zz, Vec3D dir){
    super(xx,yy,zz,dir);
    marks = new ArrayList();
    int DIMS = 40;
    reconfiguring = false;
    reconfigRatio = 0.0;
    terrain = new Terrain(DIMS,DIMS, 50);
  float[] el = new float[DIMS*DIMS];
  noiseSeed((long)random(500));
  ruleNum = int(random(5));
  for (int z = 0, i = 0; z < DIMS; z++) {
    for (int x = 0; x < DIMS; x++) {
      el[i++] = noise(x * 0.12, z * 0.12) * 400/PApplet.max((PApplet.abs(xCenter - (x%10))*PApplet.abs(zCenter-(z%10))),4);
      if((x+5)%10 == 0 && (z+5)%10 == 0){
        IsectData3D sec = new IsectData3D();
        sec = terrain.intersectAtPoint(x,z);
        marks.add(new Agent3D(sec.pos.x()*50-1000,150,sec.pos.z()*50-1000,new Vec3D()));
      }
    }
  }
  terrain.setElevation(el);
  // create mesh
  shape = (TriangleMesh)terrain.toMesh();
  originalShape = shape.copy();
  }
  void display(ToxiclibsSupport tls){
    noStroke();
    super.display(tls);
    stroke(255,0,0);
  }
 
  void run(ToxiclibsSupport tls){
    if(reconfiguring) {
      reconfigure();
    }
    super.run(tls);
    for(Agent3D mark: marks){
      mark.run(tls);
    }
    alterTerrain(zapPos);
  }
 
  ArrayList<Vec3D> getVertexPoints(TriangleMesh s){
    ArrayList<Vec3D> start = new ArrayList();
    Iterator<Vertex> getter = shape.getVertices().iterator();
    while(getter.hasNext()){
      start.add((Vec3D)getter.next());
    }
    return start;
  }
 
  ArrayList<Vec3D> getCloseVertices(Vec3D pt){
    ArrayList<Vec3D> result = new ArrayList();
    Vec3D ptFlat = new Vec3D(pt.x,0,pt.z);
    ListIterator<Vec3D> remover = getVertexPoints(shape).listIterator();
    while(remover.hasNext()){
      Vec3D f = (Vec3D)remover.next();
      Vec3D flat = new Vec3D(f.x,0,f.z);
      if(flat.distanceToSquared(ptFlat) < 10000){
        result.add(f);
      }
    }
    return result;
  }
 
  Vec3D average(ArrayList<Vec3D> vecs){
    Vec3D result = new Vec3D();
    for(Vec3D v: vecs){
      result = result.add(v);
    }
    return result.scale(1.0/vecs.size());
  }
 
  void reconfigure(){
    shape = originalShape.copy();
    reconfiguring = false;
  }
 
  void changeRule(int r){
    ruleNum = r;
  }
 
  void alterTerrain(Agent3D cursor){
    for(Agent3D mark: marks){
      if(cursor.distanceToSquared(mark) < 4){
        ArrayList<Vec3D> nearPts = getCloseVertices(cursor);
        for(Vec3D pt: nearPts){
          Vec3D rule = new Vec3D();
          switch(ruleNum){
            case(0):
              rule = pt.sub(average(nearPts));
              break;
            case(1):
              rule = average(nearPts).sub(pt);
              break;
            case(2):
              rule = new Vec3D(cos(second()*PI/30),sin(second()*PI/15),sin(second()*PI/30));
              break;
            case(3):
              rule = new Vec3D(pt.sub(struc));
              break;
            case(4):
              rule = new Vec3D(struc.sub(pt));
              break;
          }
          shape.updateVertex(pt, pt.add(rule.normalizeTo(2)));
        }
        mark.setSeekPt(average(getCloseVertices(cursor)));
      }
    }
  }
}

 

 

Clock in Clock (EDIT: finished)

Hello all, this is a (turns out) rather complicated clock program that I was inspired to create after I saw this a few months ago:

Here is my version, it changes 15 seconds before the change of the minute.

clock

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
int radius = 120;
int lineradius=radius/2-3;
int[] cX= new int[24];
int[] cY= new int[24];
float[] time1c1r1= new float[10];
float[] time2c1r1= new float[10];
float[] time1c1r2= new float[10];
float[] time2c1r2= new float[10];
float[] time1c1r3= new float[10];
float[] time2c1r3= new float[10];
float[] time1c2r1= new float[10];
float[] time2c2r1= new float[10];
float[] time1c2r2= new float[10];
float[] time2c2r2= new float[10];
float[] time1c2r3= new float[10];
float[] time2c2r3= new float[10];
 
int prevSec; 
int prevMin;
int millisRolloverTime;
 
void setup() {
  size(1280, 720);
  for (int c=0; c&lt;8; c++) {
    for (int r=0; r&lt;3; r++) {
      int index = c+(8*r);
      cX[index]=(width/2)-(radius*4-radius/2)+(radius*c);
      cY[index]=(height/2)-radius+(radius*r);
    }
  }
 
  setTime();
  millisRolloverTime=0;
}
 
void draw() {
  background(#ffffff);
  fill(0);
  rect(width/2-radius/2, height/2-120, radius, radius*2);
  fill(#ffffff);
  noStroke();
  ellipse(width/2, height/2-radius/2, radius/2.68, radius/2.68);
  ellipse(width/2, height/2+radius/2, radius/2.68, radius/2.68);
 
  for (int i=0; i&lt;24; i++) {
    stroke(0);
    strokeWeight(4); 
    fill(#ffffff);
    ellipse(cX[i], cY[i], radius, radius);
    strokeWeight(8);
 
    showTimeMove(i);
    //showTimeTogether(i);
 
    if (minute()+1==60) {
      println("Next min: 00");
    } else {
      println("Next min: "+(minute()+1));
    }
    if (hour()+1==24) {
      println("Next hr: 00");
    } else {
      println("Next hr: "+(hour()+1));
    }
  }
}
 
float backwards(float num) {
  float newnum = num;
  if (num==0) { 
    newnum= 0;
  }
  if (num==90) { 
    newnum= 270;
  }
  if (num==135) { 
    newnum= 225;
  }
  if (num==180) { 
    newnum= 180;
  }
  if (num==270) { 
    newnum= 90;
  }
  return newnum;
}
 
void showTimeMove(int i) {
 
  if (prevSec != second()) {
    millisRolloverTime = millis();
  } 
  prevSec = second();
  int mils = millis() - millisRolloverTime;
  float test = map(second() + mils/1000.0, 0, 60, 0, 360+(0));
  line(width/2, height/2-radius/2, width/2+cos(radians(test))*20, (height/2-radius/2)+(sin(radians(test))*20));
  line(width/2, height/2+radius/2, width/2+cos(radians(test))*20, (height/2+radius/2)+(sin(radians(test))*20));
 
  float animate = 0;
  int animationTime = 16;
  if (second()&gt;=(60-animationTime)) {
    animate = (second()- (60-animationTime) + mils/1000.0);
  } else {  
    animate = 0;
  }
 
 
 
  int start = 135;
  int end = 225;
  test = -1*map(animate, 0, animationTime, -1*start, 360+end);
  //line(radius, radius, radius+cos(radians(test))*lineradius, radius+sin(radians(test))*lineradius);
 
  int digitH1=hour()/10;
  int digitH2=hour()%10;
  int digitM1=minute()/10;
  int digitM2=minute()%10;
  float coords; 
  float digitM1move;
 
  int hour = hour();
  int minute = minute();
 
 
  // FIRST DIGIT
  if (i==0) {
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r1[digitH1], 1440+(time1c1r1[digitH1+1]));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r1[digitH1], 1440+(time1c1r1[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c1r1[digitH1], 1440+(time1c1r1[digitH1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitH1], 720+(backwards(time2c1r1[digitH1+1])));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitH1], 720+(backwards(time2c1r1[0])));
    } else {      
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitH1], 720+(backwards(time2c1r1[digitH1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==1) {
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time1c2r1[digitH1], 720+(backwards(time1c2r1[digitH1+1])));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time1c2r1[digitH1], 720+(backwards(time1c2r1[0])));
    } else {      
      coords = -1*map(animate, 0, animationTime, -1*time1c2r1[digitH1], 720+(backwards(time1c2r1[digitH1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r1[digitH1], 360+(backwards(time2c2r1[digitH1+1])));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r1[digitH1], 360+(backwards(time2c2r1[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r1[digitH1], 360+(backwards(time2c2r1[digitH1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==8) {
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r2[digitH1], 360+(time1c1r2[digitH1+1]));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r2[digitH1], 360+(time1c1r2[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c1r2[digitH1], 360+(time1c1r2[digitH1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c1r2[digitH1], 720+(time2c1r2[digitH1+1]));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c1r2[digitH1], 720+(time2c1r2[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c1r2[digitH1], 720+(time2c1r2[digitH1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==9) {
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r2[digitH1], 720+(time1c2r2[digitH1+1]));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r2[digitH1], 720+(time1c2r2[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r2[digitH1], 720+(time1c2r2[digitH1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r2[digitH1], 1080+(backwards(time2c2r2[digitH1+1])));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r2[digitH1], 1080+(backwards(time2c2r2[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r2[digitH1], 1080+(backwards(time2c2r2[digitH1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==16) {
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r3[digitH1], 720+(time1c1r3[digitH1+1]));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r3[digitH1], 720+(time1c1r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c1r3[digitH1], 720+(time1c1r3[digitH1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r3[digitH1], 720+(backwards(time2c1r3[digitH1+1])));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r3[digitH1], 720+(backwards(time2c1r3[digitH1+1])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r3[digitH1], 720+(backwards(time2c1r3[digitH1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==17) {
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r3[digitH1], 720+(time1c2r3[digitH1+1]));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r3[digitH1], 720+(time1c2r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r3[digitH1], 720+(time1c2r3[digitH1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour==9 || hour==19) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c2r3[digitH1], 1080+(time2c2r3[digitH1+1]));
    } else if (hour==23 &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c2r3[digitH1], 1080+(time2c2r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c2r3[digitH1], 1080+(time2c2r3[digitH1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
 
  // SECOND DIGIT
  if (i==2) {
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r1[digitH2], 720+(time1c1r1[digitH2+1]));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r1[digitH2], 720+(time1c1r1[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c1r1[digitH2], 720+(time1c1r1[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitH2], 720+(backwards(time2c1r1[digitH2+1])));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitH2], 720+(backwards(time2c1r1[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitH2], 720+(backwards(time2c1r1[digitH2])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==3) {
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r1[digitH2], 720+(time1c2r1[digitH2+1]));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r1[digitH2], 720+(time1c2r1[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r1[digitH2], 720+(time1c2r1[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c2r1[digitH2], 1440+(time2c2r1[digitH2+1]));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c2r1[digitH2], 1440+(time2c2r1[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c2r1[digitH2], 1440+(time2c2r1[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==10) {
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r2[digitH2], 720+(time1c1r2[digitH2+1]));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c1r2[digitH2], 720+(time1c1r2[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c1r2[digitH2], 720+(time1c1r2[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c1r2[digitH2], 360+(time2c1r2[digitH2+1]));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c1r2[digitH2], 360+(time2c1r2[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c1r2[digitH2], 360+(time2c1r2[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==11) {
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r2[digitH2], 360+(time1c2r2[digitH2+1]));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r2[digitH2], 360+(time1c2r2[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r2[digitH2], 360+(time1c2r2[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r2[digitH2], 720+(backwards(time2c2r2[digitH2+1])));
    } else if (digitH2==9 &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r2[digitH2], 720+(backwards(time2c2r2[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r2[digitH2], 720+(backwards(time2c2r2[digitH2])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==18) {
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r3[digitH2], 720+(backwards(time1c1r3[digitH2+1])));
    } else if (digitH2==9 &amp;&amp; minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r3[digitH2], 720+(backwards(time1c1r3[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r3[digitH2], 720+(backwards(time1c1r3[digitH2])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c1r3[digitH2], 1080+(time2c1r3[digitH2+1]));
    } else if (digitH2==9 &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c1r3[digitH2], 1080+(time2c1r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c1r3[digitH2], 1080+(time2c1r3[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==19) {
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r3[digitH2], 1080+(time1c2r3[digitH2+1]));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time1c2r3[digitH2], 1080+(time1c2r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r3[digitH2], 1080+(time1c2r3[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if ((hour!=9 &amp;&amp; hour!=19 &amp;&amp; hour!=23) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c2r3[digitH2], 720+(time2c2r3[digitH2+1]));
    } else if ((hour==23 || hour==19 || hour==9) &amp;&amp; minute==59) {
      coords = map(animate, 0, animationTime, time2c2r3[digitH2], 720+(time2c2r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c2r3[digitH2], 720+(time2c2r3[digitH2]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
 
  // THIRD DIGIT
  if (i==4) {
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = map(animate, 0, animationTime, time1c1r1[digitM1], 720+(time1c1r1[digitM1+1]));
    } else if (minute==59) {
      coords = map(animate, 0, animationTime, time1c1r1[digitM1], 720+(time1c1r1[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c1r1[digitM1], 720+(time1c1r1[digitM1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitM1], 1080+(backwards(time2c1r1[digitM1+1])));
    } else if (minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitM1], 1080+(backwards(time2c1r1[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitM1], 1080+(backwards(time2c1r1[digitM1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==5) {
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = map(animate, 0, animationTime, time1c2r1[digitM1], 720+(time1c2r1[digitM1+1]));
    } else if (minute==59) {
      coords = map(animate, 0, animationTime, time1c2r1[digitM1], 720+(time1c2r1[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r1[digitM1], 720+(time1c2r1[digitM1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = map(animate, 0, animationTime, time2c2r1[digitM1], 360+(time2c2r1[digitM1+1]));
    } else if (minute==59) {
      coords = map(animate, 0, animationTime, time2c2r1[digitM1], 360+(time2c2r1[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c2r1[digitM1], 360+(time2c2r1[digitM1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==12) {
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r2[digitM1], 1080+(backwards(time1c1r2[digitM1+1])));
    } else if (minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r2[digitM1], 1080+(backwards(time1c1r2[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r2[digitM1], 1080+(backwards(time1c1r2[digitM1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r2[digitM1], 720+(backwards(time2c1r2[digitM1+1])));
    } else if (minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r2[digitM1], 720+(backwards(time2c1r2[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r2[digitM1], 720+(backwards(time2c1r2[digitM1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==13) {
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = -1*map(animate, 0, animationTime, -1*time1c2r2[digitM1], 720+(backwards(time1c2r2[digitM1+1])));
    } else if (minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time1c2r2[digitM1], 720+(backwards(time1c2r2[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time1c2r2[digitM1], 720+(backwards(time1c2r2[digitM1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = map(animate, 0, animationTime, time2c2r2[digitM1], 720+(time2c2r2[digitM1+1]));
    } else if (minute==59) {
      coords = map(animate, 0, animationTime, time2c2r2[digitM1], 720+(time2c2r2[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c2r2[digitM1], 720+(time2c2r2[digitM1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==20) {
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r3[digitM1], 720+(backwards(time1c1r3[digitM1+1])));
    } else if (minute==59) {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r3[digitM1], 720+(backwards(time1c1r3[0])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r3[digitM1], 720+(backwards(time1c1r3[digitM1])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = map(animate, 0, animationTime, time2c1r3[digitM1], 1080+(time2c1r3[digitM1+1]));
    } else if (minute==59) {
      coords = map(animate, 0, animationTime, time2c1r3[digitM1], 1080+(time2c1r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c1r3[digitM1], 1080+(time2c1r3[digitM1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==21) {
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = map(animate, 0, animationTime, time1c2r3[digitM1], 360+(time1c2r3[digitM1+1]));
    } else if (minute==59) {
      coords = map(animate, 0, animationTime, time1c2r3[digitM1], 360+(time1c2r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r3[digitM1], 360+(time1c2r3[digitM1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM1!=5 &amp;&amp; digitM2==9) {
      coords = map(animate, 0, animationTime, time2c2r3[digitM1], 720+(time2c2r3[digitM1+1]));
    } else if (minute==59) {
      coords = map(animate, 0, animationTime, time2c2r3[digitM1], 720+(time2c2r3[0]));
    } else {
      coords = map(animate, 0, animationTime, time2c2r3[digitM1], 720+(time2c2r3[digitM1]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
 
  // FOURTH DIGIT
  if (i==6) {
    if (digitM2!=9) {
      coords = map(animate, 0, animationTime, time1c1r1[digitM2], 1440+(time1c1r1[digitM2+1]));
    } else {
      coords = map(animate, 0, animationTime, time1c1r1[digitM2], 1440+(time1c1r1[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM2!=9) {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitM2], 720+(backwards(time2c1r1[digitM2+1])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c1r1[digitM2], 720+(backwards(time2c1r1[0])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==7) {
    if (digitM2!=9) {
      coords = map(animate, 0, animationTime, time1c2r1[digitM2], 720+(time1c2r1[digitM2+1]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r1[digitM2], 720+(time1c2r1[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM2!=9) {
      coords = map(animate, 0, animationTime, time2c2r1[digitM2], 360+(time2c2r1[digitM2+1]));
    } else {
      coords = map(animate, 0, animationTime, time2c2r1[digitM2], 360+(time2c2r1[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==14) {
    if (digitM2!=9) {
      coords = map(animate, 0, animationTime, time1c1r2[digitM2], 360+(time1c1r2[digitM2+1]));
    } else {
      coords = map(animate, 0, animationTime, time1c1r2[digitM2], 360+(time1c1r2[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM2!=9) {
      coords = map(animate, 0, animationTime, time2c1r2[digitM2], 720+(time2c1r2[digitM2+1]));
    } else {
      coords = map(animate, 0, animationTime, time2c1r2[digitM2], 720+(time2c1r2[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==15) {
    if (digitM2!=9) {
      coords = -1*map(animate, 0, animationTime, -1*time1c2r2[digitM2], 720+(backwards(time1c2r2[digitM2+1])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time1c2r2[digitM2], 720+(backwards(time1c2r2[0])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM2!=9) {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r2[digitM2], 360+(backwards(time2c2r2[digitM2+1])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time2c2r2[digitM2], 360+(backwards(time2c2r2[0])));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==22) {
    if (digitM2!=9) {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r3[digitM2], 360+(backwards(time1c1r3[digitM2+1])));
    } else {
      coords = -1*map(animate, 0, animationTime, -1*time1c1r3[digitM2], 360+(time1c1r3[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM2!=9) {
      coords = map(animate, 0, animationTime, time2c1r3[digitM2], 720+(time2c1r3[digitM2+1]));
    } else {
      coords = map(animate, 0, animationTime, time2c1r3[digitM2], 720+(time2c1r3[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
  if (i==23) {
    if (digitM2!=9) {
      coords = map(animate, 0, animationTime, time1c2r3[digitM2], 1080+(time1c2r3[digitM2+1]));
    } else {
      coords = map(animate, 0, animationTime, time1c2r3[digitM2], 1080+(time1c2r3[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
    if (digitM2!=9) {
      coords = map(animate, 0, animationTime, time2c2r3[digitM2], 360+(time2c2r3[digitM2+1]));
    } else {
      coords = map(animate, 0, animationTime, time2c2r3[digitM2], 360+(time2c2r3[0]));
    }
    line(cX[i], cY[i], cX[i]+cos(radians(coords))*lineradius, cY[i]+sin(radians(coords))*lineradius);
  }
}
 
void setTime() {
  int d;
  d=0;//SET TIME = 0
  time1c1r1[d] = 0;
  time2c1r1[d] = 90;
  time1c1r2[d] = 270;
  time2c1r2[d] = 90;
  time1c1r3[d] = 270;
  time2c1r3[d] = 0;
  time1c2r1[d] = 180;
  time2c2r1[d] = 90;
  time1c2r2[d] = 270;
  time2c2r2[d] = 90;
  time1c2r3[d] = 270;
  time2c2r3[d] = 180;
 
  d=1;//SET TIME = 1
  time1c1r1[d] = 135;
  time2c1r1[d] = 135;
  time1c1r2[d] = 135;
  time2c1r2[d] = 135;
  time1c1r3[d] = 135;
  time2c1r3[d] = 135;
  time1c2r1[d] = 90;
  time2c2r1[d] = 90;
  time1c2r2[d] = 270;
  time2c2r2[d] = 90;
  time1c2r3[d] = 270;
  time2c2r3[d] = 270;
 
  d=2;//SET TIME = 2
  time1c1r1[d] = 0;
  time2c1r1[d] = 0;
  time1c1r2[d] = 0;
  time2c1r2[d] = 90;
  time1c1r3[d] = 270;
  time2c1r3[d] = 0;
  time1c2r1[d] = 180;
  time2c2r1[d] = 90;
  time1c2r2[d] = 270;
  time2c2r2[d] = 180;
  time1c2r3[d] = 180;
  time2c2r3[d] = 180;
 
  d=3;//SET TIME = 3
  time1c1r1[d] = 0;
  time2c1r1[d] = 0;
  time1c1r2[d] = 0;
  time2c1r2[d] = 0;
  time1c1r3[d] = 0;
  time2c1r3[d] = 0;
  time1c2r1[d] = 180;
  time2c2r1[d] = 90;
  time1c2r2[d] = 270;
  time2c2r2[d] = 180;
  time1c2r3[d] = 270;
  time2c2r3[d] = 180;
 
  d=4;//SET TIME = 4
  time1c1r1[d] = 90;
  time2c1r1[d] = 90;
  time1c1r2[d] = 270;
  time2c1r2[d] = 0;
  time1c1r3[d] = 135;
  time2c1r3[d] = 135;
  time1c2r1[d] = 90;
  time2c2r1[d] = 90;
  time1c2r2[d] = 270;
  time2c2r2[d] = 90;
  time1c2r3[d] = 270;
  time2c2r3[d] = 270;
 
  d=5;//SET TIME = 5
  time1c1r1[d] = 0;
  time2c1r1[d] = 90;
  time1c1r2[d] = 270;
  time2c1r2[d] = 0;
  time1c1r3[d] = 0;
  time2c1r3[d] = 0;
  time1c2r1[d] = 180;
  time2c2r1[d] = 180;
  time1c2r2[d] = 180;
  time2c2r2[d] = 90;
  time1c2r3[d] = 270;
  time2c2r3[d] = 180;
 
  d=6;//SET TIME = 6
  time1c1r1[d] = 0;
  time2c1r1[d] = 90;
  time1c1r2[d] = 270;
  time2c1r2[d] = 90;
  time1c1r3[d] = 270;
  time2c1r3[d] = 0;
  time1c2r1[d] = 180;
  time2c2r1[d] = 180;
  time1c2r2[d] = 180;
  time2c2r2[d] = 90;
  time1c2r3[d] = 270;
  time2c2r3[d] = 180;
 
  d=7;//SET TIME = 7
  time1c1r1[d] = 0;
  time2c1r1[d] = 0;
  time1c1r2[d] = 135;
  time2c1r2[d] = 135;
  time1c1r3[d] = 135;
  time2c1r3[d] = 135;
  time1c2r1[d] = 180;
  time2c2r1[d] = 90;
  time1c2r2[d] = 270;
  time2c2r2[d] = 90;
  time1c2r3[d] = 270;
  time2c2r3[d] = 270;
 
  d=8;//SET TIME = 8
  time1c1r1[d] = 0;
  time2c1r1[d] = 90;
  time1c1r2[d] = 270;
  time2c1r2[d] = 0;
  time1c1r3[d] = 270;
  time2c1r3[d] = 0;
  time1c2r1[d] = 180;
  time2c2r1[d] = 90;
  time1c2r2[d] = 270;
  time2c2r2[d] = 180;
  time1c2r3[d] = 270;
  time2c2r3[d] = 180;
 
  d=9;//SET TIME = 9
  time1c1r1[d] = 0;
  time2c1r1[d] = 90;
  time1c1r2[d] = 270;
  time2c1r2[d] = 0;
  time1c1r3[d] = 135;
  time2c1r3[d] = 135;
  time1c2r1[d] = 180;
  time2c2r1[d] = 90;
  time1c2r2[d] = 270;
  time2c2r2[d] = 90;
  time1c2r3[d] = 270;
  time2c2r3[d] = 270;
}
 
void showTimeTogether(int i) {
  int digit=second()%10;
  //SET TIME BY ROW AND COLUMN
  if (i%2!=0) {
    if (i&lt;8) {
      line(cX[i], cY[i], cX[i]+cos(radians(time1c2r1[digit]))*lineradius, cY[i]+sin(radians(time1c2r1[digit]))*lineradius);
      line(cX[i], cY[i], cX[i]+cos(radians(time2c2r1[digit]))*lineradius, cY[i]+sin(radians(time2c2r1[digit]))*lineradius);
    } else if (i&gt;=8 &amp;&amp; i&lt;16) {
      line(cX[i], cY[i], cX[i]+cos(radians(time1c2r2[digit]))*lineradius, cY[i]+sin(radians(time1c2r2[digit]))*lineradius);
      line(cX[i], cY[i], cX[i]+cos(radians(time2c2r2[digit]))*lineradius, cY[i]+sin(radians(time2c2r2[digit]))*lineradius);
    } else {
      line(cX[i], cY[i], cX[i]+cos(radians(time1c2r3[digit]))*lineradius, cY[i]+sin(radians(time1c2r3[digit]))*lineradius);
      line(cX[i], cY[i], cX[i]+cos(radians(time2c2r3[digit]))*lineradius, cY[i]+sin(radians(time2c2r3[digit]))*lineradius);
    }
  } else {
    if (i&lt;8) {
      line(cX[i], cY[i], cX[i]+cos(radians(time1c1r1[digit]))*lineradius, cY[i]+sin(radians(time1c1r1[digit]))*lineradius);
      line(cX[i], cY[i], cX[i]+cos(radians(time2c1r1[digit]))*lineradius, cY[i]+sin(radians(time2c1r1[digit]))*lineradius);
    } else if (i&gt;=8 &amp;&amp; i&lt;16) {
      line(cX[i], cY[i], cX[i]+cos(radians(time1c1r2[digit]))*lineradius, cY[i]+sin(radians(time1c1r2[digit]))*lineradius);
      line(cX[i], cY[i], cX[i]+cos(radians(time2c1r2[digit]))*lineradius, cY[i]+sin(radians(time2c1r2[digit]))*lineradius);
    } else {
      line(cX[i], cY[i], cX[i]+cos(radians(time1c1r3[digit]))*lineradius, cY[i]+sin(radians(time1c1r3[digit]))*lineradius);
      line(cX[i], cY[i], cX[i]+cos(radians(time2c1r3[digit]))*lineradius, cY[i]+sin(radians(time2c1r3[digit]))*lineradius);
    }
  }
}

Clock: Mandala for Seconds

// stuff
var w = 600;
var h = 600;
var gx = 0;
var gy = 0;
var mx = 0;
var my = 0;
var baseRand;

// constants
var msize = 256;
var msize = 256;
var smoothness = 5;
var numLines = 10;
var mouseSensitivity = 0.004;
var secondsSpinSpeed = 0.01;
var baseSpinSpeed = 0.00001;

function setup() {
  createCanvas(w,h);
  
  baseRand = random(500,1000);
  
  // init position and start x,y at goal
  findPosition();
  mx = gx;
  my = gy;
}

function draw() {
  background(0,0,0,255);
  
  findPosition();
  
  var i,j; // ??????? never do this
  
  // stars/dust
  stroke(255,255,255,150);
  for(i = 0; i <= 360; i+=1) {
    strokeWeight(i/100);
    // chaos theory i dont know what this does really
    point(cos(i+mx-my*i*0.01)*msize*0.005*i + w/2, 
          sin(i+mx+my*i*0.01)*msize*0.005*i + w/2);
  }
  
  // sharp one
  stroke(255,255,255,30);
  strokeWeight(1);
  for(i = 0; i < 360; i+=numLines) {
    for(j = 0; j < 360; j+=numLines) {
      linedeg(i+mx,j+my,msize);
    }
  }
  
  // glowy one
  stroke(255,255,255,3);
  strokeWeight(5);
  for(i = 0; i < 360; i+=numLines) {
    for(j = 0; j < 360; j+=numLines) {
      linedeg(i+mx,j+my,msize);
    }
  }
  
  // blurry one
  stroke(255,255,255,3);
  strokeWeight(10);
  for(i = 0; i < 360; i+=numLines) {
    for(j = 0; j < 360; j+=numLines) {
      linedeg(i+mx,j+my,msize);
    }
  }
}

function findPosition() {
  // what time is it
  var seconds = round(millis()/1000);
  gx = baseRand*mouseSensitivity 
     + seconds*secondsSpinSpeed 
     + millis()*baseSpinSpeed;
  gy = baseRand/2*mouseSensitivity 
     - seconds*secondsSpinSpeed
     + millis()*baseSpinSpeed;
  
  // smooth movement
  var dx = gx-mx;
  var dy = gy-my;
  mx += dx/smoothness;
  my += dy/smoothness;
}

// draw line from a a degree to another degree on a circle
function linedeg(d1,d2,s) {
  line(cos(d1)*s + w/2, sin(d1)*s + h/2,  
       cos(d2)*s + w/2, sin(d2)*s + h/2);
}

At a Loss

This morning I, realized I had been spending way too much money. I began to relate my spending habits with the days of the week and realized that tracking the amount of money I had spent would be a perfect way for me to tell how far along into the week we are. Originally I aimed to make this in java processing, but python was much more receptive to the list structure I wanted to use, so I switched to python mode.

Here is a snapshot of September 24th at 4:44
WednesdayOctFirst444

And here is a snapshot of today, October 1st at 4:45
WednesdayOct8445

sun = []
mon = [10.56, 9.10, 19.68, 5.62, 7.39]
tue = [7.27, 6.75, 8.85, 7.39]
wed = [7.39, 7.39, 2.85]
thu = [2.00, 6.75, 13.75]
fri = [6.75, 9.08, 9.08]
sat = [7.27, 6.75, 8.85, 7.39]
 
sunTot = 0
monTot = 0
tueTot = 0
wedTot = 0
thuTot = 0
friTot = 0
satTot = 0
 
sunAvg = 0
monAvg = 0
tueAvg = 0
wedAvg = 0
thuAvg = 0
friAvg = 0
satAvg = 0
 
weekTot = 0
weekAvg = 0
 
sunLoss = 0
monLoss = 0
tueLoss = 0
wedLoss = 0
thuLoss = 0
friLoss = 0
satLoss = 0
 
lossList = []
 
todayTotal = 0
lossPerSecond = 0
 
dayLoss = 0
 
previousDayLoss = 0
 
startingCash = 0
 
totalLoss = 0
currentCash = 0
 
def setup():
    size(800,300)
    startingCash = 240 #Dollars
    initialize() 
    previousDayLoss = cashUsed()
 
def initialize():
    sunTot = total(sun)
    monTot = total(mon)
    tueTot = total(tue)
    wedTot = total(wed)
    thuTot = total(thu)
    friTot = total(fri)
    satTot = total(sat)
 
    weekList = [sunTot, monTot, tueTot, wedTot, thuTot, friTot, satTot]
    weekTot = total(weekList)
 
    sunAvg = sunTot / weekTot
    monAvg = monTot / weekTot
    tueAvg = tueTot / weekTot
    wedAvg = wedTot / weekTot
    thuAvg = thuTot / weekTot
    friAvg = friTot / weekTot
    satAvg = satTot / weekTot
    weekAvg = weekTot / 7.0
 
    sunLoss = sunAvg * startingCash
    monLoss = monAvg * startingCash
    tueLoss = tueAvg * startingCash
    wedLoss = wedAvg * startingCash
    thuLoss = thuAvg * startingCash
    friLoss = friAvg * startingCash
    satLoss = satAvg * startingCash
 
    lossList = [sunLoss, monLoss, tueLoss, wedLoss, thuLoss, friLoss, satLoss]
 
    todayTotal = lossList[dayOfWeek()]
    lossPerSecond = todayTotal / 86400
 
 
def draw():
    background(findBg())
    dayLoss = ((((hour() * 60) + minute()) * 60) + second()) * lossPerSecond
    totalLoss = previousDayLoss + dayLoss
    currentCash = startingCash - totalLoss
    printCash()
 
def total(alist):
    total = 0
    for i in alist:
        total += i
    return total
 
def dayOfWeek():
    # 5 is number of days into 2014 for sunday
    daystotal = (365*(year() - 1)) + (int(floor((year()-1)/4))) -(int(floor((year() - 1)/100))) + (int(floor((year() - 1)/400))) + day()
    return daystotal % 7
 
def week():
    return month() * 4 + day() % 7 
 
def cashUsed():
    w = week()
    d = dayOfWeek()
    daysElapsed = (w % 2) * 7 + d - 1 
    loss = 0
    for i in range(daysElapsed):
        loss += lossList[i%7] / 2
    return loss
 
def findBg():
    return map(255.0 * ((((week() % 2) * 7) + dayOfWeek()) / 14.0),255,0,0,255) \
             + map(hour()+8,24,0,0,18)
 
def printCash():
    textAlign(CENTER)
    cashLeft = "%f" % currentCash
    fill(100)
    textSize(width * .20)
    lost = nfs(totalLoss,3,2)
    text("$"+lost,width*.505, height*.71)
 
    fill(255,0,0)
    stroke(0)
 
    textSize(width * .20)
    lost = nfs(totalLoss,3,2)
    text("$"+lost,width*.5, height*.7)

Waves of light, over a light, reflected off a pool of water.

My personal clock utilized layered rectangles traveling across two bars at the top of the screen. As a minute goes by, the bars will meet in the middle and continue across the screen in a wave-like motion. The minutes of the hour are represented by a lighter rectangle that moves across each bar in a similar fashion. The hour is not specifically shown. However, the lamp will be displayed lighter in the daytime and darker as nighttime approaches.

 

2:54 PMScreen Shot 2014-10-01 at 2.54.09 PM

2:54 PMScreen Shot 2014-10-01 at 2.54.25 PM

5:42 PMScreen Shot 2014-10-01 at 5.42.17 PM

5:42 PMScreen Shot 2014-10-01 at 5.42.41 PM

 

//Will Taylor
//EMS clock
float tintR = 100;
float tintG = 100;
float tintB = 100;
 
void setup(){
PImage bg = loadImage("bridgeLight.jpg");
size(bg.width, bg.height);
drawClock();
frameRate(20);
smooth();
 
}
 
void draw(){
float s = second();
float m = minute();
float h = hour();
float sec = map(s,0,59, 0,width);
float sec2 = map(s,0,59, width,0);
float min = map(m,0,59, 0,width);
float min2 = map(m,0,59, width,0);
//drawClock();
 
float alphaS = 2;
float alphaM = 1;
//noStroke();
 
// MINUTES //
if (s%2 == 0) {
fill(#C2BCDB, alphaM);
} else {
fill(#FF05C5, alphaM);
}
 
rect(min, width/13 + 5, width/30, 50);
rect(min, width/23 + 5, width/30,50);
 
rect(min2, width/7 + 5, width/30, 50);
rect(min2, width/6 + 14, width/30,50);
 
// SECONDS //
if (s%2 == 0) {
fill(#FC08D4, alphaS);
} else {
fill(#08C9FC, alphaS);
}
 
if (s &gt;=30){
alphaS = 6;
println(alphaS);
}
float secX = 0; float secY = width/13;
rect(sec, width/13 + 5, width/30, 50);
rect(sec, width/23 + 5, width/30,50);
rect(sec2, width/13 + 5, width/30, 50);
rect(sec2, width/23 + 5, width/30,50);
 
if (s%2 == 0) {
fill(#08C9FC, alphaS);
} else {
fill(#FC08D4, alphaS);
}
rect(sec, width/7 + 5, width/30, 50);
rect(sec, width/6 + 14, width/30,50);
rect(sec2, width/7 + 5, width/30, 50);
rect(sec2, width/6 + 14, width/30,50);
 
if (second()== 0){
drawClock();
}
}
 
void drawClock() {
float h = hour();
float alpha = 40;
float hour = 24 - h;
float opacity = 0; //controls darkness of lamp
float hourAlpha = (255/24) * hour ;
if (hour() &lt; 12){ // gets brighter from midnight to noon
opacity = hourAlpha;
} else {
opacity = 255 - hourAlpha; // gets darker from noon to midnight
}
PImage bg = loadImage("bridgeLight.jpg");
float m = minute();
float min = map(m,0,59,0,width);
image(bg,0,0);
fill(0, opacity);
println(hour());
println(hour, "*");
println(hourAlpha);
rect(0,width/3, width, height);
fill(0, 150);
rect(0, width/23, width,100); //second bar
rect(0, width/7, width,100); //min bar
 
}

 

Written by Comments Off on Waves of light, over a light, reflected off a pool of water. Posted in Assignment-05-Clock

Clock: The Whoring Hours

approx 12am

A screen shot taken around midday.

The work day in Amsterdam’s Red Light District runs from about 7pm till 3am. This is a sped-up render of a visual clock representing that work period across the world. The image consists of 24 bars, that can be turning on, on or off. Each bar represents a time zone, and there is a small cross on the bar that shares the time zone of the clock (in this case the US east coast). It’s intended as a reminder of what is currently happening across the world, either near or far, and the stories of the people involved. This is a rendering of the change across time sped up:

code:

//The Whoring Hours. This might belong in a sports bar.
 
 
// function that handles the drawing of the light. Could be kept 
// within the bar class
void drawBar( int sx, int sy, int ex, int ey, float dx, 
              color lowC, color highC){
  int lr = int(red(lowC));
  int lg = int(green(lowC));
  int lb = int(blue(lowC));
  int dr = int(red(highC)) - lr;
  int dg = int(green(highC)) - lg;
  int db = int(blue(highC)) - lb;
  stroke(lr,lg,lb, int(100*dx));
  strokeWeight(40);
  line(sx,sy,ex,ey);
  stroke(lr + dr/3,lg + dg/3,lb + db/3, int(150*dx));
  strokeWeight(20);
  line(sx,sy,ex,ey);
  stroke(lr + int(dx*2*dr/3),lg + int(dx*2*dg/3),
         lb + int(dx*2*db/3),int(200*dx));
  strokeWeight(7);
  line(sx,sy,ex,ey);
  stroke(lr + int(dr*dx*dx),lg + int(dg*dx*dx),
         lb + int(db*dx*dx),int(255*dx*dx));
  strokeWeight(2);
  line(sx,sy,ex,ey);
  fill(0);
  noStroke();
  rect(sx-20,sy-40,40,40);
  rect(ex-20,ey,40,40);
              }
 
//class for each of the light bars that represent a time zone
class Light {
  String name;
  int diff;
  int sStart;
  int hStart;
  int sEnd;
  int hEnd;
  int x;
  int y;
  //int alpha;
  //int r;
  float dl;
 
  Light( String tempName, int tempDiff, int tempSS, int tempHS,
         int tempSE, int tempHE, int tempX, int tempY){
    name = tempName;
    diff = tempDiff;
    sStart = tempSS;
    hStart = tempHS;
    sEnd = tempSE;
    hEnd = tempHE;  
    x = tempX;
    y = tempY; 
    dl = 0.0;
  }
 
  //gets the relative brightness (dh) based on time of day and
  //time difference
  void update(int h, float dh){
    int nh = (h + diff) % 24;
    if ((nh &gt;= hEnd) &amp;&amp; (nh &lt; sStart)){
      dl = 0.0;
    }  
    else if (nh &gt;= hStart || nh &lt; sEnd){
      dl = 1.0;
    }
    else if (nh == sStart){
      dl = dh;
    }
    else {
      dl = 1-dh;
    }
  }
 
  void display(){
    drawBar( x,y,x,y+200, dl, color(255,0,0),color(255,255,255)); 
    textAlign(CENTER);
    fill(160,190,190);
    text(name,x,y+220);
  }
}
 
ArrayList&lt;Light&gt; lights;
 
void setup(){
  size(1200,300);
  lights = new ArrayList&lt;Light&gt;();
  for( int i = -4; i&lt;20; i ++){
    lights.add(new Light("", i, 19,20, 2,3, (i+5)*width/25,50));
  }
}
 
void draw(){
  int s = second();
  int m = minute();
  int h = hour();
  float dh = float(m)/60 + float(s)/(60*60);
  background(10);
  for (int i = lights.size()-1; i &gt;= 0; i--) {
    Light light = lights.get(i);
    light.update(h,dh);
    light.display();
  }
  fill(200,200,200);
  textAlign(LEFT);
  textSize(15);
  text("The Whoring Hours:",15,30);
  stroke(200,200,200);
  strokeWeight(1);
  line((5*width/25)-5,270,(5*width/25)+5,270);
  line((5*width/25),265,(5*width/25),275);
}