@@ -227,8 +227,9 @@ class SimpleVisualizer {
227227 initializeState ( signature , repoData ) {
228228 this . particles = [ ] ;
229229 const { commits } = repoData ;
230- const width = parseInt ( this . canvas . style . width ) ;
231- const height = parseInt ( this . canvas . style . height ) ;
230+ const dpr = window . devicePixelRatio || 1 ;
231+ const width = this . canvas . width / dpr ;
232+ const height = this . canvas . height / dpr ;
232233
233234 const activeCommits = ( commits || [ ] ) . slice ( 0 , 150 ) ;
234235 if ( activeCommits . length === 0 ) return ;
@@ -251,6 +252,11 @@ class SimpleVisualizer {
251252 activeCommits . forEach ( ( commit , i ) => {
252253 const p = this . mapCommitToParticle ( commit , i , activeCommits . length , width , height , timeRange ) ;
253254 if ( i === 0 ) console . log ( 'First particle:' , p ) ;
255+
256+ if ( isNaN ( p . x ) || isNaN ( p . y ) ) {
257+ console . error ( 'Invalid particle:' , p ) ;
258+ return ;
259+ }
254260 this . particles . push ( p ) ;
255261 } ) ;
256262
@@ -307,8 +313,9 @@ class SimpleVisualizer {
307313 }
308314
309315 clear ( signature ) {
310- const width = parseInt ( this . canvas . style . width ) ;
311- const height = parseInt ( this . canvas . style . height ) ;
316+ const dpr = window . devicePixelRatio || 1 ;
317+ const width = this . canvas . width / dpr ;
318+ const height = this . canvas . height / dpr ;
312319
313320 // Use a very dark background with slight tint
314321 this . ctx . fillStyle = `hsla(${ signature . primaryHue } , 30%, 5%, 0.2)` ; // Trail effect
@@ -320,8 +327,9 @@ class SimpleVisualizer {
320327
321328 drawVisualization ( signature , repoData ) {
322329 if ( Math . random ( ) < 0.01 ) console . log ( 'Drawing particles:' , this . particles . length ) ;
323- const width = parseInt ( this . canvas . style . width ) ;
324- const height = parseInt ( this . canvas . style . height ) ;
330+ const dpr = window . devicePixelRatio || 1 ;
331+ const width = this . canvas . width / dpr ;
332+ const height = this . canvas . height / dpr ;
325333
326334 this . ctx . globalCompositeOperation = 'screen' ; // Make things glowy and additive
327335
0 commit comments