@@ -5,7 +5,6 @@ import { birthdayMode, cn, sleep } from "../../helpers/utils";
5
5
const UPDATE_DELAY = 500 as const
6
6
const UPDATE_FADE_OPACITY = 0.2 as const
7
7
const UPDATE_CHARACTERS = [ "@" , "#" , "/" , "\\" , "&" , "%" ] as const
8
- const UPDATE_BDAYMODE_COLORS = [ "white" , "red" , "blue" , "yellow" , "green" , "purple" , "orange" , "pink" ]
9
8
10
9
11
10
const FONT_NAME = "Roboto Mono" as const
@@ -23,6 +22,12 @@ const FONT_JUMP_SIZE = FONT_PX.actualBoundingBoxAscent + 10
23
22
const UPDATE_FADE_SIZE = FONT_JUMP_SIZE * ( Math . ceil ( 1 / UPDATE_FADE_OPACITY ) * 4 )
24
23
25
24
25
+ const randomColor = ( ) => {
26
+ const hue = Math . floor ( Math . random ( ) * 360 ) ;
27
+ const lightness = Math . floor ( Math . random ( ) * 21 ) + 40 ;
28
+ return `hsl(${ hue } , 100%, ${ lightness } %)` ;
29
+ }
30
+
26
31
type BMAddToMatrixOptions = {
27
32
/** Position of the element. Random by default */
28
33
x ?: number ,
@@ -78,7 +83,7 @@ class BackgroundManager {
78
83
const x = o ?. x ?? Math . floor ( Math . random ( ) * this . target . width )
79
84
return x - x % FONT_PX . width
80
85
} ) ( )
81
- const fillStyle = o ?. style ?? birthdayMode ? UPDATE_BDAYMODE_COLORS [ Math . floor ( Math . random ( ) * UPDATE_BDAYMODE_COLORS . length ) ] : "white"
86
+ const fillStyle = birthdayMode ? randomColor ( ) : ( o ?. style ?? "white" )
82
87
83
88
for ( let y = 0 ; y < this . target . height + UPDATE_FADE_SIZE ; y += FONT_JUMP_SIZE ) {
84
89
if ( x > this . target . width ) break ; // Resized - disable if outside of area
0 commit comments