From 3fb1b2b46977fbebf84524ee0eb5a4eeadc1cede Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 31 Dec 2016 13:55:35 -0700 Subject: [PATCH] Better keys --- index.html | 10 ++++++---- scripts/dotgrid.js | 10 +++------- scripts/keyboard.js | 7 ++++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index 3b2c66e..3f71a52 100644 --- a/index.html +++ b/index.html @@ -10,11 +10,13 @@
-      aA ARC CLOCKWISE
-      sS ARC COUNTERWISE
+      q  CLEAR
+      w  DELETE LAST
+      e  EXPORT
+
+      aA CLOCKWISE
+      sS COUNTERWISE
       d  LINE
-      f  CLEAR
-      g  DELETE LAST
     
diff --git a/scripts/dotgrid.js b/scripts/dotgrid.js index 14451d3..63dd1cd 100644 --- a/scripts/dotgrid.js +++ b/scripts/dotgrid.js @@ -131,7 +131,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) if(from === null || to === null){ return; } var s = document.createElementNS("http://www.w3.org/2000/svg", "path"); - s.setAttribute("d","M"+(-from[0])+","+(from[1])+" A"+this.grid_width+","+this.grid_height+" 0 "+orientation+" "+(-to[0])+","+(to[1])+""); + s.setAttribute("d","M"+(-from[0])+","+(from[1])+" A"+(to[0] - from[0])+","+(to[1] - from[1])+" 0 "+orientation+" "+(-to[0])+","+(to[1])+""); s.setAttribute('stroke', "#000000"); s.setAttribute('stroke-width', "3"); s.setAttribute('fill', "none"); @@ -158,11 +158,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.erase = function() { - erase(); - } - - function erase() - { + if(vector_element.lastChild === null){ return; } vector_element.removeChild(vector_element.lastChild); } @@ -184,6 +180,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) { x = parseInt(x/this.grid_width) * this.grid_width - (this.grid_width/2); y = parseInt(y/this.grid_height) * this.grid_height + (this.grid_height/2); - return [x,y]; + return [parseInt(x),parseInt(y)]; } } \ No newline at end of file diff --git a/scripts/keyboard.js b/scripts/keyboard.js index eb758ca..115bcb0 100644 --- a/scripts/keyboard.js +++ b/scripts/keyboard.js @@ -7,9 +7,10 @@ function Keyboard() case 65 : dotgrid.draw_arc(event.shiftKey ? "1,1" : "0,1"); break; case 83 : dotgrid.draw_arc(event.shiftKey ? "1,0" : "0,0"); break; case 68 : dotgrid.draw_line(); break; - case 70 : dotgrid.reset(); break; - case 71 : dotgrid.erase(); break; - case 81 : dotgrid.export(); break; + + case 81 : dotgrid.reset(); break; + case 87 : dotgrid.erase(); break; + case 80 : dotgrid.export(); break; } } }