diff options
author | sanine <sanine.not@pm.me> | 2023-11-12 13:59:50 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-11-12 13:59:50 -0600 |
commit | 95fd952b6d4c496efc0e6236ba2acfcbbeee8ed9 (patch) | |
tree | 2fd28076f9fe119481dcb439865b4076d00fc692 /src/ui/canvas.js | |
parent | 22fe18beac4459427c2b40499afafc7c5c868691 (diff) |
add visualization
Diffstat (limited to 'src/ui/canvas.js')
-rw-r--r-- | src/ui/canvas.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ui/canvas.js b/src/ui/canvas.js new file mode 100644 index 0000000..b04b966 --- /dev/null +++ b/src/ui/canvas.js @@ -0,0 +1,11 @@ +'use strict'; + +export function draw(canvas, size, fn) { + const ctx = canvas.getContext("2d"); + const scale = canvas.clientWidth/size; + ctx.save(); + ctx.scale(scale, scale); + ctx.clearRect(0, 0, size, size); + fn(ctx); + ctx.restore(); +} |