Skip to content

Commit

Permalink
scale the sparkline a bit better
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacbowen committed Mar 4, 2024
1 parent 0048710 commit 84cd0e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 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.

5 changes: 3 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class SphereWithRods {

drawSparkline(): void {
this.sparklineContext.clearRect(0, 0, this.sparklineCanvas.width, this.sparklineCanvas.height);
this.sparklineContext.strokeStyle = 'white';
this.sparklineContext.lineWidth = Math.ceil(Math.min(window.innerWidth, window.innerHeight) / 1000) * 2;

this.sparklineContext.beginPath();
for (let x = 10; x <= this.sparklineCanvas.width - 10; x++) {
const t = (x - 10) / (this.sparklineCanvas.width - 20); // Adjust to ensure t starts from 0
Expand All @@ -104,8 +107,6 @@ class SphereWithRods {
this.sparklineContext.beginPath();
this.sparklineContext.moveTo(lineX, 0);
this.sparklineContext.lineTo(lineX, this.sparklineCanvas.height);
this.sparklineContext.strokeStyle = 'white';
this.sparklineContext.lineWidth = 2;
this.sparklineContext.stroke();

requestAnimationFrame(this.drawSparkline.bind(this));
Expand Down

0 comments on commit 84cd0e0

Please sign in to comment.