From 2b55e0ff6247e6481302a725bec69787fbbf619d Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 18 Aug 2018 08:04:54 +1200 Subject: [PATCH] Migrated color picker --- desktop/sources/scripts/guide.js | 18 +++++++++++------- desktop/sources/scripts/picker.js | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/desktop/sources/scripts/guide.js b/desktop/sources/scripts/guide.js index c427813..ea88690 100644 --- a/desktop/sources/scripts/guide.js +++ b/desktop/sources/scripts/guide.js @@ -164,12 +164,10 @@ function Guide() ctx.fillStyle = style.color ctx.fill(p); } - if(style.strokeLineDash){ - ctx.setLineDash(style.strokeLineDash); - } - else{ - ctx.setLineDash([]); - } + + // Dash + if(style.strokeLineDash){ ctx.setLineDash(style.strokeLineDash); } + else{ ctx.setLineDash([]); } ctx.stroke(p); } @@ -187,8 +185,10 @@ function Guide() ctx.strokeStyle = dotgrid.theme.active.b_inv; ctx.setLineDash([5,10]); ctx.stroke(); - ctx.setLineDash([0,0]); ctx.closePath(); + + ctx.setLineDash([]); + ctx.restore(); } this.draw_cursor = function(pos = dotgrid.cursor.pos,radius = dotgrid.tool.style().thickness-1) @@ -214,6 +214,7 @@ function Guide() this.draw_preview = function() { + var ctx = this.el.getContext('2d'); var operation = dotgrid.cursor.operation && dotgrid.cursor.operation.cast ? dotgrid.cursor.operation.cast : null if(!dotgrid.tool.can_cast(operation)){ return; } @@ -228,6 +229,9 @@ function Guide() strokeLineDash:[5, 15] } this.draw_path(path,style) + + ctx.setLineDash([]); + ctx.restore(); } function pos_is_equal(a,b){ return a && b && Math.abs(a.x) == Math.abs(b.x) && Math.abs(a.y) == Math.abs(b.y) } diff --git a/desktop/sources/scripts/picker.js b/desktop/sources/scripts/picker.js index 2970eb6..40e5117 100644 --- a/desktop/sources/scripts/picker.js +++ b/desktop/sources/scripts/picker.js @@ -9,7 +9,10 @@ function Picker() { this.el.setAttribute("placeholder",`${dotgrid.tool.style().color}`) - dotgrid.controller.set("picker"); + try{ dotgrid.controller.set("picker"); } + catch(err){ console.log("No controller"); } + + dotgrid.interface.el.className = "picker" this.el.focus() this.original = dotgrid.tool.style().color @@ -19,7 +22,10 @@ function Picker() this.stop = function() { this.cancel(); - dotgrid.controller.set(); + + try{ dotgrid.controller.set(); } + catch(err){ console.log("No controller"); } + dotgrid.interface.el.className = "" this.el.blur() this.el.value = "" @@ -33,7 +39,10 @@ function Picker() if(parts.size){ this.set_size(parts.size); } dotgrid.guide.refresh(); - dotgrid.controller.set(); + + try{ dotgrid.controller.set(); } + catch(err){ console.log("No controller"); } + dotgrid.interface.el.className = "" this.el.blur() this.el.value = ""