Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

Stop! Metric Time

27. Oktober 2011

This is a clock representing time in a metric format (10h:100m:100s). It uses the peasycam library, which can be found here. The date is still hardcoded, as it would be very complex to implement a metric calendar.
import peasy.test.*;
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;

import processing.opengl.*;
PeasyCam camera;
float a;
double cur;
double normCurSec;

void setup() {

PFont font;
font = loadFont("trade.vlw");
textFont(font, 10);

size(1000, 600, OPENGL);
fill(0, 153);
noStroke();
camera = new PeasyCam(this, 100, 50, 0, 100);
smooth();
}

void draw() {
background(20);

fill(#28C0E8, 240);
String clockStr = str(hour()) + ":" + str(minute()) + ":" + str(second()) /*+ ":" + str(millis())*/;

cur = (hour() * 60 * 60) + (minute() * 60) + second();
normCurSec = cur * 1.0 / 86400;

float stundeDec = float ( hour() ) / 24.0 * 100.0 ;
float minuteDec = float ( minute() ) / 60.0 * 100.0 ;
float sekundDec = float ( second() ) / 60.0 * 100.0 ;

String decimal = int(str(stundeDec + .5)) + ":" + int(str(minuteDec + .5)) + ":" + int(str(sekundDec + .5));
float progress = (float)normCurSec * 100.0;

noStroke();

//rect(0, 0, progress, 20);
rect(0, 30, stundeDec, 20);
rect(0, 60, minuteDec, 20);
rect(0, 90, sekundDec, 20);
rect(100, -100, 1, 210);

pushMatrix();
translate(100, -63, 0);
rotateY(-PI/2);
scale(5);
//box(sekundDec, 20, 20);
text("NEPTUNEDAY,", 0, 0);
text("81st OCTOBER", 0, 10);
popMatrix();

pushMatrix();
translate(0, -63, 0);
scale(5);
text("of",10,0);
rotateY(-PI/2);
scale(1.5);
//box(sekundDec, 20, 20);
text("IT IS " + nf((float)normCurSec* 100, 1, 3) + " %", -10, -5, -20);
popMatrix();

pushMatrix();
translate(0, -90, -650);
scale(5);
rotateX(PI/2);
rotateZ(PI/2);
text("WHAT TIME IT IS?");
popMatrix();

pushMatrix();
translate(0, 15, -50);
rotateY(-PI/2);
//text(nf((float)normCurSec* 100, 1, 3) + " %", 0, 0);
text("HOUR", 0, 30);
text("MINUTE", 0, 60);
text("SECOND", 0, 90);
popMatrix();
}
Download: MetricTime