Skip to content

Instantly share code, notes, and snippets.

@Introscopia
Last active March 27, 2019 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Introscopia/084a0de375fe7dd9e3b3748ee66203b0 to your computer and use it in GitHub Desktop.
Save Introscopia/084a0de375fe7dd9e3b3748ee66203b0 to your computer and use it in GitHub Desktop.
/*
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