diff --git a/sources/media/icons/mirror.svg b/sources/media/icons/mirror.svg
new file mode 100644
index 0000000..30cc4f9
--- /dev/null
+++ b/sources/media/icons/mirror.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js
index dc4e31c..167863f 100644
--- a/sources/scripts/dotgrid.js
+++ b/sources/scripts/dotgrid.js
@@ -26,6 +26,9 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
var end = null;
this.svg_el = null;
+ this.mirror_el = null;
+
+ this.mirror = false;
this.path = document.createElementNS("http://www.w3.org/2000/svg", "path");
this.segments = [];
@@ -70,6 +73,9 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
cursor_end.id = "cursor_end";
this.element.appendChild(cursor_end);
+ this.mirror_el = document.createElementNS("http://www.w3.org/2000/svg", "g");
+ this.mirror_path = document.createElementNS("http://www.w3.org/2000/svg", "path");
+
// Vector
this.svg_el = document.createElementNS("http://www.w3.org/2000/svg", "svg");
this.svg_el.setAttribute("class","vector");
@@ -85,8 +91,10 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
this.svg_el.style.fill = "none";
this.svg_el.style.strokeLinecap = this.linecap;
this.element.appendChild(this.svg_el);
-
- this.svg_el.appendChild(this.path);
+
+ this.svg_el.appendChild(this.path);
+ this.svg_el.appendChild(this.mirror_el);
+ this.mirror_el.appendChild(this.mirror_path);
this.draw();
}
@@ -104,6 +112,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
if(o == "arc_r"){ this.draw_arc("0,0"); }
if(o == "bezier"){ this.draw_bezier(); }
if(o == "close"){ this.draw_close(); }
+ if(o == "mirror"){ this.mirror = this.mirror == true ? false : true; this.draw(); }
if(o == "export"){ this.export(); }
}
@@ -210,6 +219,9 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
this.svg_el.style.strokeLinecap = this.linecap;
this.svg_el.style.strokeWidth = this.thickness;
+ this.mirror_path.setAttribute("d",this.mirror ? d : '');
+ this.mirror_path.setAttribute("transform","translate(300,0),scale(-1,1)")
+
this.update_interface();
}
@@ -327,6 +339,13 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
html += "
";
}
+ if(this.segments.length > 0 && !this.mirror){
+ html += "
";
+ }
+ else{
+ html += "
";
+ }
+
if(this.segments.length > 0){
html += "
";
}
diff --git a/sources/scripts/keyboard.js b/sources/scripts/keyboard.js
index 8b6baae..95df952 100644
--- a/sources/scripts/keyboard.js
+++ b/sources/scripts/keyboard.js
@@ -2,7 +2,11 @@ function Keyboard()
{
this.listen = function(event)
{
- console.log(event.keyCode)
+ // save
+ if(event.key == "s" && (event.ctrlKey || event.metaKey)){
+ dotgrid.export();
+ return;
+ }
switch (event.keyCode) {
case 83 : dotgrid.draw_arc(event.shiftKey ? "1,1" : "0,1"); break;