From 6b1c6e1a6735998f5bbf1c7f4f2ef72fcdf05583 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Mon, 23 Dec 2024 01:25:03 +0100
Subject: Add configuration and debugging
---
canvasWorker.js | 17 ++++++++++++++++-
index.html | 42 +++++++++++++++++++++++++++++++++++++++++-
main.js | 8 +++++++-
3 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/canvasWorker.js b/canvasWorker.js
index 51878f6..ab97236 100644
--- a/canvasWorker.js
+++ b/canvasWorker.js
@@ -76,13 +76,28 @@ let useWebGL = true;
let draw;
self.onmessage = (msg) => {
- if (msg.data == "clear") {
+ if ("clear" in msg.data) {
if (useWebGL) {
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
} else {
gl.clearRect(0, 0, canvas.width, canvas.height);
}
+ } else if ("resize" in msg.data) {
+ const { width, height } = msg.data.resize;
+ canvas.width = width;
+ canvas.height = height;
+ gl.canvas.width = width;
+ gl.canvas.height = height;
+
+ if (useWebGL) {
+ gl.viewport(0, 0, canvas.width, canvas.height);
+ gl.clearColor(0, 0, 0, 0);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ draw = initGL();
+ } else {
+ gl.clearRect(0, 0, canvas.width, canvas.height);
+ }
} else if ("canvas" in msg.data) {
canvas = msg.data.canvas;
useWebGL = msg.data.useWebGL;
diff --git a/index.html b/index.html
index 9e519c9..d46fbef 100644
--- a/index.html
+++ b/index.html
@@ -263,6 +263,28 @@ map = \\(0 \\\\\(0 (6 4) (6 3) (6 2) (6 1)))
>
+
+ Configuration
+
+ Warning: Larger resolutions will often need exponentially more
+ memory/computation!)
+
+
+ Debug information:
+
+