diff --git a/wasm-build/demo.html b/wasm-build/demo.html
index d31b004..fd28e4f 100644
--- a/wasm-build/demo.html
+++ b/wasm-build/demo.html
@@ -23,6 +23,7 @@
canvas {
border: 2px solid #ddd; border-radius: 4px; display: block;
margin: 0 auto; cursor: crosshair; touch-action: none;
+ width: 100%; height: auto; aspect-ratio: 4 / 3;
}
.controls {
width: 280px; background: white; border-radius: 8px; padding: 20px;
@@ -74,23 +75,6 @@
-
-
-
-
How to use Dasher:
-
1. Move your mouse over the canvas to steer — the letters zoom toward you
-
2. The crosshair (vertical line) is where text gets entered — move up/down to choose letters
-
3. Move further right to dash faster; move left to slow down / reverse
-
4. Typed text appears in the output box below
-
-
-
-
Loading DasherCore WebAssembly...
-
-
@@ -153,8 +137,8 @@
Output Text
let lastFpsTime = performance.now();
function updateStatus(message, type) {
- statusText.textContent = message;
- statusContainer.className = 'status ' + (type || 'loading');
+ if (statusText) statusText.textContent = message;
+ if (statusContainer) statusContainer.className = 'status ' + (type || 'loading');
}
function enableControls() {
@@ -348,6 +332,25 @@ Output Text
ctx.textAlign = 'center';
ctx.fillText('Loading DasherCore...', canvas.width / 2, canvas.height / 2);
+ // Responsive canvas: sync resolution to display size
+ function resizeCanvas() {
+ const rect = canvas.getBoundingClientRect();
+ const w = Math.round(rect.width);
+ const h = Math.round(rect.height);
+ if (w > 0 && h > 0 && (w !== canvas.width || h !== canvas.height)) {
+ canvas.width = w;
+ canvas.height = h;
+ if (dasher && isRunning) {
+ dasher.setScreenSize(w, h);
+ }
+ }
+ }
+
+ window.addEventListener('resize', resizeCanvas);
+ const resizeObserver = new ResizeObserver(resizeCanvas);
+ resizeObserver.observe(canvas);
+ resizeCanvas();
+
window.addEventListener('beforeunload', () => {
if (dasher) dasher.destroy();
});