Skip to content

Commit

Permalink
better sparkline sizing across screen ratios/sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacbowen committed Mar 4, 2024
1 parent a5ca87d commit 0048710
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@

#sparkline-canvas {
position: absolute;
right: 20px;
bottom: 20px;
width: 300px;
height: 100px;
right: 1vw;
bottom: 1vw;
opacity: 0.5;
}
</style>
Expand Down
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class SphereWithRods {
this.camera.aspect = window.innerWidth / window.innerHeight;
this.camera.updateProjectionMatrix();
this.renderer.setSize(window.innerWidth, window.innerHeight);
this.sparklineCanvas.width = Math.min(window.innerWidth, window.innerHeight) * 0.5;
this.sparklineCanvas.height = this.sparklineCanvas.width * 0.3;
}

constructSphere(): void {
Expand All @@ -68,6 +70,8 @@ class SphereWithRods {
constructSparkline(): void {
this.sparklineCanvas = document.getElementById('sparkline-canvas') as HTMLCanvasElement;
this.sparklineContext = this.sparklineCanvas.getContext('2d')!;
this.sparklineCanvas.width = Math.min(window.innerWidth, window.innerHeight) * 0.5;
this.sparklineCanvas.height = this.sparklineCanvas.width * 0.3;
this.startTime = Date.now();
this.drawSparkline();
}
Expand Down

0 comments on commit 0048710

Please sign in to comment.