Improved shortcuts further
This commit is contained in:
@@ -201,26 +201,26 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
|
||||
this.set_from = function(pos)
|
||||
{
|
||||
from = pos;
|
||||
from = pos.mirror().clamp(0,300).mirror();
|
||||
|
||||
cursor_from.style.left = Math.floor(-pos.x*this.scale + this.grid_width);
|
||||
cursor_from.style.top = Math.floor(pos.y*this.scale + this.grid_height);
|
||||
cursor_from.style.left = Math.floor(-from.x*this.scale + this.grid_width);
|
||||
cursor_from.style.top = Math.floor(from.y*this.scale + this.grid_height);
|
||||
}
|
||||
|
||||
this.set_to = function(pos)
|
||||
{
|
||||
cursor_to.style.left = Math.floor(-pos.x*this.scale + this.grid_width);
|
||||
cursor_to.style.top = Math.floor(pos.y*this.scale + this.grid_height);
|
||||
to = pos.mirror().clamp(0,300).mirror();
|
||||
|
||||
to = pos;
|
||||
cursor_to.style.left = Math.floor(-to.x*this.scale + this.grid_width);
|
||||
cursor_to.style.top = Math.floor(to.y*this.scale + this.grid_height);
|
||||
}
|
||||
|
||||
this.set_end = function(pos)
|
||||
{
|
||||
cursor_end.style.left = Math.floor(-pos.x*this.scale + this.grid_width);
|
||||
cursor_end.style.top = Math.floor(pos.y*this.scale + this.grid_height);
|
||||
end = pos.mirror().clamp(0,300).mirror();
|
||||
|
||||
end = pos;
|
||||
cursor_end.style.left = Math.floor(-end.x*this.scale + this.grid_width);
|
||||
cursor_end.style.top = Math.floor(end.y*this.scale + this.grid_height);
|
||||
}
|
||||
|
||||
this.delete_at = function(pos)
|
||||
@@ -436,7 +436,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
this.draw()
|
||||
var svg = this.svg_el.outerHTML
|
||||
|
||||
|
||||
dotgrid.resize()
|
||||
dialog.showSaveDialog((fileName) => {
|
||||
dotgrid.resize()
|
||||
|
||||
@@ -45,10 +45,10 @@ function Keyboard()
|
||||
|
||||
case 9 : dotgrid.toggle_fill(); e.preventDefault(); break; // 'tab'
|
||||
|
||||
case 38 : dotgrid.mod_move(new Pos(0,-10)); break; // 'up'
|
||||
case 40 : dotgrid.mod_move(new Pos(0,10)); break; // 'down'
|
||||
case 37 : dotgrid.mod_move(new Pos(-10,0)); break; // 'left'
|
||||
case 39 : dotgrid.mod_move(new Pos(10,0)); break; // 'right'
|
||||
case 38 : dotgrid.mod_move(new Pos(0,-15)); break; // 'up'
|
||||
case 40 : dotgrid.mod_move(new Pos(0,15)); break; // 'down'
|
||||
case 37 : dotgrid.mod_move(new Pos(-15,0)); break; // 'left'
|
||||
case 39 : dotgrid.mod_move(new Pos(15,0)); break; // 'right'
|
||||
}
|
||||
dotgrid.draw();
|
||||
}
|
||||
|
||||
@@ -27,4 +27,16 @@ function Pos(x,y)
|
||||
{
|
||||
return new Pos(this.x*a,this.y*a)
|
||||
}
|
||||
|
||||
this.mirror = function(x = -1,y = 1)
|
||||
{
|
||||
return new Pos(this.x * x,this.y * y);
|
||||
}
|
||||
|
||||
this.clamp = function(min,max)
|
||||
{
|
||||
return new Pos(clamp(this.x,min,max),clamp(this.y,min,max));
|
||||
}
|
||||
|
||||
function clamp(v, min, max) { return v < min ? min : v > max ? max : v; }
|
||||
}
|
||||
Reference in New Issue
Block a user