Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
Simple Binary Clock in Processing.
Relogio Binario simples em Processing.
*/
float tx, ty, dx, dy;
void setup() {
size(400, 350);
tx = width / 9f;
ty = height / 3f;
dx = width / 9f;
dy = height / 6f;
noStroke();
}
void draw() {
background(0);
for( int y = 0; y < 3; ++y ){
String s = "";
switch( y ){
case 0 :
s = binary( hour(), 8 );
break;
case 1:
s = binary( minute(), 8 );
break;
case 2:
s = binary( second(), 8 );
break;
}
for( int x = 0; x < 8; ++x ){
if( s.charAt( x ) == '1' ) fill(#4DFF4E);
else fill( 50 );
ellipse( tx + (x*dx), ty + (y*dy), 30, 30 );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.