From 127d36d8210feaf2b0278bdaa5e868419ecf9c1c Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 6 Feb 2018 14:23:25 +1300 Subject: [PATCH] Drawing handles --- sources/scripts/dotgrid.js | 2 +- sources/scripts/guide.js | 11 +++++++++-- sources/scripts/tool.js | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sources/scripts/dotgrid.js b/sources/scripts/dotgrid.js index 7fe28f8..4281c0e 100644 --- a/sources/scripts/dotgrid.js +++ b/sources/scripts/dotgrid.js @@ -135,7 +135,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca this.controller.add("default","Edit","Move Down",() => { dotgrid.mod_move(new Pos(0,15)); },"Down"); this.controller.add("default","Edit","Move Left",() => { dotgrid.mod_move(new Pos(-15,0)); },"Left"); this.controller.add("default","Edit","Move Right",() => { dotgrid.mod_move(new Pos(15,0)); },"Right"); - this.controller.add("default","Edit","Deselect",() => { dotgrid.reset(); },"Esc"); + this.controller.add("default","Edit","Deselect",() => { dotgrid.tool.clear(); },"Esc"); this.controller.add("default","Stroke","Line",() => { dotgrid.tool.cast("line"); },"A"); this.controller.add("default","Stroke","Arc",() => { dotgrid.draw_arc("0,1"); },"S"); diff --git a/sources/scripts/guide.js b/sources/scripts/guide.js index feca1ed..9e20446 100644 --- a/sources/scripts/guide.js +++ b/sources/scripts/guide.js @@ -72,6 +72,14 @@ function Guide() this.draw_vertex(dotgrid.tool.verteces[id]); } + for(segment_id in dotgrid.tool.layer()){ + var segment = dotgrid.tool.layer()[segment_id]; + for(vertex_id in segment.verteces){ + var vertex = segment.verteces[vertex_id]; + this.draw_handle(vertex); + } + } + // Translations if(dotgrid.translation){ this.draw_translation(); @@ -99,7 +107,7 @@ function Guide() ctx.closePath(); } - this.draw_handle = function(pos,radius) + this.draw_handle = function(pos,radius = 5) { var ctx = this.widgets.getContext('2d'); @@ -108,7 +116,6 @@ function Guide() ctx.fillStyle = dotgrid.theme.active.f_high; ctx.fill(); ctx.closePath(); - ctx.beginPath(); ctx.arc((pos.x * 2)+20, (pos.y * 2)+20, radius, 0, 2 * Math.PI, false); ctx.fillStyle = dotgrid.theme.active.f_high; diff --git a/sources/scripts/tool.js b/sources/scripts/tool.js index 1fc1cd2..f94a266 100644 --- a/sources/scripts/tool.js +++ b/sources/scripts/tool.js @@ -94,5 +94,6 @@ function Tool() this.clear = function() { this.verteces = []; + dotgrid.draw(); } } \ No newline at end of file