Vector positions are now relative
This commit is contained in:
parent
450aee4f72
commit
6dba090b1f
@ -3,7 +3,7 @@ function FileSave(rune)
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [];
|
||||
this.variables = {"format" : "[png/jpg]"};
|
||||
this.variables = {"format" : "[png/jpg/svg]"};
|
||||
|
||||
this.docs = "Creates a new window with a image of the resulting canvas in the specified format.";
|
||||
|
||||
@ -19,7 +19,11 @@ function FileSave(rune)
|
||||
{
|
||||
var d = null;
|
||||
|
||||
if(cmd.variable("format") && cmd.variable("format").value == "jpg"){
|
||||
if(cmd.variable("format") && cmd.variable("format").value == "svg"){
|
||||
// TODO
|
||||
return;
|
||||
}
|
||||
else if(cmd.variable("format") && cmd.variable("format").value == "jpg"){
|
||||
var d = this.merge().element.toDataURL('image/jpeg');
|
||||
}
|
||||
else{
|
||||
|
@ -7,6 +7,7 @@ function Vector(rune)
|
||||
|
||||
this.layer = null;
|
||||
this.coordinates = [];
|
||||
this.last_pos = null;
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
@ -61,7 +62,7 @@ function Vector(rune)
|
||||
var command = "+ ";
|
||||
|
||||
for (var i = 0; i < this.coordinates.length; i++) {
|
||||
command += i == 0 ? "M"+this.coordinates[i]+" " : this.coordinates[i]+" ";
|
||||
command += this.coordinates[i]+" ";
|
||||
}
|
||||
return command;
|
||||
}
|
||||
@ -88,7 +89,13 @@ function Vector(rune)
|
||||
{
|
||||
this.click = null;
|
||||
|
||||
// Add the right thing
|
||||
if(this.coordinates.length == 0){
|
||||
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){
|
||||
this.coordinates.push("M"+position.render());
|
||||
}
|
||||
@ -99,11 +106,13 @@ function Vector(rune)
|
||||
this.coordinates.push("A1,1 0 0,0 "+position.render());
|
||||
}
|
||||
else{
|
||||
this.coordinates.push(position.render());
|
||||
this.coordinates.push("l"+offset.render());
|
||||
}
|
||||
}
|
||||
|
||||
commander.element_input.value = this.create_command();
|
||||
commander.hint.update();
|
||||
this.passive(commander.cmd());
|
||||
this.last_pos = position;
|
||||
}
|
||||
}
|
@ -25,6 +25,11 @@ function Position(position_str = "0,0",y = null)
|
||||
return Math.sqrt( (this.x-target.x)*(this.x-target.x) + (this.y-target.y)*(this.y-target.y) );
|
||||
}
|
||||
|
||||
this.offset = function(position = new Position(0,0))
|
||||
{
|
||||
return new Position(this.x - position.x,this.y - position.y);
|
||||
}
|
||||
|
||||
this.normalize = function(rect)
|
||||
{
|
||||
if(this.x < 0){
|
||||
|
Loading…
x
Reference in New Issue
Block a user