@@ -72,7 +72,9 @@ function alphaForStar(star: Star, age: number): number {
7272// Picks a realistic star color: mostly whitish, some blueish (hot stars like
7373// Sirius/Rigel), some reddish (cool stars like Betelgeuse/Antares).
7474function pickStarPalette ( ) : { hue : number ; sat : number } {
75- const r = Math . random ( ) ;
75+ // Cosmetic randomness only (star color), not security-sensitive.
76+ const r = Math . random ( ) ; // NOSONAR
77+
7678 if ( r < 0.15 ) {
7779 return { hue : randomBetween ( 0 , 25 ) , sat : randomBetween ( 75 , 95 ) } ; // reddish
7880 }
@@ -82,8 +84,21 @@ function pickStarPalette(): { hue: number; sat: number } {
8284 return { hue : randomBetween ( 40 , 60 ) , sat : randomBetween ( 5 , 20 ) } ; // whitish/neutral (majority)
8385}
8486
87+ // Quick fade-in, then fade-out towards the end of the meteor's trajectory.
88+ function meteorAlpha ( lifeRatio : number ) : number {
89+ if ( lifeRatio < 0.15 ) {
90+ return lifeRatio / 0.15 ;
91+ }
92+ if ( lifeRatio > 0.7 ) {
93+ return Math . max ( 0 , 1 - ( lifeRatio - 0.7 ) / 0.3 ) ;
94+ }
95+ return 1 ;
96+ }
97+
8598function pickStarShape ( ) : StarShape {
86- const r = Math . random ( ) ;
99+ // Cosmetic randomness only (star shape), not security-sensitive.
100+ const r = Math . random ( ) ; // NOSONAR
101+
87102 if ( r < CONFIG . starShapeChance . x ) return 'x' ;
88103 if ( r < CONFIG . starShapeChance . x + CONFIG . starShapeChance . plus ) return 'plus' ;
89104 return 'circle' ;
@@ -159,7 +174,8 @@ class StarfieldScreensaver {
159174 // Meteor flies diagonally from top to bottom, sometimes coming from
160175 // the left, sometimes from the right.
161176 const angle = randomBetween ( 20 , 50 ) * ( Math . PI / 180 ) ;
162- const dir = Math . random ( ) < 0.5 ? 1 : - 1 ;
177+ // Cosmetic randomness only (meteor direction), not security-sensitive.
178+ const dir = Math . random ( ) < 0.5 ? 1 : - 1 ; // NOSONAR
163179 const speed = randomBetween ( CONFIG . meteor . speedMinPxPerMs , CONFIG . meteor . speedMaxPxPerMs ) ;
164180 const startX = dir === 1
165181 ? randomBetween ( - 100 , this . width * 0.4 )
@@ -260,10 +276,7 @@ class StarfieldScreensaver {
260276 continue ;
261277 }
262278
263- // Quick fade-in, then fade-out towards the end of the trajectory.
264- const alpha = lifeRatio < 0.15
265- ? lifeRatio / 0.15
266- : ( lifeRatio > 0.7 ? Math . max ( 0 , 1 - ( lifeRatio - 0.7 ) / 0.3 ) : 1 ) ;
279+ const alpha = meteorAlpha ( lifeRatio ) ;
267280
268281 const angle = Math . atan2 ( meteor . vy , meteor . vx ) ;
269282 const tailX = meteor . x - Math . cos ( angle ) * meteor . length ;
0 commit comments