aboutsummaryrefslogtreecommitdiffhomepage
path: root/worker.js
diff options
context:
space:
mode:
authorMarvin Borner2024-04-06 19:45:26 +0200
committerMarvin Borner2024-04-06 19:45:26 +0200
commit32eea268559a1360cc00fcd5b180e74104e0c395 (patch)
treec646e5d76066616369adcde59acf98e682f57bd8 /worker.js
parentcf46c0fae36b2c242aa924303e1d39f068381273 (diff)
Performance
Diffstat (limited to 'worker.js')
-rw-r--r--worker.js14
1 files changed, 14 insertions, 0 deletions
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);
+ }
+};