From 19fdad91533f60038f43cb998d10d3baf210eec0 Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Fri, 16 Jul 2021 16:42:52 -0700 Subject: [PATCH] Convert client to use img Removing the tiling feature allowed me to switch the client to use img instead of canvas. --- client/index.html | 2 +- client/js/main.js | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/client/index.html b/client/index.html index 956f7db..8800a8e 100644 --- a/client/index.html +++ b/client/index.html @@ -18,7 +18,7 @@ diff --git a/client/js/main.js b/client/js/main.js index b56cf60..87fd188 100644 --- a/client/js/main.js +++ b/client/js/main.js @@ -28,15 +28,8 @@ function setup() { ws.send('pass ' + localStorage.getItem('password')) setInterval(function(){ws.send('ack')}, 3000) } else if ( type == 'pic' ) { - pos = e.data.split('%')[1] - x = Number(pos.split('x')[0]) - y = Number(pos.split('x')[1]) data = e.data.split('%')[2] - img = new Image() - img.src = data - img.addEventListener("load", function(){ - ctx.drawImage(img,x,y) - }) + canvas.src = data errorbox.style.display = 'none' canvas.style.display = 'block' } else if ( type == 'err' ) { @@ -100,7 +93,7 @@ function connect(e) { } -let canvas = document.querySelector('canvas') +let canvas = document.querySelector('#canvas') let errorbox = document.querySelector('#errorbox') let login = document.querySelector('#login') @@ -113,8 +106,6 @@ let start_button = document.querySelector('#start') let is_short = true let click_timeout -let ctx = canvas.getContext("2d") - let displayWidth, displayHeight let ws