summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
authorRaymaekers Luca <luca@spacehb.net>2025-07-12 16:13:16 +0200
committerRaymaekers Luca <luca@spacehb.net>2025-07-12 16:13:16 +0200
commit4ea5261f32ec8acd4cdad7c364f57e6ebc86866a (patch)
tree4902a807134e971dc0601083b7f110f527cf429a /index.html
checkpoint
Diffstat (limited to 'index.html')
-rw-r--r--index.html42
1 files changed, 42 insertions, 0 deletions
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..d2ab090
--- /dev/null
+++ b/index.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script type="module">
+ async function init() {
+ const { instance } = await WebAssembly.instantiateStreaming(
+ fetch("./graphics.wasm")
+ );
+
+ const width = 600;
+ const height = 600;
+ const bytes_per_pixel = 4;
+
+ const canvas = document.getElementById("graphics-canvas");
+ canvas.width = width;
+ canvas.height = height;
+
+ const buffer_address = instance.exports.BUFFER.value;
+ const image = new ImageData(
+ new Uint8ClampedArray(
+ instance.exports.memory.buffer,
+ buffer_address,
+ bytes_per_pixel * width * height,
+ ),
+ width,
+ height,
+ );
+
+ const ctx = canvas.getContext("2d");
+
+ instance.exports.go(buffer_address, width, height);
+
+ ctx.putImageData(image, 0, 0);
+ }
+
+ init();
+ </script>
+ </head>
+ <body>
+ <canvas id="graphics-canvas"></canvas>
+ </body>
+</html>