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);
|
Module.call(this,rune);
|
||||||
|
|
||||||
this.parameters = [];
|
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.";
|
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;
|
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');
|
var d = this.merge().element.toDataURL('image/jpeg');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -7,6 +7,7 @@ function Vector(rune)
|
|||||||
|
|
||||||
this.layer = null;
|
this.layer = null;
|
||||||
this.coordinates = [];
|
this.coordinates = [];
|
||||||
|
this.last_pos = null;
|
||||||
|
|
||||||
this.install = function()
|
this.install = function()
|
||||||
{
|
{
|
||||||
@ -61,7 +62,7 @@ function Vector(rune)
|
|||||||
var command = "+ ";
|
var command = "+ ";
|
||||||
|
|
||||||
for (var i = 0; i < this.coordinates.length; i++) {
|
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;
|
return command;
|
||||||
}
|
}
|
||||||
@ -88,22 +89,30 @@ function Vector(rune)
|
|||||||
{
|
{
|
||||||
this.click = null;
|
this.click = null;
|
||||||
|
|
||||||
// Add the right thing
|
if(this.coordinates.length == 0){
|
||||||
if(keyboard.shift_held == true && keyboard.alt_held == true){
|
|
||||||
this.coordinates.push("M"+position.render());
|
this.coordinates.push("M"+position.render());
|
||||||
}
|
}
|
||||||
else 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{
|
else{
|
||||||
this.coordinates.push(position.render());
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
else 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("l"+offset.render());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commander.element_input.value = this.create_command();
|
commander.element_input.value = this.create_command();
|
||||||
commander.hint.update();
|
commander.hint.update();
|
||||||
this.passive(commander.cmd());
|
this.passive(commander.cmd());
|
||||||
|
this.last_pos = position;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,6 +24,11 @@ function Position(position_str = "0,0",y = null)
|
|||||||
if(!target){ return 0; }
|
if(!target){ return 0; }
|
||||||
return Math.sqrt( (this.x-target.x)*(this.x-target.x) + (this.y-target.y)*(this.y-target.y) );
|
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)
|
this.normalize = function(rect)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user