summaryrefslogtreecommitdiff
path: root/src/ui/canvas.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/canvas.js')
-rw-r--r--src/ui/canvas.js11
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();
+}