Last active
March 27, 2019 00:20
-
-
Save Introscopia/084a0de375fe7dd9e3b3748ee66203b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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