From 95fd952b6d4c496efc0e6236ba2acfcbbeee8ed9 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 12 Nov 2023 13:59:50 -0600 Subject: add visualization --- src/ui/canvas.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/ui/canvas.js (limited to 'src/ui/canvas.js') 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(); +} -- cgit v1.2.1