Skip to content

Commit

Permalink
feat: calculate magnification depth based on width
Browse files Browse the repository at this point in the history
  • Loading branch information
istudyatuni committed May 13, 2022
1 parent 6b2b621 commit 9959f44
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/components/Canvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
drawStore.set('yc', coords.yc)
draw()
drawStore.set('depth', $drawStore.depth + 1)
}
onMount(init)
Expand Down
7 changes: 5 additions & 2 deletions src/components/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
</script>

<script>
// calculate how many times viewport was scaled by 2
// 4 is initial width between [-3, 1], rx - lx == total width of x axis
$: magnification_depth = Math.log2(4 / ($drawStore.rx - $drawStore.lx))
function toggleShow() {
settings.set('show_settings', !$settings.show_settings)
}
Expand All @@ -24,7 +28,6 @@
drawStore.set('lx', -3)
drawStore.set('rx', 1)
drawStore.set('yc', 0)
drawStore.set('depth', 0)
resetHash()
}
</script>
Expand Down Expand Up @@ -54,7 +57,7 @@
</div>

<div class="mb-2">
<p>Depth: {$drawStore.depth}</p>
<p>Magnification depth: {magnification_depth}</p>
</div>

<div class="flex mb-2">
Expand Down
1 change: 0 additions & 1 deletion src/stores/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const draw = sessionStore('draw-settings', {
lx: -3,
rx: 1,
yc: 0,
depth: 0,
})

export const settings = sessionStore('settings', {
Expand Down

0 comments on commit 9959f44

Please sign in to comment.