From d6c2c776a7675bbe7ec0945e0b6c691b4e9b95e0 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 17 Nov 2017 19:17:45 +1300 Subject: [PATCH] Display a guide for the mirror brush --- sources/scripts/layers/guide.js | 11 +++++++++++ sources/scripts/modules/brush.js | 7 +++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sources/scripts/layers/guide.js b/sources/scripts/layers/guide.js index db06bfc..16ee43b 100644 --- a/sources/scripts/layers/guide.js +++ b/sources/scripts/layers/guide.js @@ -19,6 +19,13 @@ function Guide() if(this.inspect){ this.draw_inspector(); } + + // Brush mirrors + for(id in ronin.brush.pointers){ + var pointer = ronin.brush.pointers[id]; + if(!pointer.options.mirror){ continue; } + units.push({x1:pointer.options.mirror.x,y1:0,x2:pointer.options.mirror.x,y2:ronin.frame.height}) + } if(units.length == 0){ return; } @@ -29,6 +36,10 @@ function Guide() this.draw = function(u = null) { + if(u && u.x1 != null && u.y1 != null && u.x2 != null && u.y2 != null){ + this.draw_line({x:u.x1,y:u.y1},{x:u.x2,y:u.y2}) + } + if(u && u.x && u.y){ this.draw_pos(u); } diff --git a/sources/scripts/modules/brush.js b/sources/scripts/modules/brush.js index 07f2618..93e1f96 100644 --- a/sources/scripts/modules/brush.js +++ b/sources/scripts/modules/brush.js @@ -5,8 +5,7 @@ function Brush() this.settings = {size:4,color:"#000"}; this.pointers = [ - new Pointer({offset:{x:0,y:0}}), - new Pointer({offset:{x:0,y:0},mirror:{x:400,y:0}}) + new Pointer({offset:{x:0,y:0}}) ]; this.ports.speed = new Port(this,"speed",false,true,0,50,"The cursor speed"); @@ -109,8 +108,8 @@ function Pointer(options) var ctx = ronin.render.context(); if(this.options.mirror){ - line.from.x = this.options.mirror.x - line.from.x; - line.to.x = this.options.mirror.x - line.to.x; + line.from.x = (this.options.mirror.x *2) - line.from.x; + line.to.x = (this.options.mirror.x*2) - line.to.x; } ctx.beginPath();