Normalized negative positions in guides.
This commit is contained in:
parent
0dc4e53685
commit
3b067f8855
@ -4,7 +4,6 @@ function File()
|
||||
|
||||
this.active = function()
|
||||
{
|
||||
console.log("Nothing to do.");
|
||||
ronin.overlay.clear();
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,13 @@ function Overlay(element)
|
||||
if(rect){
|
||||
this.draw_rect(position,rect);
|
||||
}
|
||||
else if(position.x > 0 && position.y > 0){
|
||||
else if(position.x != 0 && position.y != 0){
|
||||
this.draw_pointer(position);
|
||||
}
|
||||
else if(position.x > 0 ){
|
||||
else if(position.x != 0 ){
|
||||
this.draw_vertical_line(position);
|
||||
}
|
||||
else if(position.y > 0 ){
|
||||
else if(position.y != 0 ){
|
||||
this.draw_horizontal_line(position);
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,8 @@ function Overlay(element)
|
||||
{
|
||||
this.context().beginPath();
|
||||
|
||||
position.normalize(rect);
|
||||
|
||||
this.context().moveTo(position.x,position.y);
|
||||
this.context().lineTo(position.x + rect.width,position.y);
|
||||
this.context().lineTo(position.x + rect.width,position.y + rect.height);
|
||||
|
@ -22,4 +22,14 @@ function Position(position_str = "0,0",y = null)
|
||||
if(!target){ return 0; }
|
||||
return Math.sqrt( (this.x-target.x)*(this.x-target.x) + (this.y-target.y)*(this.y-target.y) );
|
||||
}
|
||||
|
||||
this.normalize = function(rect)
|
||||
{
|
||||
if(this.x < 0){
|
||||
this.x = ronin.canvas.element.width - rect.width - Math.abs(this.x);
|
||||
}
|
||||
if(this.y < 0){
|
||||
this.y = ronin.canvas.element.height - rect.height - Math.abs(this.y);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user