diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2024-04-08 23:14:33 +0300 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2024-04-08 23:14:33 +0300 |
| commit | de1ae672a03a862f221cc4530d9527e44d7577d7 (patch) | |
| tree | 71e89fd3c34a4d3d31c1bcbf54c0a6aaff43d44e | |
| parent | 2ff40aa50b3cf65b880ff0940c148e484f0a2802 (diff) | |
proto: possible fix but dunno maybe it doesn't work
| -rw-r--r-- | index.js | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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(); } |
