Fixed the draw_line function.
This commit is contained in:
parent
fd34a91758
commit
01483dddcc
@ -94,12 +94,12 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
this.svg_el.style.strokeLinecap = this.linecap;
|
this.svg_el.style.strokeLinecap = this.linecap;
|
||||||
this.element.appendChild(this.svg_el);
|
this.element.appendChild(this.svg_el);
|
||||||
|
|
||||||
this.offset_el.appendChild(this.path)
|
this.offset_el.appendChild(this.path)
|
||||||
this.svg_el.appendChild(this.offset_el);
|
this.svg_el.appendChild(this.offset_el);
|
||||||
this.svg_el.appendChild(this.mirror_el);
|
this.svg_el.appendChild(this.mirror_el);
|
||||||
this.mirror_el.appendChild(this.mirror_path);
|
this.mirror_el.appendChild(this.mirror_path);
|
||||||
|
|
||||||
this.draw();
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
@ -139,7 +139,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
if(pos[0] < -300){ return; }
|
if(pos[0] < -300){ return; }
|
||||||
if(pos[0] > 0){ return; }
|
if(pos[0] > 0){ return; }
|
||||||
if(pos[1] < 0){ return; }
|
if(pos[1] < 0){ return; }
|
||||||
|
|
||||||
if(from === null){ this.set_from(pos); }
|
if(from === null){ this.set_from(pos); }
|
||||||
else if(to === null){ this.set_to(pos); }
|
else if(to === null){ this.set_to(pos); }
|
||||||
else{ this.set_end(pos); }
|
else{ this.set_end(pos); }
|
||||||
@ -203,7 +203,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
if(end){
|
if(end){
|
||||||
this.set_end([end[0]-(x),end[1]+(y)])
|
this.set_end([end[0]-(x),end[1]+(y)])
|
||||||
this.draw();
|
this.draw();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Move offset
|
// Move offset
|
||||||
this.offset = this.offset.add(new Pos(x,y));
|
this.offset = this.offset.add(new Pos(x,y));
|
||||||
@ -246,16 +246,17 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
// Draw
|
// Draw
|
||||||
this.draw_line = function()
|
this.draw_line = function()
|
||||||
{
|
{
|
||||||
if(from === null || to === null){ return; }
|
if(from === null || to === null){ return; }
|
||||||
|
|
||||||
var end_point = end ? new Pos(end[0] * -1,end[1]) : null;
|
to = new Pos(to[0] * -1, to[1])
|
||||||
|
var end_point = end ? new Pos(end[0] * -1,end[1]) : to;
|
||||||
|
|
||||||
from = new Pos(from[0],from[1])
|
from = new Pos(from[0] * -1,from[1])
|
||||||
|
|
||||||
this.segments.push(new Path_Line(new Pos(from.x * -1,from.y).sub(this.offset),new Pos(to[0] * -1,to[1]).sub(this.offset),end_point.sub(this.offset)));
|
this.segments.push(new Path_Line(from.sub(this.offset),to.sub(this.offset),end_point.sub(this.offset)));
|
||||||
|
|
||||||
this.draw();
|
this.draw();
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.draw_arc = function(orientation)
|
this.draw_arc = function(orientation)
|
||||||
@ -271,7 +272,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
|
|
||||||
this.draw_bezier = function()
|
this.draw_bezier = function()
|
||||||
{
|
{
|
||||||
if(from === null || to === null){ return; }
|
if(from === null || to === null){ return; }
|
||||||
|
|
||||||
this.segments.push(new Path_Bezier(new Pos(from[0] * -1,from[1]).sub(this.offset),new Pos(to[0] * -1,to[1]).sub(this.offset),new Pos(end[0] * -1,end[1]).sub(this.offset)));
|
this.segments.push(new Path_Bezier(new Pos(from[0] * -1,from[1]).sub(this.offset),new Pos(to[0] * -1,to[1]).sub(this.offset),new Pos(end[0] * -1,end[1]).sub(this.offset)));
|
||||||
|
|
||||||
@ -285,7 +286,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
if(this.segments[this.segments.length-1].name == "close"){ return; }
|
if(this.segments[this.segments.length-1].name == "close"){ return; }
|
||||||
|
|
||||||
this.segments.push(new Path_Close());
|
this.segments.push(new Path_Close());
|
||||||
|
|
||||||
this.draw();
|
this.draw();
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
@ -314,7 +315,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
this.segments.pop();
|
this.segments.pop();
|
||||||
}
|
}
|
||||||
this.draw();
|
this.draw();
|
||||||
}
|
}
|
||||||
@ -322,13 +323,13 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
this.export = function()
|
this.export = function()
|
||||||
{
|
{
|
||||||
if(this.segments.length == 0){ return; }
|
if(this.segments.length == 0){ return; }
|
||||||
|
|
||||||
dialog.showSaveDialog((fileName) => {
|
dialog.showSaveDialog((fileName) => {
|
||||||
if (fileName === undefined){ return; }
|
if (fileName === undefined){ return; }
|
||||||
fs.writeFile(fileName+".svg", dotgrid.svg_el.outerHTML, (err) => {
|
fs.writeFile(fileName+".svg", dotgrid.svg_el.outerHTML, (err) => {
|
||||||
if(err){ alert("An error ocurred creating the file "+ err.message); return; }
|
if(err){ alert("An error ocurred creating the file "+ err.message); return; }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.update_interface = function()
|
this.update_interface = function()
|
||||||
@ -347,7 +348,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(from && to && end){
|
if(from && to && end){
|
||||||
html += "<img data-operation='bezier' title='bezier (f)' src='media/icons/bezier.svg' class='icon'/>";
|
html += "<img data-operation='bezier' title='bezier (f)' src='media/icons/bezier.svg' class='icon'/>";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
html += "<img title='bezier (f)' src='media/icons/bezier.svg' class='icon inactive'/>";
|
html += "<img title='bezier (f)' src='media/icons/bezier.svg' class='icon inactive'/>";
|
||||||
@ -373,7 +374,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
else{
|
else{
|
||||||
html += "<img title='export (e)' src='media/icons/export.svg' class='icon right inactive'/>";
|
html += "<img title='export (e)' src='media/icons/export.svg' class='icon right inactive'/>";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.interface.innerHTML = html;
|
this.interface.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,4 +391,4 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
|||||||
y = parseInt(y/this.grid_height) * this.grid_height + (this.grid_height/2) +5;
|
y = parseInt(y/this.grid_height) * this.grid_height + (this.grid_height/2) +5;
|
||||||
return [parseInt(x),parseInt(y)];
|
return [parseInt(x),parseInt(y)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user