From c5e7f9bea8dbe3c140ac285a4a5a6ab8ca9aa5a2 Mon Sep 17 00:00:00 2001 From: Minater247 Date: Sat, 16 Jan 2021 03:17:59 -0800 Subject: [PATCH 1/6] Validate number inputs --- index.html | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index 5a4be3f..731161b 100644 --- a/index.html +++ b/index.html @@ -285,7 +285,7 @@
@@ -371,16 +371,20 @@

Select the Dimensions Of the grid

} else if (tools[Tool.circle]) { var centre = new Point(x, y); var radius = +prompt("radius?"); - var lp = circle(radius, centre); - var p; - for (p of lp) this.draw(p.x, p.y); + if (radius > 0 && Number.isInteger(radius)) { + var lp = circle(radius, centre); + var p; + for (p of lp) this.draw(p.x, p.y); + } } else if (tools[Tool.ellipse]) { var center = new Point(x, y); var radiusX = +prompt("X radius?"); var radiusY = +prompt("Y radius?"); - var lp = ellipse(radiusX, radiusY, center); - for (p of lp) - this.draw(p.x, p.y); + if (radiusX > 0 && radiusY > 0 && Number.isInteger(radiusX) && Number.isInteger(radiusY)) { + var lp = ellipse(radiusX, radiusY, center); + for (p of lp) + this.draw(p.x, p.y); + } } else { this.draw(x, y); } @@ -675,15 +679,17 @@

Select the Dimensions Of the grid

document.querySelector("#close").onclick = function () { var width = +document.querySelector("#width").value; var height = +document.querySelector("#height").value; - window.board = new Canvas(width, height); - window.board.setcolor([0, 0, 0, 255]); - window.dim.close(); - window.gif = new GIF({ - workers: 2, - quality: 10, - width: 10 * window.board.width, - height: 10 * window.board.height - }); + if (width > 0 && height > 0 && Number.isInteger(width) && Number.isInteger(height)) { + window.board = new Canvas(width, height); + window.board.setcolor([0, 0, 0, 255]); + window.dim.close(); + window.gif = new GIF({ + workers: 2, + quality: 10, + width: 10 * window.board.width, + height: 10 * window.board.height + }); + } window.gif.on('finished', function (blob) { var url = URL.createObjectURL(blob); var link = document.createElement('a'); From 57af5f7df04a3cf6ca2064791b341966160a845e Mon Sep 17 00:00:00 2001 From: Minater247 Date: Sat, 16 Jan 2021 03:24:34 -0800 Subject: [PATCH 2/6] Changed frames to deal with undefined board --- index.html | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 731161b..1a49ea1 100644 --- a/index.html +++ b/index.html @@ -601,21 +601,23 @@

Select the Dimensions Of the grid

document.querySelector("#frames").style.transform = "translate(-50%,-50%) scale(1,1)"; document.querySelector("#frames").focus(); document.querySelector("#frames #gallery").innerHTML=""; - for (var frame of board.frames) document.querySelector("#frames #gallery").appendChild(frame[0]); - document.querySelectorAll("#frames #gallery img").forEach((x,i) => { - x.onclick = (e) => { - board.loadFrame(i); - Frames.close(); - }; - x.oncontextmenu = (e) => { - e.preventDefault(); - var del_confirmation = confirm("Delete?"); - if (del_confirmation) { - board.deleteFrame(i); - Frames.open(); - } - }; - }); + if (typeof board !== 'undefined') { + for (var frame of board.frames) document.querySelector("#frames #gallery").appendChild(frame[0]); + document.querySelectorAll("#frames #gallery img").forEach((x,i) => { + x.onclick = (e) => { + board.loadFrame(i); + Frames.close(); + }; + x.oncontextmenu = (e) => { + e.preventDefault(); + var del_confirmation = confirm("Delete?"); + if (del_confirmation) { + board.deleteFrame(i); + Frames.open(); + } + }; + }); + } } static close() { document.querySelector("#frames").style.transform = "translate(-50%,-50%) scale(0,0)"; From 73defaa0c2adba41b06c9e5d42fc22f614f4f402 Mon Sep 17 00:00:00 2001 From: Minater247 Date: Sat, 16 Jan 2021 03:29:49 -0800 Subject: [PATCH 3/6] Attpt stop board switcher appearing when no boards --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 1a49ea1..a1cde25 100644 --- a/index.html +++ b/index.html @@ -597,11 +597,11 @@

Select the Dimensions Of the grid

class Frames { static open() { - document.querySelector("#frames").style.display = "block"; - document.querySelector("#frames").style.transform = "translate(-50%,-50%) scale(1,1)"; - document.querySelector("#frames").focus(); - document.querySelector("#frames #gallery").innerHTML=""; if (typeof board !== 'undefined') { + document.querySelector("#frames").style.display = "block"; + document.querySelector("#frames").style.transform = "translate(-50%,-50%) scale(1,1)"; + document.querySelector("#frames").focus(); + document.querySelector("#frames #gallery").innerHTML=""; for (var frame of board.frames) document.querySelector("#frames #gallery").appendChild(frame[0]); document.querySelectorAll("#frames #gallery img").forEach((x,i) => { x.onclick = (e) => { From 7274f57e2cebb9f0236b05de310e98b19fa8f834 Mon Sep 17 00:00:00 2001 From: Minater247 Date: Sat, 16 Jan 2021 03:41:53 -0800 Subject: [PATCH 4/6] Comment out PWA install since its prompt is empty --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index a1cde25..b2c426a 100644 --- a/index.html +++ b/index.html @@ -777,7 +777,7 @@

Select the Dimensions Of the grid

}); function install() { - msg.prompt(); + //msg.prompt(); } window.onerror = function (errorMsg, url, lineNumber) { From 1f770a9cc5ed0e7414c51575ff279cea776004e1 Mon Sep 17 00:00:00 2001 From: Minater247 Date: Sat, 16 Jan 2021 03:49:51 -0800 Subject: [PATCH 5/6] Ensure board is defined when saving --- index.html | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index b2c426a..88b2d08 100644 --- a/index.html +++ b/index.html @@ -278,8 +278,8 @@ @@ -705,6 +705,18 @@

Select the Dimensions Of the grid

document.querySelector(".menu").style.display = document.querySelector(".menu").style.display != "block" ? "block" : "none"; } +function saveCurrentBoard() { + if (typeof board !== 'undefined') { + board.save() + } +} + +function saveGifBoard() { + if (typeof board !== 'undefined') { + board.renderGIF() + } +} + function newProject(){ document.querySelector(".menu").style.display = "none"; localStorage.removeItem('pc-canvas-data'); From a89132cb01252370758e2a2d6de00a8a9623c0cf Mon Sep 17 00:00:00 2001 From: Minater247 Date: Sun, 17 Jan 2021 20:44:28 -0800 Subject: [PATCH 6/6] Add gif.abort call before rendering gif --- index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 88b2d08..fc0dcb0 100644 --- a/index.html +++ b/index.html @@ -507,7 +507,8 @@

Select the Dimensions Of the grid

copy: true, delay: 100 }); - }); + }); + gif.abort() gif.render(); }