@@ -45,6 +45,12 @@ export function escapeXML(str: string): string {
4545 . replace ( / " / g, '"' )
4646 . replace ( / ' / g, ''' ) ;
4747}
48+
49+ export function particleCount ( count : number ) : number {
50+ if ( count === 0 ) return 0 ;
51+ return Math . min ( 5 , Math . max ( 3 , Math . floor ( count / 4 ) ) ) ;
52+ }
53+
4854function generateParticles (
4955 x : number ,
5056 y : number ,
@@ -54,9 +60,9 @@ function generateParticles(
5460 sf : number
5561) : string {
5662 let particles = '' ;
57- const particleCount = Math . min ( 5 , Math . max ( 3 , Math . floor ( count / 4 ) ) ) ;
63+ const numParticles = particleCount ( count ) ;
5864
59- for ( let i = 0 ; i < particleCount ; i ++ ) {
65+ for ( let i = 0 ; i < numParticles ; i ++ ) {
6066 const seed = `${ x } :${ y } :${ height } :${ color } :${ count } :${ i } ` ;
6167 const offsetX = deterministicRandom ( `${ seed } :offsetX` ) * 6 - 3 ;
6268 const delay = deterministicRandom ( `${ seed } :delay` ) * 1.5 ;
@@ -79,9 +85,9 @@ function generateAutoParticles(
7985 sf : number
8086) : string {
8187 let particles = '' ;
82- const particleCount = Math . min ( 5 , Math . max ( 3 , Math . floor ( count / 4 ) ) ) ;
88+ const numParticles = particleCount ( count ) ;
8389
84- for ( let i = 0 ; i < particleCount ; i ++ ) {
90+ for ( let i = 0 ; i < numParticles ; i ++ ) {
8591 const seed = `${ x } :${ y } :${ height } :auto:${ count } :${ i } ` ;
8692 const offsetX = deterministicRandom ( `${ seed } :offsetX` ) * 6 - 3 ;
8793 const delay = deterministicRandom ( `${ seed } :delay` ) * 1.5 ;
0 commit comments