@@ -29,28 +29,33 @@ export default function ParticleBackground() {
2929
3030 const createParticles = ( ) => {
3131 const particles : Particle [ ] = [ ] ;
32- const particleCount = Math . min ( 50 , Math . floor ( globalThis . innerWidth / 20 ) ) ;
33-
32+ const particleCount = Math . min (
33+ 50 ,
34+ Math . floor ( globalThis . innerWidth / 20 ) ,
35+ ) ;
36+
3437 // Get theme colors from CSS custom properties
3538 const getThemeColor = ( colorName : string ) => {
36- return getComputedStyle ( document . documentElement ) . getPropertyValue ( `--color-${ colorName } ` ) . trim ( ) ;
39+ return getComputedStyle ( document . documentElement ) . getPropertyValue (
40+ `--color-${ colorName } ` ,
41+ ) . trim ( ) ;
3742 } ;
38-
43+
3944 const colors = [
4045 getThemeColor ( "teal" ) ,
41- getThemeColor ( "blue" ) ,
46+ getThemeColor ( "blue" ) ,
4247 getThemeColor ( "green" ) ,
4348 getThemeColor ( "yellow" ) ,
4449 getThemeColor ( "mauve" ) ,
4550 getThemeColor ( "sky" ) ,
46- getThemeColor ( "lavender" )
47- ] . filter ( color => color ) ; // Filter out any empty colors
48-
51+ getThemeColor ( "lavender" ) ,
52+ ] . filter ( ( color ) => color ) ; // Filter out any empty colors
53+
4954 // Fallback colors if theme colors aren't available (more theme-appropriate)
5055 if ( colors . length === 0 ) {
5156 colors . push ( "#45b7d1" , "#4ecdc4" , "#96c93d" , "#f39c12" , "#8839ef" ) ;
5257 }
53-
58+
5459 for ( let i = 0 ; i < particleCount ; i ++ ) {
5560 particles . push ( {
5661 x : Math . random ( ) * canvas . width ,
@@ -62,39 +67,39 @@ export default function ParticleBackground() {
6267 color : colors [ Math . floor ( Math . random ( ) * colors . length ) ] ,
6368 } ) ;
6469 }
65-
70+
6671 particlesRef . current = particles ;
6772 } ;
6873
6974 const animate = ( ) => {
7075 ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
71-
76+
7277 particlesRef . current . forEach ( ( particle , index ) => {
7378 // Update position
7479 particle . x += particle . vx ;
7580 particle . y += particle . vy ;
76-
81+
7782 // Wrap around edges
7883 if ( particle . x < 0 ) particle . x = canvas . width ;
7984 if ( particle . x > canvas . width ) particle . x = 0 ;
8085 if ( particle . y < 0 ) particle . y = canvas . height ;
8186 if ( particle . y > canvas . height ) particle . y = 0 ;
82-
87+
8388 // Draw particle
8489 ctx . beginPath ( ) ;
8590 ctx . arc ( particle . x , particle . y , particle . size , 0 , Math . PI * 2 ) ;
8691 ctx . fillStyle = particle . color ;
8792 ctx . globalAlpha = particle . opacity ;
8893 ctx . fill ( ) ;
89-
94+
9095 // Draw connections to nearby particles
9196 particlesRef . current . forEach ( ( otherParticle , otherIndex ) => {
9297 if ( index === otherIndex ) return ;
93-
98+
9499 const dx = particle . x - otherParticle . x ;
95100 const dy = particle . y - otherParticle . y ;
96101 const distance = Math . sqrt ( dx * dx + dy * dy ) ;
97-
102+
98103 if ( distance < 100 ) {
99104 ctx . beginPath ( ) ;
100105 ctx . moveTo ( particle . x , particle . y ) ;
@@ -106,7 +111,7 @@ export default function ParticleBackground() {
106111 }
107112 } ) ;
108113 } ) ;
109-
114+
110115 ctx . globalAlpha = 1 ;
111116 animationIdRef . current = requestAnimationFrame ( animate ) ;
112117 } ;
@@ -134,7 +139,7 @@ export default function ParticleBackground() {
134139 < canvas
135140 ref = { canvasRef }
136141 class = "fixed inset-0 pointer-events-none z-0"
137- style = { {
142+ style = { {
138143 background : "transparent" ,
139144 opacity : 0.6 ,
140145 } }
0 commit comments