First draft for the new vector tool
This commit is contained in:
@@ -3,7 +3,7 @@ function Vector(rune)
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Any];
|
||||
this.variables = {"fill_color" : "none","stroke_width" : 2,"stroke_color" : "#ffffff", "line_cap" : "square"};
|
||||
this.variables = {"fill_color" : "none","stroke_width" : 5,"stroke_color" : "#ffffff", "line_cap" : "square"};
|
||||
|
||||
this.layer = null;
|
||||
|
||||
@@ -20,7 +20,7 @@ function Vector(rune)
|
||||
{
|
||||
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 : ronin.brush.size;
|
||||
this.layer.context().lineWidth = cmd.variable("stroke_width") ? cmd.variable("stroke_width").value : 5;
|
||||
this.layer.context().strokeStyle = cmd.variable("stroke_color") ? cmd.variable("stroke_color").value : "#ffffff";
|
||||
this.layer.context().stroke(new Path2D(cmd.content.join(" ")));
|
||||
}
|
||||
@@ -29,7 +29,7 @@ function Vector(rune)
|
||||
{
|
||||
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 : ronin.brush.size;
|
||||
ronin.surface.active_layer.context().lineWidth = cmd.variable("stroke_width") ? cmd.variable("stroke_width").value : 5;
|
||||
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(" ")));
|
||||
}
|
||||
@@ -40,17 +40,34 @@ function Vector(rune)
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "Vector";
|
||||
if(keyboard.shift_held == true){
|
||||
return "Vector(Counterclock Arc)";
|
||||
}
|
||||
else if(keyboard.alt_held == true){
|
||||
return "Vector(Clockwise Arc)";
|
||||
}
|
||||
else{
|
||||
return "Vector(Line)";
|
||||
}
|
||||
}
|
||||
|
||||
this.memory = null;
|
||||
this.coordinates = [];
|
||||
|
||||
this.create_command = function()
|
||||
{
|
||||
var command = "+ ";
|
||||
|
||||
for (var i = 0; i < this.coordinates.length; i++) {
|
||||
command += i == 0 ? "M"+this.coordinates[i]+" " : this.coordinates[i]+" ";
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.click = true;
|
||||
this.memory = commander.element_input.value;
|
||||
|
||||
commander.element_input.value += "L"+position.render()+" ";
|
||||
commander.element_input.value = this.create_command();
|
||||
commander.hint.update();
|
||||
this.passive(commander.cmd());
|
||||
}
|
||||
@@ -58,7 +75,8 @@ function Vector(rune)
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(!this.click){ return; }
|
||||
commander.element_input.value = this.memory+"L"+position.render()+" ";
|
||||
commander.element_input.value = this.create_command();
|
||||
commander.element_input.value += "L"+position.render();
|
||||
commander.hint.update();
|
||||
this.passive(commander.cmd());
|
||||
}
|
||||
@@ -66,5 +84,20 @@ function Vector(rune)
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
this.click = null;
|
||||
|
||||
// Add the right thing
|
||||
if(keyboard.shift_held == true){
|
||||
this.coordinates.push("A1,1 0 0,1 "+position.render());
|
||||
}
|
||||
else if(keyboard.alt_held == true){
|
||||
this.coordinates.push("A1,1 0 0,0 "+position.render());
|
||||
}
|
||||
else{
|
||||
this.coordinates.push(position.render());
|
||||
}
|
||||
|
||||
commander.element_input.value = this.create_command();
|
||||
commander.hint.update();
|
||||
this.passive(commander.cmd());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user