Migrated color picker

This commit is contained in:
Devine Lu Linvega 2018-08-18 08:04:54 +12:00
parent 446ec315f2
commit 2b55e0ff62
2 changed files with 23 additions and 10 deletions

View File

@ -164,12 +164,10 @@ function Guide()
ctx.fillStyle = style.color ctx.fillStyle = style.color
ctx.fill(p); ctx.fill(p);
} }
if(style.strokeLineDash){
ctx.setLineDash(style.strokeLineDash); // Dash
} if(style.strokeLineDash){ ctx.setLineDash(style.strokeLineDash); }
else{ else{ ctx.setLineDash([]); }
ctx.setLineDash([]);
}
ctx.stroke(p); ctx.stroke(p);
} }
@ -187,8 +185,10 @@ function Guide()
ctx.strokeStyle = dotgrid.theme.active.b_inv; ctx.strokeStyle = dotgrid.theme.active.b_inv;
ctx.setLineDash([5,10]); ctx.setLineDash([5,10]);
ctx.stroke(); ctx.stroke();
ctx.setLineDash([0,0]);
ctx.closePath(); ctx.closePath();
ctx.setLineDash([]);
ctx.restore();
} }
this.draw_cursor = function(pos = dotgrid.cursor.pos,radius = dotgrid.tool.style().thickness-1) this.draw_cursor = function(pos = dotgrid.cursor.pos,radius = dotgrid.tool.style().thickness-1)
@ -214,6 +214,7 @@ function Guide()
this.draw_preview = function() this.draw_preview = function()
{ {
var ctx = this.el.getContext('2d');
var operation = dotgrid.cursor.operation && dotgrid.cursor.operation.cast ? dotgrid.cursor.operation.cast : null var operation = dotgrid.cursor.operation && dotgrid.cursor.operation.cast ? dotgrid.cursor.operation.cast : null
if(!dotgrid.tool.can_cast(operation)){ return; } if(!dotgrid.tool.can_cast(operation)){ return; }
@ -228,6 +229,9 @@ function Guide()
strokeLineDash:[5, 15] strokeLineDash:[5, 15]
} }
this.draw_path(path,style) 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) } 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) }

View File

@ -9,7 +9,10 @@ function Picker()
{ {
this.el.setAttribute("placeholder",`${dotgrid.tool.style().color}`) 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" dotgrid.interface.el.className = "picker"
this.el.focus() this.el.focus()
this.original = dotgrid.tool.style().color this.original = dotgrid.tool.style().color
@ -19,7 +22,10 @@ function Picker()
this.stop = function() this.stop = function()
{ {
this.cancel(); this.cancel();
dotgrid.controller.set();
try{ dotgrid.controller.set(); }
catch(err){ console.log("No controller"); }
dotgrid.interface.el.className = "" dotgrid.interface.el.className = ""
this.el.blur() this.el.blur()
this.el.value = "" this.el.value = ""
@ -33,7 +39,10 @@ function Picker()
if(parts.size){ this.set_size(parts.size); } if(parts.size){ this.set_size(parts.size); }
dotgrid.guide.refresh(); dotgrid.guide.refresh();
dotgrid.controller.set();
try{ dotgrid.controller.set(); }
catch(err){ console.log("No controller"); }
dotgrid.interface.el.className = "" dotgrid.interface.el.className = ""
this.el.blur() this.el.blur()
this.el.value = "" this.el.value = ""