// clock // -- a simple digital clock // // Scott "Jerry" Lawrence // sdlpci@cis.rit.edu int colors = 0; void setup() { size( 185, 125 ); background( 0 ); } void loop() { if( colors == 0 ) { background( 0 ); }else{ background( 127 ); } number( 10, hour()/10 ); number( 40, hour()%10 ); number( 70, minute()/10 ); number( 100, minute()%10 ); number( 130, second()/10 ); number( 160, second()%10 ); // screengrab stuff /* if( keyPressed ) { if( key == 'G' ) saveFrame(); } */ } void mousePressed() { if( colors==0 ) { colors=1; } else { colors=0; } } void number( int x, int value) { if( colors == 0 ) stroke( 100, 0, 0 ); else stroke( 90, 90, 127 ); setFill( value & 0x08 ); ellipse( x, 10, 15, 15 ); setFill( value & 0x04 ); ellipse( x, 40, 15, 15 ); setFill( value & 0x02 ); ellipse( x, 70, 15, 15 ); setFill( value & 0x01 ); ellipse( x, 100, 15, 15 ); } void setFill( int bit ) { if( colors == 0 ) { if( bit == 0 ) { fill( 100, 0, 0 ); } else { fill( 255, 0, 0 ); } } else { if( bit == 0 ) { fill( 127, 127, 127 ); } else { fill( 0, 0, 255 ); } } }