Guides now tile, and can be positioned at the bottom.

This commit is contained in:
Devine Lu Linvega 2016-11-13 08:44:57 -08:00
parent 657694b255
commit 26972ebce5
3 changed files with 21 additions and 9 deletions

View File

@ -4,7 +4,7 @@ canvas:hover { cursor: crosshair;}
#guides { position:fixed; z-index:1000;} #guides { position:fixed; z-index:1000;}
#commander { display:none; } #commander { display:none; z-index: 2000; }
#commander.visible { display:block; } #commander.visible { display:block; }
#commander.hidden { display:none; } #commander.hidden { display:none; }
#commander input { background:black; padding:15px; position:fixed; bottom:0; color:white; left:0; border:0; width:calc(100vw); font-family:courier; cursor:pointer; display:block;} #commander input { background:black; padding:15px; position:fixed; bottom:0; color:white; left:0; border:0; width:calc(100vw); font-family:courier; cursor:pointer; display:block;}

View File

@ -8,7 +8,17 @@ function Guide(position = new Position(),rect = new Rect(),color = new Color())
{ {
context.beginPath(); context.beginPath();
if(this.position.x > 0 && this.position.y > 0 && (this.rect.w > 0 || this.rect.h > 0)){ if((this.position.x < 0 || this.position.y < 0) && (this.rect.w > 0 || this.rect.h > 0)){
var new_x = this.position.x < 0 ? canvas.width - Math.abs(this.position.x) - this.rect.w : this.position.x;
var new_y = this.position.y < 0 ? canvas.height - Math.abs(this.position.y) - this.rect.h : this.position.y;
console.log(new_y);
context.moveTo(new_x,new_y);
context.lineTo(new_x + this.rect.w,new_y);
context.lineTo(new_x + this.rect.w,new_y + this.rect.h);
context.lineTo(new_x,new_y + this.rect.h);
context.lineTo(new_x,new_y);
}
else if(this.position.x > 0 && this.position.y > 0 && (this.rect.w > 0 || this.rect.h > 0)){
context.moveTo(this.position.x,this.position.y); context.moveTo(this.position.x,this.position.y);
context.lineTo(this.position.x + this.rect.w,this.position.y); context.lineTo(this.position.x + this.rect.w,this.position.y);
context.lineTo(this.position.x + this.rect.w,this.position.y + this.rect.h); context.lineTo(this.position.x + this.rect.w,this.position.y + this.rect.h);

View File

@ -58,24 +58,25 @@ function Ronin()
var w = p[2] ? p[2] : 0 ; var w = p[2] ? p[2] : 0 ;
var h = p[3] ? p[3] : 0 ; var h = p[3] ? p[3] : 0 ;
if(x < -10){ if(x < -10 && w === 0 && h === 0){
x = Math.abs(x); x = Math.abs(x);
for (i = 0; i < canvas.width/x; i++) { for (i = 0; i < canvas.width/x; i++) {
var g = new Guide(new Position(x * i,y), new Rect(w,h), new Color('000000')); var g = new Guide(new Position(x * i,y), new Rect(w,h), new Color('ff0000'));
g.draw(this.guides_context); g.draw(this.guides_context);
} }
} }
else if(y < -10){ else if(y < -10 && w === 0 && h === 0){
y = Math.abs(y); y = Math.abs(y);
for (i = 0; i < canvas.width/y; i++) { for (i = 0; i < canvas.width/y; i++) {
var g = new Guide(new Position(x,y* i), new Rect(w,h), new Color('000000')); var g = new Guide(new Position(x,y* i), new Rect(w,h), new Color('ff0000'));
g.draw(this.guides_context); g.draw(this.guides_context);
} }
} }
else{ else{
var g = new Guide(new Position(x,y), new Rect(w,h), new Color('000000')); var g = new Guide(new Position(x,y), new Rect(w,h), new Color('ff0000'));
g.draw(this.guides_context); g.draw(this.guides_context);
} }
} }
this.add_guide = function(p) this.add_guide = function(p)
@ -85,14 +86,15 @@ function Ronin()
var w = p[2] ? p[2] : 0 ; var w = p[2] ? p[2] : 0 ;
var h = p[3] ? p[3] : 0 ; var h = p[3] ? p[3] : 0 ;
if(x < -10){
if(x < -10 && w === 0 && h === 0){
x = Math.abs(x); x = Math.abs(x);
for (i = 0; i < canvas.width/x; i++) { for (i = 0; i < canvas.width/x; i++) {
var g = new Guide(new Position(x * i,y), new Rect(w,h), new Color('000000')); var g = new Guide(new Position(x * i,y), new Rect(w,h), new Color('000000'));
this.guides.push(g); this.guides.push(g);
} }
} }
else if(y < -10){ else if(y < -10 && w === 0 && h === 0){
y = Math.abs(y); y = Math.abs(y);
for (i = 0; i < canvas.width/y; i++) { for (i = 0; i < canvas.width/y; i++) {
var g = new Guide(new Position(x,y* i), new Rect(w,h), new Color('000000')); var g = new Guide(new Position(x,y* i), new Rect(w,h), new Color('000000'));