diff --git a/sources/media/icons/close.svg b/sources/media/icons/close.svg index 882d391..a152521 100644 --- a/sources/media/icons/close.svg +++ b/sources/media/icons/close.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index 0a2a88e..dc4e31c 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -103,6 +103,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca if(o == "arc_c"){ this.draw_arc("0,1"); } if(o == "arc_r"){ this.draw_arc("0,0"); } if(o == "bezier"){ this.draw_bezier(); } + if(o == "close"){ this.draw_close(); } if(o == "export"){ this.export(); } } @@ -248,6 +249,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.draw_close = function() { if(this.segments.length == 0){ return; } + if(this.segments[this.segments.length-1].name == "close"){ return; } this.segments.push(new Path_Close()); @@ -255,45 +257,6 @@ 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"); - this.svg_el.appendChild(s); - - reset(); - } - - this.draw_circle = function() - { - if(from === null || to === null){ return; } - - 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])); - this.svg_el.appendChild(s); - - reset(); - } - - this.draw_rect = function() - { - if(from === null || to === null){ return; } - - var s = document.createElementNS("http://www.w3.org/2000/svg", "rect"); - s.setAttribute("x",-from[0]); - s.setAttribute("y",from[1]); - s.setAttribute("width",Math.abs(to[0]) - Math.abs(from[0])); - s.setAttribute("height",Math.abs(to[1]) - Math.abs(from[1])); - this.svg_el.appendChild(s); - - reset(); - } - this.reset = function() { reset(); @@ -357,6 +320,13 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca html += ""; } + if(this.segments.length > 0 && this.segments[this.segments.length-1].name != "close"){ + html += ""; + } + else{ + html += ""; + } + if(this.segments.length > 0){ html += ""; } diff --git a/sources/scripts/keyboard.js b/sources/scripts/keyboard.js index a4b28f2..8b6baae 100644 --- a/sources/scripts/keyboard.js +++ b/sources/scripts/keyboard.js @@ -3,6 +3,7 @@ function Keyboard() this.listen = function(event) { console.log(event.keyCode) + switch (event.keyCode) { case 83 : dotgrid.draw_arc(event.shiftKey ? "1,1" : "0,1"); break; case 65 : dotgrid.draw_arc(event.shiftKey ? "1,0" : "0,0"); break; @@ -19,10 +20,6 @@ function Keyboard() case 8 : dotgrid.erase(); break; case 69 : dotgrid.export(); break; - case 90 : dotgrid.draw_dot(); break; - case 88 : dotgrid.draw_circle(); break; - case 67 : dotgrid.draw_rect(); break; - case 38 : dotgrid.mod_move(0,-1); break; case 40 : dotgrid.mod_move(0,1); break; case 37 : dotgrid.mod_move(1,0); break; diff --git a/sources/scripts/path_arc.js b/sources/scripts/path_arc.js index ee3d71b..b1818c3 100644 --- a/sources/scripts/path_arc.js +++ b/sources/scripts/path_arc.js @@ -1,5 +1,7 @@ function Path_Arc(from,to,orientation,end) { + this.name = "arc"; + this.from = from; this.to = to; this.orientation = orientation; diff --git a/sources/scripts/path_bezier.js b/sources/scripts/path_bezier.js index e070884..6612bef 100644 --- a/sources/scripts/path_bezier.js +++ b/sources/scripts/path_bezier.js @@ -1,5 +1,7 @@ function Path_Bezier(from,to,end) { + this.name = "bezier"; + this.from = from; this.to = to; this.end = end; diff --git a/sources/scripts/path_close.js b/sources/scripts/path_close.js index 078c79c..33e6ceb 100644 --- a/sources/scripts/path_close.js +++ b/sources/scripts/path_close.js @@ -1,5 +1,7 @@ function Path_Close() { + this.name = "close"; + this.to_segment = function(prev) { return "Z "; diff --git a/sources/scripts/path_line.js b/sources/scripts/path_line.js index 3bddef7..7353711 100644 --- a/sources/scripts/path_line.js +++ b/sources/scripts/path_line.js @@ -1,5 +1,7 @@ function Path_Line(from,to,end = null) { + this.name = "line"; + this.from = from; this.to = to; this.end = end;