From ad1ede6796d22e3d61a210b44281e89f3a819c00 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 3 Apr 2018 09:48:36 +1200 Subject: [PATCH] Optimizing --- desktop/package.json | 4 ++-- desktop/sources/scripts/dotgrid.js | 28 ++++++++++++++++++---------- desktop/sources/scripts/guide.js | 1 + 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/desktop/package.json b/desktop/package.json index bd3f92c..3b4d9a5 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -12,11 +12,11 @@ "build" : "npm run clean ; npm run build_osx ; npm run build_linux ; npm run build_win ; npm run build_pi", "push_osx" : "~/butler push ~/Desktop/Dotgrid-darwin-x64/ hundredrabbits/dotgrid:osx-64", "push_linux" : "~/butler push ~/Desktop/Dotgrid-linux-x64/ hundredrabbits/dotgrid:linux-64", - "push_pi" : "~/butler push ~/Desktop/Dotgrid-linux-armv7l/ hundredrabbits/dotgrid:linux-pi", + "push_pi" : "~/butler push ~/Desktop/Dotgrid-linux-armv7l/ hundredrabbits/dotgrid:linux-pi", "push_win" : "~/butler push ~/Desktop/Dotgrid-win32-x64/ hundredrabbits/dotgrid:windows-64", "push_theme" : "~/butler push ~/Github/HundredRabbits/Themes/themes/ hundredrabbits/dotgrid:themes", "push_status" : "~/butler status hundredrabbits/dotgrid", - "push" : "npm run build ; npm run push_theme ; npm run push_osx ; npm run push_pi ; npm run push_linux ; npm run push_win ; npm run clean ; npm run push_status" + "push" : "npm run build ; npm run theme ; npm run push_osx ; npm run push_linux ; npm run push_win ; npm run clean ; npm run push_status" }, "devDependencies": { "electron": "^1.8.1" diff --git a/desktop/sources/scripts/dotgrid.js b/desktop/sources/scripts/dotgrid.js index 6518c8f..afda24c 100644 --- a/desktop/sources/scripts/dotgrid.js +++ b/desktop/sources/scripts/dotgrid.js @@ -344,8 +344,18 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) setTimeout(() => { dotgrid.tool.clear(); },150); } - this.move_cursor = function(pos) + function pos_is_equal(a,b) { + return a && b && a.x == b.x && a.y == b.y + } + + this.cursor_prev = null; + + this.move_cursor = function(pos, force = false) + { + if(pos_is_equal(pos,this.cursor_prev) && !force){ return; } + + console.log("move_cursor",pos) if(pos.x>0) { this.cursor.style.visibility = "hidden" } else { @@ -355,21 +365,18 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.cursor.style.visibility = "visible" this.cursor.style.left = Math.floor(-(pos.x-this.grid_width)); this.cursor.style.top = Math.floor(pos.y+this.grid_height); - this.update_cursor(pos); + this.cursor_x.style.left = `${-pos.x}px`; + this.cursor_x.textContent = parseInt(-pos.x/this.grid_width) + this.cursor_y.style.top = `${pos.y}px`; + this.cursor_y.textContent = parseInt(pos.y/this.grid_width) window.setTimeout(() => dotgrid.cursor.style.transition = "all 50ms", 17 /*one frame*/) } - } - - this.update_cursor = function(pos) - { - this.cursor_x.style.left = `${-pos.x}px`; - this.cursor_x.textContent = parseInt(-pos.x/this.grid_width) - this.cursor_y.style.top = `${pos.y}px`; - this.cursor_y.textContent = parseInt(pos.y/this.grid_width) + this.cursor_prev = pos; } this.preview = function(operation) { + console.log("preview") if(!operation){ this.preview_el.innerHTML = ``; return;} if(operation != "line" && operation != "arc_c" && operation != "arc_r" && operation != "bezier" && operation != "close"){ this.preview_el.innerHTML = ``; return; } @@ -461,6 +468,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.draw = function(exp = false) { + console.log("draw") var paths = this.tool.paths(); var d = this.tool.path(); this.layer_1.setAttribute("d",paths[0]); diff --git a/desktop/sources/scripts/guide.js b/desktop/sources/scripts/guide.js index 3fedd15..9b3d00d 100644 --- a/desktop/sources/scripts/guide.js +++ b/desktop/sources/scripts/guide.js @@ -66,6 +66,7 @@ function Guide() this.update = function() { + console.log("guide_update") this.clear(); for(id in dotgrid.tool.verteces){