11window . onload = function ( ) {
2+ //MARK: Update
23 const version = "v4.3.0" ;
34
45 checkForUpdates = async ( ) => {
@@ -12,13 +13,7 @@ window.onload = function () {
1213 return await fetch ( 'project.json' ) . then ( _ => _ . json ( ) ) ;
1314 }
1415
15- function optionsToDict ( options ) {
16- return options . reduce ( ( acc , option ) => {
17- acc [ option . label ] = option . value ;
18- return acc ;
19- } , { } ) ;
20- }
21-
16+ //MARK: Options
2217 var gui ;
2318 var options = {
2419 ui_rain_matrixSpeed : 24 ,
@@ -85,6 +80,7 @@ window.onload = function () {
8580 else
8681 drawGui ( ) ;
8782
83+ //MARK: GUI
8884 function drawGui ( ) {
8985 readProjectConfig ( ) . then ( ( config ) => {
9086 gui = new lil . GUI ( { autoPlace : false , width : 300 } ) ;
@@ -97,7 +93,7 @@ window.onload = function () {
9793 options . trailLength = calculateTrailLength ( options . ui_rain_trailLength ) ;
9894 updateMask ( ) ;
9995 } ) ;
100- rainFolder . add ( options , "ui_rain_initialAnimation" , optionsToDict ( config . general . properties . ui_rain_initialanimation . options ) ) . name ( "Initial Animation" ) . onChange ( fallAnimation ) ;
96+ rainFolder . add ( options , "ui_rain_initialAnimation" , optionsToDict ( config . general . properties . ui_rain_initialanimation . options ) ) . name ( "Initial Animation" ) . onChange ( initialAnimation ) ;
10197
10298 const colorFolder = gui . addFolder ( "Color" ) ;
10399 colorFolder . add ( options , 'ui_color_colorMode' , optionsToDict ( config . general . properties . ui_color_colormode . options ) ) . name ( 'Color Mode' ) ;
@@ -155,7 +151,7 @@ window.onload = function () {
155151 const otherFolder = gui . addFolder ( "Other" ) ;
156152 otherFolder . add ( options , 'ui_other_codesCommaSeparated' ) . name ( 'Codes (Comma separated)' ) . onChange ( ( ) => {
157153 options . codes = makeCodes ( options . ui_other_codesCommaSeparated ) ;
158- fallAnimation ( ) ;
154+ initialAnimation ( ) ;
159155 } ) ;
160156
161157 gui . add ( options , "Save" ) ;
@@ -169,6 +165,7 @@ window.onload = function () {
169165 } ) ;
170166 }
171167
168+ //MARK: Wallpaper Engine
172169 window . wallpaperPropertyListener = {
173170 applyUserProperties : function ( properties ) {
174171 if ( properties . ui_rain_matrixspeed )
@@ -179,7 +176,7 @@ window.onload = function () {
179176 }
180177 if ( properties . ui_rain_initialanimation ) {
181178 options . ui_rain_initialAnimation = properties . ui_rain_initialanimation . value ;
182- fallAnimation ( ) ;
179+ initialAnimation ( ) ;
183180 }
184181
185182 if ( properties . ui_color_colormode )
@@ -265,7 +262,7 @@ window.onload = function () {
265262
266263 if ( properties . ui_other_codescommaseparated ) {
267264 options . codes = makeCodes ( properties . ui_other_codescommaseparated . value ) ;
268- fallAnimation ( ) ;
265+ initialAnimation ( ) ;
269266 }
270267 }
271268 } ;
@@ -275,15 +272,10 @@ window.onload = function () {
275272 updateMask ( ) ;
276273 updateFont ( ) ;
277274 updateGrid ( ) ;
278- fallAnimation ( ) ;
275+ initialAnimation ( ) ;
279276 } , false ) ;
280277
281- setInterval ( ( ) => {
282- updateTime ( ) ;
283- if ( options . ui_clock_clock != "0" )
284- updateMask ( ) ;
285- } , 60000 ) ;
286-
278+ //MARK: Variables
287279 var fonts = [ "monospace" , "consolas" , "courier-bold" , "neo-matrix" ] ;
288280 var charsets = [
289281 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ,
@@ -297,7 +289,7 @@ window.onload = function () {
297289 var logo = null , logos = [ "ipaf" , "kali-1" , "kali-2" , "ubuntu-1" , "ubuntu-2" , "windows-11" , "windows-10-8" , "windows-7" , "visual-studio" , "vs-code" , "unity-1" , "unity-2" , "unreal" , "python" , "blazor" , "docker" , "flutter" , "git" , "blender" , "angular" , "c-sharp" , "c-plus-plus" , "qt" ] ;
298290 var debug = document . getElementById ( "debug" ) , logs = [ ] ;
299291 var hour = "" , minute = "" ;
300- var startTime , now , then , elapsed , letters , columns , rows , drops , drop_chars ;
292+ var startTime , now , then , elapsed , letters , columns , rows , drops ;
301293 var AudioTimeout = false , LastSoundTime = new Date ( ) , isSilent = false , frequencyArray , frequencyArrayLength = 128 , column_frequency ;
302294 var column_hue , row_hue ;
303295 var font_fraction ;
@@ -323,6 +315,7 @@ window.onload = function () {
323315 colorOverlayDom . width = window . innerWidth ;
324316 }
325317
318+ //MARK: Logo
326319 function updateLogo ( ) {
327320 logo = new Image ( ) ;
328321 logo . onload = updateMask ;
@@ -343,6 +336,13 @@ window.onload = function () {
343336 }
344337 }
345338
339+ //MARK: Time
340+ setInterval ( ( ) => {
341+ updateTime ( ) ;
342+ if ( options . ui_clock_clock != "0" )
343+ updateMask ( ) ;
344+ } , 60000 ) ;
345+
346346 function updateTime ( ) {
347347 let today = new Date ( ) ;
348348 hour = today . getHours ( ) ;
@@ -365,6 +365,7 @@ window.onload = function () {
365365 minute = "0" + minute ;
366366 }
367367
368+ //MARK: Mask
368369 function updateMask ( ) {
369370 mask . globalCompositeOperation = 'source-over' ;
370371 mask . clearRect ( 0 , 0 , neoMatrixDom . width , neoMatrixDom . height ) ;
@@ -425,6 +426,7 @@ window.onload = function () {
425426 }
426427 }
427428
429+ //MARK: Charset
428430 function updateCharSet ( ) {
429431 if ( options . ui_characters_charset == "0" )
430432 letters = options . ui_characters_customCharset ;
@@ -434,6 +436,7 @@ window.onload = function () {
434436 letters = letters . split ( "" ) ;
435437 }
436438
439+ //MARK: Font
437440 function updateFont ( ) {
438441 var font_name ;
439442
@@ -447,9 +450,10 @@ window.onload = function () {
447450
448451 updateGrid ( ) ;
449452 updateMask ( ) ;
450- fallAnimation ( ) ;
453+ initialAnimation ( ) ;
451454 }
452455
456+ //MARK: Grid
453457 function updateGrid ( ) {
454458 columns = neoMatrixDom . width / options . ui_font_size ;
455459 rows = neoMatrixDom . height / options . ui_font_size ;
@@ -458,30 +462,24 @@ window.onload = function () {
458462 column_frequency = frequencyArrayLength / ( columns * 2 ) ;
459463 }
460464
461- function fallAnimation ( ) {
465+ //MARK: Initial Animation
466+ function initialAnimation ( ) {
462467 drops = [ ] ;
463- drop_chars = [ ] ;
464468
465469 switch ( options . ui_rain_initialAnimation ) {
466470 case "0" : {
467- for ( var i = 0 ; i < columns ; i ++ ) {
468- drops [ i ] = [ rows + 1 , 0 , 0 ] ;
469- drop_chars [ i ] = [ "" , false ] ;
470- }
471+ for ( var i = 0 ; i < columns ; i ++ )
472+ drops [ i ] = [ rows + 1 , 0 , 0 , "" , 0 ] ;
471473 break ;
472474 }
473475 case "1" : {
474- for ( var i = 0 ; i < columns ; i ++ ) {
475- drops [ i ] = [ 1 , 0 , 0 ] ;
476- drop_chars [ i ] = [ "" , false ] ;
477- }
476+ for ( var i = 0 ; i < columns ; i ++ )
477+ drops [ i ] = [ 1 , 0 , 0 , "" , 0 ] ;
478478 break ;
479479 }
480480 case "2" : {
481- for ( var i = 0 ; i < columns ; i ++ ) {
482- drops [ i ] = [ Math . floor ( Math . random ( ) * rows ) , 0 , 0 ] ;
483- drop_chars [ i ] = [ "" , false ] ;
484- }
481+ for ( var i = 0 ; i < columns ; i ++ )
482+ drops [ i ] = [ Math . floor ( Math . random ( ) * rows ) , 0 , 0 , "" , 0 ] ;
485483 break ;
486484 }
487485 }
@@ -504,6 +502,7 @@ window.onload = function () {
504502 }
505503 }
506504
505+ //MARK: Draw Matrix
507506 function drawMatrix ( ) {
508507 drawMask ( ) ;
509508 isSilent = true ;
@@ -533,20 +532,20 @@ window.onload = function () {
533532 neoMatrix . clearRect ( i * options . ui_font_size , ( ( drops [ i ] [ 0 ] - 2 ) * options . ui_font_size ) + font_fraction , options . ui_font_size , options . ui_font_size ) ;
534533
535534 var tmp = drops [ i ] [ 0 ] - 1 ;
536- neoMatrix . fillStyle = calculateColor ( i , tmp , drop_chars [ i ] [ 1 ] ) ;
537- neoMatrix . fillText ( drop_chars [ i ] [ 0 ] , i * options . ui_font_size , tmp * options . ui_font_size ) ;
535+ neoMatrix . fillStyle = calculateColor ( i , tmp , drops [ i ] [ 4 ] ) ;
536+ neoMatrix . fillText ( drops [ i ] [ 3 ] , i * options . ui_font_size , tmp * options . ui_font_size ) ;
538537
539538 neoMatrix . fillStyle = "#FFF" ;
540539 }
541540 else
542541 neoMatrix . fillStyle = calculateColor ( i , drops [ i ] [ 0 ] , lightness ) ;
543542
544543 neoMatrix . clearRect ( i * options . ui_font_size , ( ( drops [ i ] [ 0 ] - 1 ) * options . ui_font_size ) + font_fraction , options . ui_font_size , options . ui_font_size ) ;
545- drop_chars [ i ] = [ character , lightness ] ;
544+ drops [ i ] [ 3 ] = character , drops [ i ] [ 4 ] = lightness ;
546545 neoMatrix . fillText ( character , i * options . ui_font_size , drops [ i ] [ 0 ] * options . ui_font_size ) ;
547546
548547 if ( drops [ i ] [ 0 ] > rows && Math . random ( ) > probability )
549- drops [ i ] = [ 0 , 0 , 0 ] ;
548+ drops [ i ] = [ 0 , 0 , 0 , "" , 0 ] ;
550549
551550 drops [ i ] [ 0 ] ++ ;
552551 }
@@ -561,6 +560,7 @@ window.onload = function () {
561560 }
562561 }
563562
563+ //MARK: Calculate Character
564564 function calculateCharacter ( dropItem ) {
565565
566566 if ( Math . random ( ) > 0.995 && dropItem [ 1 ] == 0 ) {
@@ -579,6 +579,7 @@ window.onload = function () {
579579 return letters [ Math . floor ( Math . random ( ) * letters . length ) ] ;
580580 }
581581
582+ //MARK: Calculate Color
582583 function calculateColor ( i , j , lightness ) {
583584 var hue , offset = Math . floor ( options . colorAnimationSpeed * then ) ;
584585
@@ -626,6 +627,7 @@ window.onload = function () {
626627 return codes ;
627628 }
628629
630+ //MARK: Helpers
629631 function Log ( text ) {
630632 debug . classList . remove ( "hide" ) ;
631633 void debug . offsetWidth ;
@@ -680,5 +682,12 @@ window.onload = function () {
680682 return max ;
681683 return value ;
682684 }
685+
686+ function optionsToDict ( options ) {
687+ return options . reduce ( ( acc , option ) => {
688+ acc [ option . label ] = option . value ;
689+ return acc ;
690+ } , { } ) ;
691+ }
683692} ;
684693
0 commit comments