pointvec/sources/scripts/path_line.js

47 lines
1015 B
JavaScript
Raw Normal View History

2017-11-04 19:59:11 -04:00
function Path_Line(from,to,end = null)
{
2017-11-21 16:24:25 -05:00
this.__serialized_name__ = "Path_Line";
2017-11-05 14:38:14 -05:00
this.name = "line";
2017-11-21 16:24:25 -05:00
2017-11-04 19:59:11 -04:00
this.from = from;
this.to = to;
this.end = end;
this.to_segment = function(prev)
{
var html = ""
2017-11-05 14:15:31 -05:00
if(!prev || (!prev.to && !prev.end)){
2017-11-12 16:47:34 -05:00
html += "M"+this.from.scale(dotgrid.scale)+" ";
2017-11-04 19:59:11 -04:00
}
else if(prev){
2017-11-05 00:33:04 -04:00
if(prev.end){
2017-11-12 16:47:34 -05:00
if(!prev.end.is_equal(this.from.scale(dotgrid.scale))){
html += "M"+this.from.scale(dotgrid.scale)+" ";
2017-11-05 00:33:04 -04:00
}
2017-11-04 19:59:11 -04:00
}
2017-11-05 00:33:04 -04:00
else if(prev.to){
2017-11-12 16:47:34 -05:00
if(!prev.to.is_equal(this.from.scale(dotgrid.scale))){
html += "M"+this.from.scale(dotgrid.scale)+" ";
2017-11-05 00:33:04 -04:00
}
2017-11-04 19:59:11 -04:00
}
}
2017-11-12 16:47:34 -05:00
html += "L"+this.to.scale(dotgrid.scale)+" "
2017-11-04 19:59:11 -04:00
if(this.end){
2017-11-12 16:47:34 -05:00
html += "L"+this.end.scale(dotgrid.scale)+" "
2017-11-04 19:59:11 -04:00
}
return html
}
2017-11-12 22:54:56 -05:00
this.handles = function()
{
var a = [];
if(this.from){ a.push(this.from); }
if(this.to){ a.push(this.to); }
if(this.end){ a.push(this.end); }
return a;
}
2017-11-04 19:59:11 -04:00
}