From 32eea268559a1360cc00fcd5b180e74104e0c395 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 6 Apr 2024 19:45:26 +0200 Subject: Performance --- worker.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 worker.js (limited to 'worker.js') diff --git a/worker.js b/worker.js new file mode 100644 index 0000000..f89a699 --- /dev/null +++ b/worker.js @@ -0,0 +1,14 @@ +let canvas, screen; + +self.onmessage = (msg) => { + if (msg.data == "clear") { + screen.clearRect(0, 0, canvas.width, canvas.height); + } else if ("canvas" in msg.data) { + canvas = msg.data.canvas; + screen = canvas.getContext("2d"); + } else { + [color, x, y, width, height] = msg.data; + screen.fillStyle = color; + screen.fillRect(x, y, width, height); + } +}; -- cgit v1.2.3