Display a guide for the mirror brush

This commit is contained in:
Devine Lu Linvega 2017-11-17 19:17:45 +13:00
parent 25aff03ccf
commit d6c2c776a7
2 changed files with 14 additions and 4 deletions

View File

@ -19,6 +19,13 @@ function Guide()
if(this.inspect){ if(this.inspect){
this.draw_inspector(); 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; } if(units.length == 0){ return; }
@ -29,6 +36,10 @@ function Guide()
this.draw = function(u = null) 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){ if(u && u.x && u.y){
this.draw_pos(u); this.draw_pos(u);
} }

View File

@ -5,8 +5,7 @@ function Brush()
this.settings = {size:4,color:"#000"}; this.settings = {size:4,color:"#000"};
this.pointers = [ this.pointers = [
new Pointer({offset:{x:0,y:0}}), new Pointer({offset:{x:0,y:0}})
new Pointer({offset:{x:0,y:0},mirror:{x:400,y:0}})
]; ];
this.ports.speed = new Port(this,"speed",false,true,0,50,"The cursor speed"); 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(); var ctx = ronin.render.context();
if(this.options.mirror){ if(this.options.mirror){
line.from.x = this.options.mirror.x - line.from.x; line.from.x = (this.options.mirror.x *2) - line.from.x;
line.to.x = this.options.mirror.x - line.to.x; line.to.x = (this.options.mirror.x*2) - line.to.x;
} }
ctx.beginPath(); ctx.beginPath();