Starting interface
This commit is contained in:
parent
fe6192c6bc
commit
6027918884
@ -4,7 +4,7 @@ function Cursor()
|
|||||||
this.translation = null,
|
this.translation = null,
|
||||||
|
|
||||||
this.translate = function(from = null,to = null, multi = false)
|
this.translate = function(from = null,to = null, multi = false)
|
||||||
{
|
{
|
||||||
if((from || to) && this.translation == null){ this.translation = {multi:multi}; console.log("Begin translation") }
|
if((from || to) && this.translation == null){ this.translation = {multi:multi}; console.log("Begin translation") }
|
||||||
|
|
||||||
if(from){ this.translation.from = from; }
|
if(from){ this.translation.from = from; }
|
||||||
@ -54,7 +54,7 @@ function Cursor()
|
|||||||
if(this.translation.multi){ dotgrid.tool.translate_multi(this.translation.from,this.translation.to); }
|
if(this.translation.multi){ dotgrid.tool.translate_multi(this.translation.from,this.translation.to); }
|
||||||
else{ dotgrid.tool.translate(this.translation.from,this.translation.to); }
|
else{ dotgrid.tool.translate(this.translation.from,this.translation.to); }
|
||||||
}
|
}
|
||||||
else{
|
else if(e.target.id == "guide"){
|
||||||
dotgrid.tool.add_vertex({x:this.pos.x,y:this.pos.y});
|
dotgrid.tool.add_vertex({x:this.pos.x,y:this.pos.y});
|
||||||
}
|
}
|
||||||
this.translate();
|
this.translate();
|
||||||
@ -93,7 +93,7 @@ function Cursor()
|
|||||||
{
|
{
|
||||||
var grid = dotgrid.tool.settings.size.width/dotgrid.grid_x;
|
var grid = dotgrid.tool.settings.size.width/dotgrid.grid_x;
|
||||||
return {
|
return {
|
||||||
x:clamp(step(pos.x,grid),grid,dotgrid.tool.settings.size.width+grid),
|
x:clamp(step(pos.x,grid),grid,dotgrid.tool.settings.size.width),
|
||||||
y:clamp(step(pos.y,grid),grid,dotgrid.tool.settings.size.height+grid)
|
y:clamp(step(pos.y,grid),grid,dotgrid.tool.settings.size.height+grid)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -34,14 +34,24 @@ function Interface()
|
|||||||
for(id in tools){
|
for(id in tools){
|
||||||
var tool = tools[id];
|
var tool = tools[id];
|
||||||
var shortcut = tool[2];
|
var shortcut = tool[2];
|
||||||
html += `<svg id="${id}" ar="${id}" title="${tool[0].capitalize()}" viewBox="0 0 300 300" class="icon"><path id="${id}_path" class="icon_path" d="${tool[1]}"/>${id == "depth" ? `<path class="icon_path inactive" d=""/>` : ""}<rect ar="${id}" width="300" height="300" opacity="0"><title>${id.capitalize()}${shortcut ? '('+shortcut+')' : ''}</title></rect></svg>`
|
html += `<svg id="${id}" ar="${id}" title="${tool[0].capitalize()}" onmousedown="dotgrid.interface.down('${id}')" onmouseover="dotgrid.interface.over('${id}')" viewBox="0 0 300 300" class="icon"><path id="${id}_path" class="icon_path" d="${tool[1]}"/>${id == "depth" ? `<path class="icon_path inactive" d=""/>` : ""}<rect ar="${id}" width="300" height="300" opacity="0"><title>${id.capitalize()}${shortcut ? '('+shortcut+')' : ''}</title></rect></svg>`
|
||||||
}
|
}
|
||||||
this.menu_el.innerHTML = html
|
this.menu_el.innerHTML = html
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.over = function(id)
|
||||||
|
{
|
||||||
|
console.log("over",id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.down = function(id)
|
||||||
|
{
|
||||||
|
console.log("click",id)
|
||||||
|
}
|
||||||
|
|
||||||
this.prev_operation = null;
|
this.prev_operation = null;
|
||||||
|
|
||||||
this.refresh = function(force = false)
|
this.refresh = function(force = false,id)
|
||||||
{
|
{
|
||||||
if(this.prev_operation == dotgrid.cursor.operation && force == false){ return; }
|
if(this.prev_operation == dotgrid.cursor.operation && force == false){ return; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user