From 7e098564ce3eadfa419952702d1504b255f028bc Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 4 Jan 2017 10:48:08 -0700 Subject: [PATCH] Added shapes --- scripts/dotgrid.js | 23 ++++++++++++++++++++ scripts/keyboard.js | 3 +++ index.html => template.icon.html | 12 +++++++++-- template.interface.html | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) rename index.html => template.icon.html (51%) create mode 100644 template.interface.html diff --git a/scripts/dotgrid.js b/scripts/dotgrid.js index 565c93a..1884f85 100644 --- a/scripts/dotgrid.js +++ b/scripts/dotgrid.js @@ -146,6 +146,29 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca reset(); } + this.draw_dot = function() + { + var s = document.createElementNS("http://www.w3.org/2000/svg", "circle"); + s.setAttribute("cx",-from[0]); + s.setAttribute("cy",from[1]); + s.setAttribute("r","2"); + s.setAttribute("fill","black"); + vector_element.appendChild(s); + + reset(); + } + + this.draw_circle = function() + { + var s = document.createElementNS("http://www.w3.org/2000/svg", "circle"); + s.setAttribute("cx",-from[0]); + s.setAttribute("cy",from[1]); + s.setAttribute("r",(from[0] - to[0])); + vector_element.appendChild(s); + + reset(); + } + this.reset = function() { reset(); diff --git a/scripts/keyboard.js b/scripts/keyboard.js index 115bcb0..e0b5336 100644 --- a/scripts/keyboard.js +++ b/scripts/keyboard.js @@ -11,6 +11,9 @@ function Keyboard() case 81 : dotgrid.reset(); break; case 87 : dotgrid.erase(); break; case 80 : dotgrid.export(); break; + + case 90 : dotgrid.draw_dot(); break; + case 88 : dotgrid.draw_circle(); break; } } } diff --git a/index.html b/template.icon.html similarity index 51% rename from index.html rename to template.icon.html index 3f71a52..a12a77d 100644 --- a/index.html +++ b/template.icon.html @@ -6,7 +6,7 @@ - Dotgrid + Dotgrid(Interface)
@@ -18,6 +18,14 @@
       sS COUNTERWISE
       d  LINE
     
- + diff --git a/template.interface.html b/template.interface.html new file mode 100644 index 0000000..8fa0943 --- /dev/null +++ b/template.interface.html @@ -0,0 +1,36 @@ + + + + + + + + + Dotgrid(Interface) + + +
+      q  CLEAR
+      w  DELETE LAST
+      e  EXPORT
+
+      aA CLOCKWISE
+      sS COUNTERWISE
+      d  LINE
+
+
+      z  DOT
+      x  CIRCLE
+      c  --
+    
+ + +