From fe6192c6bc54426cd4cb0cee1a85f6ba5e982c70 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 3 Aug 2018 11:41:37 +1200 Subject: [PATCH] Remove further weird offsets --- desktop/sources/scripts/cursor.js | 4 ++-- desktop/sources/scripts/guide.js | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js index 01b97bc..21c954a 100644 --- a/desktop/sources/scripts/cursor.js +++ b/desktop/sources/scripts/cursor.js @@ -93,8 +93,8 @@ function Cursor() { var grid = dotgrid.tool.settings.size.width/dotgrid.grid_x; return { - x:clamp(step(pos.x,grid),0,dotgrid.tool.settings.size.width), - y:clamp(step(pos.y,grid),0,dotgrid.tool.settings.size.height) + x:clamp(step(pos.x,grid),grid,dotgrid.tool.settings.size.width+grid), + y:clamp(step(pos.y,grid),grid,dotgrid.tool.settings.size.height+grid) }; } } \ No newline at end of file diff --git a/desktop/sources/scripts/guide.js b/desktop/sources/scripts/guide.js index 67a2706..6c91b3c 100644 --- a/desktop/sources/scripts/guide.js +++ b/desktop/sources/scripts/guide.js @@ -8,7 +8,7 @@ function Guide() this.el.style.height = "320px"; this.show_extras = true; - this.scale = 1; // require('electron').remote.getCurrentWindow().this.scaleFactor; + this.scale = 2; // require('electron').remote.getCurrentWindow().this.scaleFactor; this.start = function() { @@ -79,13 +79,21 @@ function Guide() { if(!this.show_extras){ return; } - for (var x = dotgrid.grid_x; x >= 0; x--) { + var cursor = {x:parseInt(dotgrid.cursor.pos.x/dotgrid.grid_width),y:parseInt(dotgrid.cursor.pos.y/dotgrid.grid_width)} + + for (var x = dotgrid.grid_x-1; x >= 0; x--) { for (var y = dotgrid.grid_y; y >= 0; y--) { - var pos_x = parseInt(x * dotgrid.grid_width) + dotgrid.grid_width ; - var pos_y = parseInt(y * dotgrid.grid_height) + dotgrid.grid_height ; var is_step = x % dotgrid.block_x == 0 && y % dotgrid.block_y == 0; - var radius = is_step ? 2.5 : 1.5; - this.draw_marker({x:pos_x,y:pos_y},radius,is_step); + + // Color + var color = is_step ? dotgrid.theme.active.f_med : dotgrid.theme.active.f_low; + if((y == 0 || y == dotgrid.grid_y) && cursor.x == x+1){ color = dotgrid.theme.active.f_high; } + else if((x == 0 || x == dotgrid.grid_x-1) && cursor.y == y+1){ color = dotgrid.theme.active.f_high; } + + this.draw_marker({ + x:parseInt(x * dotgrid.grid_width) + dotgrid.grid_width, + y:parseInt(y * dotgrid.grid_height) + dotgrid.grid_height + },is_step ? 2.5 : 1.5,color); } } } @@ -128,13 +136,13 @@ function Guide() ctx.closePath(); } - this.draw_marker = function(pos,radius = 1,step) + this.draw_marker = function(pos,radius = 1,color) { var ctx = this.el.getContext('2d'); ctx.beginPath(); ctx.lineWidth = 2; ctx.arc(pos.x * this.scale, pos.y * this.scale, radius, 0, 2 * Math.PI, false); - ctx.fillStyle = step ? dotgrid.theme.active.f_med : dotgrid.theme.active.f_low; + ctx.fillStyle = color; ctx.fill(); ctx.closePath(); }