From 32d971cd02766227844e26eb8e991ef2e1f87525 Mon Sep 17 00:00:00 2001 From: cantbesure1 Date: Mon, 6 Nov 2017 22:55:51 -0800 Subject: [PATCH 1/4] cursor change/fix --- sources/scripts/dotgrid.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index ed79715..9c3890e 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -138,10 +138,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca pos = [pos[0],pos[1]] - if(pos[1] > 300){ return; } - if(pos[0] < -300){ return; } - if(pos[0] > 0){ return; } - if(pos[1] < 0){ return; } + if(pos[3]) return; if(from === null){ this.set_from(pos); } else if(to === null){ this.set_to(pos); } @@ -394,11 +391,16 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca return [(window.innerWidth/2) - (this.width/2) - x,y - 50]; } - this.position_on_grid = function(x,y) + this.position_on_grid = function(x,y) // rounds the mouse position to the nearest cell, and limits the coords to within the box { - x = parseInt(x/this.grid_width) * this.grid_width - (this.grid_width/2) + 5; - y = parseInt(y/this.grid_height) * this.grid_height + (this.grid_height/2) +5; - return [parseInt(x),parseInt(y)]; + x = Math.round(x/this.grid_width)*this.grid_width + y = Math.round(y/this.grid_height)*this.grid_height+this.grid_height + off = (x<-this.width || x>0 || y>this.height || y<0) + if(off) { // change position so the cursor will not be seen + x = 50 + y = -50 + } + return [parseInt(x),parseInt(y),off]; } } From dea2957972a9df8603dafdd132e117caa2bacc4f Mon Sep 17 00:00:00 2001 From: cantbesure1 Date: Mon, 6 Nov 2017 22:59:45 -0800 Subject: [PATCH 2/4] thickness bugfix --- sources/scripts/dotgrid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index 9c3890e..84b2153 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -174,7 +174,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.mod_thickness = function(mod) { - this.thickness += mod; + this.thickness = Math.max(this.thickness+mod,0); this.draw(); } From fbd26a76eaa49318ac6a9e9a2618da24c0f13f9e Mon Sep 17 00:00:00 2001 From: cantbesure1 Date: Mon, 6 Nov 2017 23:15:15 -0800 Subject: [PATCH 3/4] tiny documentation fix --- sources/scripts/keyboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/scripts/keyboard.js b/sources/scripts/keyboard.js index 274677d..928dc39 100644 --- a/sources/scripts/keyboard.js +++ b/sources/scripts/keyboard.js @@ -40,7 +40,7 @@ function Keyboard() case 87 : dotgrid.erase(); break; // 'W' case 8 : dotgrid.erase(); break; // 'Backspace' case 69 : dotgrid.export(); break; // 'e' - case 13 : dotgrid.export(); break; // 'e' + case 13 : dotgrid.export(); break; // 'Enter' case 9 : dotgrid.toggle_fill(); e.preventDefault(); break; // 'tab' From 2e5bf29ab42b58dc5dd05d83ac47deee23a60a77 Mon Sep 17 00:00:00 2001 From: cantbesure1 Date: Mon, 6 Nov 2017 23:50:10 -0800 Subject: [PATCH 4/4] return statement bugfix --- sources/scripts/dotgrid.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index 84b2153..95a2d1f 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -135,10 +135,8 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca { var pos = this.position_in_grid(e.clientX,e.clientY); pos = this.position_on_grid(pos[0],pos[1]); - - pos = [pos[0],pos[1]] - - if(pos[3]) return; + + if(pos[2]) return; if(from === null){ this.set_from(pos); } else if(to === null){ this.set_to(pos); }