diff --git a/scripts/modules/file.save.js b/scripts/modules/file.save.js
index f4faa63..f261995 100644
--- a/scripts/modules/file.save.js
+++ b/scripts/modules/file.save.js
@@ -19,19 +19,18 @@ function FileSave(rune)
{
var d = null;
+ var w = window.open('about:blank','image from canvas');
+
if(cmd.variable("format") && cmd.variable("format").value == "svg"){
- // TODO
- return;
+ w.document.write("
Untitled"+ronin.vector.create_svg()+"");
}
else if(cmd.variable("format") && cmd.variable("format").value == "jpg"){
- var d = this.merge().element.toDataURL('image/jpeg');
+ w.document.write("Untitled
");
}
else{
- var d = this.merge().element.toDataURL('image/png');
+ w.document.write("Untitled
");
}
- var w = window.open('about:blank','image from canvas');
- w.document.write("Untitled
");
this.layer.clear();
}
diff --git a/scripts/modules/vector.js b/scripts/modules/vector.js
index 8849321..e550dcb 100644
--- a/scripts/modules/vector.js
+++ b/scripts/modules/vector.js
@@ -8,6 +8,7 @@ function Vector(rune)
this.layer = null;
this.coordinates = [];
this.last_pos = null;
+ this.paths = [];
this.install = function()
{
@@ -21,22 +22,51 @@ function Vector(rune)
this.passive = function(cmd)
{
this.layer.clear();
- this.layer.context().lineCap = cmd.variable("line_cap") ? cmd.variable("line_cap").value : "round";
- this.layer.context().lineWidth = cmd.variable("stroke_width") ? cmd.variable("stroke_width").value : 5;
+ this.layer.context().lineCap = cmd.variable("line_cap") ? cmd.variable("line_cap").value : "square";
+ this.layer.context().lineWidth = cmd.variable("stroke_width") ? cmd.variable("stroke_width").value : 10;
this.layer.context().strokeStyle = cmd.variable("stroke_color") ? cmd.variable("stroke_color").value : "#ffffff";
this.layer.context().stroke(new Path2D(cmd.content.join(" ")));
}
this.active = function(cmd)
{
+ this.paths.push(this.create_path());
this.coordinates = [];
this.layer.clear();
- ronin.surface.active_layer.context().lineCap = cmd.variable("line_cap") ? cmd.variable("line_cap").value : "round";
- ronin.surface.active_layer.context().lineWidth = cmd.variable("stroke_width") ? cmd.variable("stroke_width").value : 5;
+ ronin.surface.active_layer.context().lineCap = cmd.variable("line_cap") ? cmd.variable("line_cap").value : "square";
+ ronin.surface.active_layer.context().lineWidth = cmd.variable("stroke_width") ? cmd.variable("stroke_width").value : 10;
ronin.surface.active_layer.context().strokeStyle = cmd.variable("stroke_color") ? cmd.variable("stroke_color").value : "#ffffff";
ronin.surface.active_layer.context().stroke(new Path2D(cmd.content.join(" ")));
}
+ // Tools
+
+
+ this.create_path = function()
+ {
+ var command = "";
+
+ for (var i = 0; i < this.coordinates.length; i++) {
+ command += this.coordinates[i]+" ";
+ }
+ return command;
+ }
+
+ this.create_svg = function()
+ {
+ var s = "";
+
+ s += "";
+ console.log(s);
+ return s;
+ }
+
// Mouse
this.click = null;
@@ -57,21 +87,11 @@ function Vector(rune)
}
}
- this.create_command = function()
- {
- var command = "+ ";
-
- for (var i = 0; i < this.coordinates.length; i++) {
- command += this.coordinates[i]+" ";
- }
- return command;
- }
-
this.mouse_down = function(position)
{
this.click = true;
- commander.element_input.value = this.create_command();
+ commander.element_input.value = "+ "+this.create_path();
commander.hint.update();
this.passive(commander.cmd());
}
@@ -79,7 +99,7 @@ function Vector(rune)
this.mouse_move = function(position)
{
if(!this.click){ return; }
- commander.element_input.value = this.create_command();
+ commander.element_input.value = "+ "+this.create_path();
commander.element_input.value += "L"+position.render();
commander.hint.update();
this.passive(commander.cmd());
@@ -93,7 +113,7 @@ function Vector(rune)
this.coordinates.push("M"+position.render());
}
else{
-
+
var offset = this.last_pos ? position.offset(this.last_pos) : position;
if(keyboard.shift_held == true && keyboard.alt_held == true){
@@ -110,7 +130,7 @@ function Vector(rune)
}
}
- commander.element_input.value = this.create_command();
+ commander.element_input.value = "+ "+this.create_path();
commander.hint.update();
this.passive(commander.cmd());
this.last_pos = position;