From c8443d4c66ef481b4f4b84b250d8e38fdd7ce96a Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 13 Nov 2016 09:31:34 -0800 Subject: [PATCH] Improved mirror Pointer. --- scripts/brush.js | 8 ++++---- scripts/pointer.js | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/brush.js b/scripts/brush.js index 7e3e0be..002a667 100644 --- a/scripts/brush.js +++ b/scripts/brush.js @@ -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); diff --git a/scripts/pointer.js b/scripts/pointer.js index aecc562..8c8c8bc 100644 --- a/scripts/pointer.js +++ b/scripts/pointer.js @@ -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); }