Ejemplo: visualizando el tiempo

IMG_7724IMG_7725IMG_7726IMG_7727reloj

int dia, mes, ani, horas, minutos, segundos;
PFont mifont;
String textomes;

void setup() {
size(500, 500, P3D);
mifont=loadFont("SansSerif-48.vlw");
textFont(mifont, 18);
}

void draw() {
background(255);
dia = day();
mes = month();
ani = year();
horas = hour();
minutos = minute();
segundos = second();
fill(0);
if(mes == 3) {
textomes = "Marzo";
}
text(horas+":"+minutos+":"+segundos+" "+dia+"/"+textomes+"/"+ani, 0, 20);

// dibujar el segundero
pushMatrix();
translate(width/2, height/2);
stroke(255, 0, 0);
strokeWeight(1);
rotateZ((segundos-15)*PI/30);
line(0, 0, 180, 0);
popMatrix();

// dibujar el minutero
pushMatrix();
translate(width/2, height/2);
stroke(0, 255, 0);
strokeWeight(3);
rotateZ((minutos-15)*PI/30);
line(0, 0, 170, 0);
popMatrix();

// dibujar el horario
pushMatrix();
translate(width/2, height/2);
stroke(0, 0, 255);
strokeWeight(5);
rotateZ((horas-3)*PI/6);
line(0, 0, 150, 0);
popMatrix();

//dibujar los números
pushMatrix();
translate(width/2, height/2);
rotateZ(-PI/2);
for(int i = 0; i<60; i = i+1) {
pushMatrix();
rotateZ(i*PI/30);
fill(0);
text(i,200, 0);
popMatrix();
}
popMatrix();
}