From de1ae672a03a862f221cc4530d9527e44d7577d7 Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 8 Apr 2024 23:14:33 +0300 Subject: proto: possible fix but dunno maybe it doesn't work --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index b987340..64c460a 100644 --- a/index.js +++ b/index.js @@ -59,6 +59,7 @@ canvas.addEventListener('mousedown', (e) => { client.on('message', function (topic, message) { let val = message.toString(); var n = parseInt(val); + update(); if (!isNaN(n)){ if (n < 150){ drawings.push({x: (n - 30) * Math.sin(tr.a)/canvas.width, y: ((n - 30) * Math.cos(tr.a))/canvas.height, tr: {x: tr.x, y: tr.y}}) // add a wall @@ -69,7 +70,6 @@ client.on('message', function (topic, message) { tr.x -= (n - 30) * Math.sin(tr.a) tr.y -= (n - 30) * Math.cos(tr.a) } - update(); } }); /* canvas.addEventListener('touchstart', (e) => { @@ -108,6 +108,7 @@ function resizeCanvas() { ctx.fillStyle = "red"; robot.style.top = canvas.height/2 - robot.height/2 - canvasOffsetY; robot.style.left = canvas.width/2 - robot.width/2 - canvasOffsetX; + ctx.setTransform(1, 0, 0, 1, 0, 0); } function redrawCanvas(){ @@ -125,7 +126,6 @@ function redrawCanvas(){ function update(){ resizeCanvas(); - ctx.setTransform(1,0,0,1,0,0); redrawCanvas(); } -- cgit v1.2.3