Improved guide

This commit is contained in:
Devine Lu Linvega
2018-05-08 10:59:38 +12:00
parent 8e3d496719
commit 5afd2906b3
4 changed files with 27 additions and 38 deletions

View File

@@ -10,7 +10,7 @@ function Guide()
this.start = function()
{
this.clear();
this.draw();
this.refresh();
}
this.toggle = function()
@@ -18,19 +18,6 @@ function Guide()
this.el.style.opacity = !this.el.style.opacity || this.el.style.opacity == 1 ? 0 : 1;
}
this.draw = function()
{
for (var x = dotgrid.grid_x; 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;
dotgrid.guide.draw_marker({x:pos_x,y:pos_y},radius,is_step);
}
}
}
this.resize = function(size)
{
this.el.width = (size.width+40)*2;
@@ -38,7 +25,7 @@ function Guide()
this.el.style.width = (size.width+40)+"px";
this.el.style.height = (size.height+40)+"px";
this.update();
this.refresh();
}
this.clear = function()
@@ -46,14 +33,28 @@ function Guide()
this.el.getContext('2d').clearRect(0, 0, this.el.width*2, this.el.height*2);
}
this.update = function()
this.refresh = function()
{
console.log("refresh")
this.clear();
// Markers
for (var x = dotgrid.grid_x; 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);
}
}
// Verteces
for(id in dotgrid.tool.verteces){
this.draw_vertex(dotgrid.tool.verteces[id]);
}
// Handles
for(segment_id in dotgrid.tool.layer()){
var segment = dotgrid.tool.layer()[segment_id];
for(vertex_id in segment.verteces){
@@ -66,7 +67,6 @@ function Guide()
if(dotgrid.translation){
this.draw_translation();
}
this.draw();
}
this.draw_vertex = function(pos, radius = 5)
@@ -101,13 +101,6 @@ function Guide()
ctx.strokeStyle = dotgrid.theme.active.f_low;
ctx.stroke();
ctx.closePath();
ctx.beginPath();
ctx.arc((pos.x * 2)+30, (pos.y * 2)+30, 2, 0, 2 * Math.PI, false);
ctx.fillStyle = dotgrid.theme.active.f_high;
ctx.fill();
ctx.strokeStyle = dotgrid.theme.active.background;
ctx.stroke();
ctx.closePath();
}
this.draw_translation = function()