Improved mirror Pointer.

This commit is contained in:
Devine Lu Linvega 2016-11-13 09:31:34 -08:00
parent 490af4a725
commit c8443d4c66
2 changed files with 9 additions and 6 deletions

View File

@ -16,14 +16,14 @@ function Brush()
this.add = function(p)
{
if(p.length > 1){
if(p.length >= 2){
var position = new Position(parseInt(p[0]),parseInt(p[1]));
var pointer = new Pointer(position);
}
if(p.length > 2){
var color = new Color(p[2]);
pointer = new Pointer(position,color);
if(p.length >= 4){
var mirror = new Position(parseInt(p[2]),parseInt(p[3]));
pointer.mirror = mirror;
}
this.add_pointer(pointer);

View File

@ -30,8 +30,11 @@ function Pointer(offset = new Position(), color = new Color('000000'))
this.position = function()
{
if(this.mirror){
return new Position(500 - (brush.position.x + this.offset.x), brush.position.y + this.offset.y);
if(this.mirror && this.mirror.x > 0){
return new Position(this.mirror.x - (brush.position.x + this.offset.x), 0 + (brush.position.y + this.offset.y));
}
else if(this.mirror && this.mirror.y > 0){
return new Position((brush.position.x + this.offset.x), this.mirror.y - (brush.position.y + this.offset.y));
}
return new Position(brush.position.x + this.offset.x, brush.position.y + this.offset.y);
}