Improved translation
This commit is contained in:
parent
edaa37077b
commit
ca84c32877
@ -30,6 +30,8 @@ function Cursor()
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.last_pos = {x:0,y:0}
|
||||||
|
|
||||||
this.move = function(e)
|
this.move = function(e)
|
||||||
{
|
{
|
||||||
this.pos = this.pos_from_event(e)
|
this.pos = this.pos_from_event(e)
|
||||||
@ -39,16 +41,21 @@ function Cursor()
|
|||||||
this.translate(null,this.pos)
|
this.translate(null,this.pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.last_pos.x != this.pos.x || this.last_pos.y != this.pos.y){
|
||||||
dotgrid.guide.refresh();
|
dotgrid.guide.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
dotgrid.interface.refresh();
|
dotgrid.interface.refresh();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
this.last_pos = this.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.up = function(e)
|
this.up = function(e)
|
||||||
{
|
{
|
||||||
this.pos = this.pos_from_event(e)
|
this.pos = this.pos_from_event(e)
|
||||||
|
|
||||||
if(e.altKey){ dotgrid.tool.remove_segments_at(this.pos); return; }
|
if(e.altKey){ dotgrid.tool.remove_segments_at(this.pos); this.translate(); return; }
|
||||||
|
|
||||||
// Translation
|
// Translation
|
||||||
if(this.translation){
|
if(this.translation){
|
||||||
|
@ -16,8 +16,9 @@ function Guide()
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refresh = function()
|
this.refresh = function(force = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.clear();
|
this.clear();
|
||||||
|
|
||||||
if(dotgrid.tool.index == 2){ this.draw_markers() ; this.draw_vertices() }
|
if(dotgrid.tool.index == 2){ this.draw_markers() ; this.draw_vertices() }
|
||||||
@ -89,6 +90,7 @@ function Guide()
|
|||||||
var color = is_step ? dotgrid.theme.active.f_med : dotgrid.theme.active.f_low;
|
var color = is_step ? dotgrid.theme.active.f_med : dotgrid.theme.active.f_low;
|
||||||
if((y == 0 || y == dotgrid.grid_y) && cursor.x == x+1){ color = dotgrid.theme.active.f_high; }
|
if((y == 0 || y == dotgrid.grid_y) && cursor.x == x+1){ color = dotgrid.theme.active.f_high; }
|
||||||
else if((x == 0 || x == dotgrid.grid_x-1) && cursor.y == y+1){ color = dotgrid.theme.active.f_high; }
|
else if((x == 0 || x == dotgrid.grid_x-1) && cursor.y == y+1){ color = dotgrid.theme.active.f_high; }
|
||||||
|
else if(cursor.x == x+1 && cursor.y == y+1){ color = dotgrid.theme.active.f_high; }
|
||||||
|
|
||||||
this.draw_marker({
|
this.draw_marker({
|
||||||
x:parseInt(x * dotgrid.grid_width) + dotgrid.grid_width,
|
x:parseInt(x * dotgrid.grid_width) + dotgrid.grid_width,
|
||||||
@ -98,6 +100,17 @@ function Guide()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.draw_marker = function(pos,radius = 1,color)
|
||||||
|
{
|
||||||
|
var ctx = this.el.getContext('2d');
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.arc(pos.x * this.scale, pos.y * this.scale, radius, 0, 2 * Math.PI, false);
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
ctx.fill();
|
||||||
|
ctx.closePath();
|
||||||
|
}
|
||||||
|
|
||||||
this.draw_vertex = function(pos, radius = 5)
|
this.draw_vertex = function(pos, radius = 5)
|
||||||
{
|
{
|
||||||
var ctx = this.el.getContext('2d');
|
var ctx = this.el.getContext('2d');
|
||||||
@ -136,17 +149,6 @@ function Guide()
|
|||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.draw_marker = function(pos,radius = 1,color)
|
|
||||||
{
|
|
||||||
var ctx = this.el.getContext('2d');
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.lineWidth = 2;
|
|
||||||
ctx.arc(pos.x * this.scale, pos.y * this.scale, radius, 0, 2 * Math.PI, false);
|
|
||||||
ctx.fillStyle = color;
|
|
||||||
ctx.fill();
|
|
||||||
ctx.closePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.draw_path = function(path,style)
|
this.draw_path = function(path,style)
|
||||||
{
|
{
|
||||||
var ctx = this.el.getContext('2d');
|
var ctx = this.el.getContext('2d');
|
||||||
@ -193,9 +195,9 @@ function Guide()
|
|||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.lineWidth = 3;
|
ctx.lineWidth = 3;
|
||||||
ctx.lineCap = "round";
|
ctx.lineCap = "round";
|
||||||
ctx.arc(Math.abs(pos.x * -this.scale), Math.abs(pos.y * this.scale), 3, 0, 2 * Math.PI, false);
|
ctx.arc(Math.abs(pos.x * -this.scale), Math.abs(pos.y * this.scale), 5, 0, 2 * Math.PI, false);
|
||||||
ctx.fillStyle = dotgrid.theme.active.f_low;
|
ctx.strokeStyle = dotgrid.theme.active.background;
|
||||||
ctx.fill();
|
ctx.stroke();
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
@ -176,7 +176,7 @@ function Tool()
|
|||||||
this.style().fill = this.style().fill == "none" ? this.style().color : "none";
|
this.style().fill = this.style().fill == "none" ? this.style().color : "none";
|
||||||
}
|
}
|
||||||
else if(type == "thickness"){
|
else if(type == "thickness"){
|
||||||
this.style().thickness = clamp(this.style().thickness+mod,1,40);
|
this.style().thickness = clamp(this.style().thickness+mod,1,100);
|
||||||
}
|
}
|
||||||
else if(type == "mirror"){
|
else if(type == "mirror"){
|
||||||
this.style().mirror_style = this.style().mirror_style > 3 ? 0 : this.style().mirror_style+1;
|
this.style().mirror_style = this.style().mirror_style > 3 ? 0 : this.style().mirror_style+1;
|
||||||
|
Loading…
Reference in New Issue
Block a user