Thank you for your hints! :)
I found out that the frameRate and the CPU usage are directly corresponding (on my PC). When I choose 10 frames per second, the CPU usage is still at 100%. At 9 its 90%, at 8 its 80%, ... :D
I decided to leave 50% of the CPU to the watch so I have enough space left to work.
I think, that the problem with the letters which are cut off on the upper side, is a bug with 3D-mode. When I use 2D the ttf as well as the vwl fonts are looking normal.
Now I wrote a faster (and more beautiful ;) binary watch:
Code:
int windowHeight;
int windowWidth;
void setup()
{
windowHeight = 400;
windowWidth = 400;
size(windowWidth, windowHeight, P3D);
background(0);
lights();
frameRate(5);
// the text below
PFont myfont = createFont("SansSerif.bold", 20, true);
textFont(myfont);
int x = windowHeight-40;
fill(255);
text("Month", 30, x);
text("Day", 110, x);
text("Hour", 165, x);
text("Minute", 230, x);
text("Second", 310, x);
}
void draw ()
{
// get time
Calendar systime = Calendar.getInstance();
int[] systimeNumbers = {
systime.get(Calendar.MONTH) + 1,
systime.get(Calendar.DATE),
systime.get(Calendar.AM_PM) == Calendar.AM? systime.get(Calendar.HOUR) : systime.get(Calendar.HOUR)+12,
systime.get(Calendar.MINUTE),
systime.get(Calendar.SECOND)
};
// house lights down...
fill(0);
stroke(0);
rect(0, 0, windowWidth, windowHeight-80);
// stage lights on...
directionalLight(255,255,255, // Color (white)
0,0,-1); // direction along the x,y and z axis
lightSpecular(255,255,255);
// draw new time with bit shifting
int x = 60;
int x_offset = 70;
int y = 60;
int y_offset = 40;
noStroke();
for(int i=0; i<=4; i++)
{
int k = 5; // counts in the opposite direction of j
for(int j=0; j<=5; j++)
{
if(((systimeNumbers[i] >> j) & 1) == 1)
{
//fill(255, 0, 0, 255); // red
//fill(0, 255, 0, 255); // green
//fill(0, 0, 255, 255); // blue
fill(255, 255, 0, 255); // yellow
//fill((i+1) * 50, 0, (j+1) * 55, 255); // funny
}
else
{
fill(90,90,110, 200); // grey
}
translate(x + (x_offset*i), y + (y_offset*k));
sphere(18);
translate(-(x + (x_offset*i)), -(y + (y_offset*k)));
k--;
}
}
}