@@ -135,20 +135,24 @@ window.onload = function () {
135135 ctx . fillRect ( 0 , 0 , c . width , c . height ) ;
136136
137137 for ( var i = 0 ; i < drops . length ; i ++ ) {
138+ var character = calculateCharacter ( drops [ i ] ) ;
139+ var doHighlight = drops [ i ] [ 1 ] > 0 ;
140+
138141 if ( highlight_first_character ) {
139142 ctx . fillStyle = "#000" ;
140143 ctx . fillRect ( i * font_size , ( ( drops [ i ] [ 0 ] - 2 ) * font_size ) + font_fraction , font_size , font_size ) ;
141144
142- ctx . fillStyle = calculateColor ( i , drops [ i ] [ 0 ] , drops [ i ] [ 1 ] ) ;
143- ctx . fillText ( drop_chars [ i ] , i * font_size , ( drops [ i ] [ 0 ] - 1 ) * font_size ) ;
145+ var tmp = drops [ i ] [ 0 ] - 1 ;
146+ ctx . fillStyle = calculateColor ( i , tmp , drop_chars [ i ] [ 1 ] ) ;
147+ ctx . fillText ( drop_chars [ i ] [ 0 ] , i * font_size , tmp * font_size ) ;
144148
145149 ctx . fillStyle = "#FFF" ;
146150 }
147151 else
148- ctx . fillStyle = calculateColor ( i , drops [ i ] [ 0 ] , drops [ i ] [ 1 ] ) ;
152+ ctx . fillStyle = calculateColor ( i , drops [ i ] [ 0 ] , doHighlight ) ;
149153
150- drop_chars [ i ] = calculateCharacter ( drops [ i ] ) ;
151- ctx . fillText ( drop_chars [ i ] , i * font_size , drops [ i ] [ 0 ] * font_size ) ;
154+ drop_chars [ i ] = [ character , doHighlight ] ;
155+ ctx . fillText ( character , i * font_size , drops [ i ] [ 0 ] * font_size ) ;
152156
153157 if ( drops [ i ] [ 0 ] > rows && Math . random ( ) > 0.975 )
154158 drops [ i ] = [ 0 , 0 , 0 ] ;
@@ -175,8 +179,8 @@ window.onload = function () {
175179 return letters [ Math . floor ( Math . random ( ) * letters . length ) ] ;
176180 }
177181
178- function calculateColor ( i , j , codeIndex ) {
179- if ( codeIndex != 0 )
182+ function calculateColor ( i , j , highLight ) {
183+ if ( highLight )
180184 return "#FFF" ;
181185
182186 var hue , offset = Math . floor ( color_animation_speed * then ) ;
@@ -224,8 +228,10 @@ window.onload = function () {
224228 function fallAnimation ( ) {
225229 drops = [ ] ;
226230 drop_chars = [ ] ;
227- for ( var x = 0 ; x < columns ; x ++ )
228- drops [ x ] = [ 1 , 0 , 0 ] ;
231+ for ( var i = 0 ; i < columns ; i ++ ) {
232+ drops [ i ] = [ 1 , 0 , 0 ] ;
233+ drop_chars [ i ] = [ "" , false ] ;
234+ }
229235 }
230236
231237 function loop ( ) {
0 commit comments