// Joshua // // A simple vector font routine and a "War Games"-like interface thingy. // // left-click on the screen to increase the number of characters in the code it got // right-click to decrease byte fixed[] = { 'C', 'P', 'E', '1', '7', '0', '4', 'T', 'K', 'S' }; /* the launch code */ int thresh[] = { 4, 8, 6, 7, 2, 5, 3, 0, 9, 1 }; /* the order that Joshua gets the numbers */ int clickLevel = 0; void setup() { size( 600, 400 ); //size( screen.width, screen.height ); // use this for "fullscreen".. shift-command-r to "present" it fullscreen frameRate( 15 ); smooth(); } int c=0; int blinkCounter=0; void draw() { background( 0 ); noFill(); glowbox( 20, 20, width-40, height-40 ); byte display[] = new byte[10]; if( clickLevel <= thresh[0] ) display[0] = (byte)random( 'a', 'z' ); else display[0] = fixed[0]; if( clickLevel <= thresh[1] ) display[1] = (byte)random( 'a', 'z' ); else display[1] = fixed[1]; if( clickLevel <= thresh[2] ) display[2] = (byte)random( 'a', 'z' ); else display[2] = fixed[2]; if( clickLevel <= thresh[3] ) display[3] = (byte)random( '0', '9' ); else display[3] = fixed[3]; if( clickLevel <= thresh[4] ) display[4] = (byte)random( '0', '9' ); else display[4] = fixed[4]; if( clickLevel <= thresh[5] ) display[5] = (byte)random( '0', '9' ); else display[5] = fixed[5]; if( clickLevel <= thresh[6] ) display[6] = (byte)random( '0', '9' ); else display[6] = fixed[6]; if( clickLevel <= thresh[7] ) display[7] = (byte)random( 'a', 'z' ); else display[7] = fixed[7]; if( clickLevel <= thresh[8] ) display[8] = (byte)random( 'a', 'z' ); else display[8] = fixed[8]; if( clickLevel <= thresh[9] ) display[9] = (byte)random( 'a', 'z' ); else display[9] = fixed[9]; String code = new String( display ); if( clickLevel >= 10 ) /* after it got all 10 numbers... */ { blinkCounter++; if( blinkCounter > 10 ) /* on for 10 frames */ { if( blinkCounter > 15 ) /* off for 15-10 frames */ blinkCounter = 0; return; } } /* draw out the code, first big, transparent...*/ float sf = (width/10)/7; strokeWeight( 6 ); stroke( 200, 255, 255, 128 ); vectorText( code, int((width - sf*5.9*10)/2), int((height - sf*8)/2), 0, sf ); /* then smaller, opaque */ strokeWeight( 2 ); stroke( 200, 255, 255 ); vectorText( code, int((width - sf*5.9*10)/2), int((height - sf*8)/2), 0, sf ); } /* draw the outer glowing border */ void glowbox( int x, int y, int w, int h ) { int stk = 4; noFill(); for( int i=4 ; i>0 ; i-- ) { stroke( 255/i ); strokeWeight( 4*i ); rect( x, y, w, h ); } } void mousePressed() { if( mouseButton == LEFT ) clickLevel++; if( mouseButton == RIGHT ) clickLevel--; clickLevel = constrain( clickLevel, 0, 10 ); } /* print a vector string */ void vectorText( String s, int x, int y, int kern, float sc ) { pushMatrix(); translate( x, y ); for( int i=0 ; i