Divided export options
This commit is contained in:
parent
b6a1cf703c
commit
d1fad873c7
@ -35,7 +35,9 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
|
|||||||
|
|
||||||
this.controller.add("default","File","New",() => { dotgrid.new(); },"CmdOrCtrl+N");
|
this.controller.add("default","File","New",() => { dotgrid.new(); },"CmdOrCtrl+N");
|
||||||
this.controller.add("default","File","Open",() => { dotgrid.open(); },"CmdOrCtrl+O");
|
this.controller.add("default","File","Open",() => { dotgrid.open(); },"CmdOrCtrl+O");
|
||||||
this.controller.add("default","File","Save",() => { dotgrid.save(); },"CmdOrCtrl+S");
|
this.controller.add("default","File","Save(.grid)",() => { dotgrid.save(); },"CmdOrCtrl+S");
|
||||||
|
this.controller.add("default","File","Render(.png)",() => { dotgrid.render(); },"CmdOrCtrl+R");
|
||||||
|
this.controller.add("default","File","Export(.svg)",() => { dotgrid.export(); },"CmdOrCtrl+E");
|
||||||
|
|
||||||
this.controller.add("default","Edit","Copy",() => { document.execCommand('copy'); },"CmdOrCtrl+C");
|
this.controller.add("default","Edit","Copy",() => { document.execCommand('copy'); },"CmdOrCtrl+C");
|
||||||
this.controller.add("default","Edit","Cut",() => { document.execCommand('cut'); },"CmdOrCtrl+X");
|
this.controller.add("default","Edit","Cut",() => { document.execCommand('cut'); },"CmdOrCtrl+X");
|
||||||
@ -120,19 +122,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
|
|||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.save = function()
|
|
||||||
{
|
|
||||||
dotgrid.guide.refresh();
|
|
||||||
|
|
||||||
dialog.showSaveDialog((fileName) => {
|
|
||||||
if (fileName === undefined){ return; }
|
|
||||||
fs.writeFile(fileName+".svg", dotgrid.render.to_svg());
|
|
||||||
fs.writeFile(fileName+'.png', dotgrid.render.to_png());
|
|
||||||
fs.writeFile(fileName+'.grid', dotgrid.tool.export());
|
|
||||||
dotgrid.guide.refresh()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.open = function()
|
this.open = function()
|
||||||
{
|
{
|
||||||
var paths = dialog.showOpenDialog({properties: ['openFile'],filters:[{name:"Dotgrid Image",extensions:["dot","grid"]}]});
|
var paths = dialog.showOpenDialog({properties: ['openFile'],filters:[{name:"Dotgrid Image",extensions:["dot","grid"]}]});
|
||||||
@ -146,6 +135,39 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.save = function()
|
||||||
|
{
|
||||||
|
dotgrid.guide.refresh();
|
||||||
|
|
||||||
|
dialog.showSaveDialog({title:"Save to .grid"},(fileName) => {
|
||||||
|
if (fileName === undefined){ return; }
|
||||||
|
fs.writeFile(fileName+'.grid', dotgrid.tool.export());
|
||||||
|
dotgrid.guide.refresh()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.render = function()
|
||||||
|
{
|
||||||
|
dotgrid.guide.refresh();
|
||||||
|
|
||||||
|
dialog.showSaveDialog({title:"Render to .png"},(fileName) => {
|
||||||
|
if (fileName === undefined){ return; }
|
||||||
|
fs.writeFile(fileName+'.png', dotgrid.render.to_png());
|
||||||
|
dotgrid.guide.refresh()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.export = function()
|
||||||
|
{
|
||||||
|
dotgrid.guide.refresh();
|
||||||
|
|
||||||
|
dialog.showSaveDialog({title:"Exoprt to .svg"},(fileName) => {
|
||||||
|
if (fileName === undefined){ return; }
|
||||||
|
fs.writeFile(fileName+".svg", dotgrid.render.to_svg());
|
||||||
|
dotgrid.guide.refresh()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
|
|
||||||
this.mouse_down = function(e)
|
this.mouse_down = function(e)
|
||||||
|
@ -62,15 +62,9 @@ function Interface()
|
|||||||
document.getElementById("color").className.baseVal = "icon";
|
document.getElementById("color").className.baseVal = "icon";
|
||||||
|
|
||||||
// Mirror
|
// Mirror
|
||||||
if(dotgrid.tool.style().mirror_style == 0){
|
if(dotgrid.tool.style().mirror_style == 0){ document.getElementById("mirror_path").setAttribute("d","M60,60 L60,60 L120,120 M180,180 L180,180 L240,240 M210,90 L210,90 L180,120 M120,180 L120,180 L90,210") }
|
||||||
document.getElementById("mirror_path").setAttribute("d","M60,60 L60,60 L120,120 M180,180 L180,180 L240,240 M210,90 L210,90 L180,120 M120,180 L120,180 L90,210")
|
else if(dotgrid.tool.style().mirror_style == 1){ document.getElementById("mirror_path").setAttribute("d","M60,60 L240,240 M180,120 L210,90 M120,180 L90,210") }
|
||||||
}
|
else if(dotgrid.tool.style().mirror_style == 2){ document.getElementById("mirror_path").setAttribute("d","M210,90 L210,90 L90,210 M60,60 L60,60 L120,120 M180,180 L180,180 L240,240") }
|
||||||
else if(dotgrid.tool.style().mirror_style == 1){
|
|
||||||
document.getElementById("mirror_path").setAttribute("d","M60,60 L240,240 M180,120 L210,90 M120,180 L90,210")
|
|
||||||
}
|
|
||||||
else if(dotgrid.tool.style().mirror_style == 2){
|
|
||||||
document.getElementById("mirror_path").setAttribute("d","M210,90 L210,90 L90,210 M60,60 L60,60 L120,120 M180,180 L180,180 L240,240")
|
|
||||||
}
|
|
||||||
|
|
||||||
this.prev_operation = dotgrid.cursor.operation;
|
this.prev_operation = dotgrid.cursor.operation;
|
||||||
}
|
}
|
||||||
|
@ -30,18 +30,21 @@ function Tool()
|
|||||||
{
|
{
|
||||||
this.vertices = [];
|
this.vertices = [];
|
||||||
dotgrid.guide.refresh();
|
dotgrid.guide.refresh();
|
||||||
|
dotgrid.interface.refresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.undo = function()
|
this.undo = function()
|
||||||
{
|
{
|
||||||
this.layers = dotgrid.history.prev();
|
this.layers = dotgrid.history.prev();
|
||||||
dotgrid.guide.refresh();
|
dotgrid.guide.refresh();
|
||||||
|
dotgrid.interface.refresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.redo = function()
|
this.redo = function()
|
||||||
{
|
{
|
||||||
this.layers = dotgrid.history.next();
|
this.layers = dotgrid.history.next();
|
||||||
dotgrid.guide.refresh();
|
dotgrid.guide.refresh();
|
||||||
|
dotgrid.interface.refresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// I/O
|
// I/O
|
||||||
@ -57,6 +60,7 @@ function Tool()
|
|||||||
dotgrid.history.push(this.layers);
|
dotgrid.history.push(this.layers);
|
||||||
this.clear();
|
this.clear();
|
||||||
dotgrid.guide.refresh();
|
dotgrid.guide.refresh();
|
||||||
|
dotgrid.interface.refresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.replace = function(dot)
|
this.replace = function(dot)
|
||||||
@ -73,6 +77,7 @@ function Tool()
|
|||||||
|
|
||||||
this.clear();
|
this.clear();
|
||||||
dotgrid.guide.refresh();
|
dotgrid.guide.refresh();
|
||||||
|
dotgrid.interface.refresh(true);
|
||||||
dotgrid.history.push(this.layers);
|
dotgrid.history.push(this.layers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +90,7 @@ function Tool()
|
|||||||
this.layer().pop();
|
this.layer().pop();
|
||||||
this.clear();
|
this.clear();
|
||||||
dotgrid.guide.refresh();
|
dotgrid.guide.refresh();
|
||||||
|
dotgrid.interface.refresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.remove_segments_at = function(pos)
|
this.remove_segments_at = function(pos)
|
||||||
@ -103,12 +109,14 @@ function Tool()
|
|||||||
}
|
}
|
||||||
this.clear();
|
this.clear();
|
||||||
dotgrid.guide.refresh();
|
dotgrid.guide.refresh();
|
||||||
|
dotgrid.interface.refresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.add_vertex = function(pos)
|
this.add_vertex = function(pos)
|
||||||
{
|
{
|
||||||
pos = {x:Math.abs(pos.x),y:Math.abs(pos.y)}
|
pos = {x:Math.abs(pos.x),y:Math.abs(pos.y)}
|
||||||
this.vertices.push(pos);
|
this.vertices.push(pos);
|
||||||
|
dotgrid.interface.refresh(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.vertex_at = function(pos)
|
this.vertex_at = function(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user