Improved copy/cut/paste

This commit is contained in:
Devine Lu Linvega
2018-02-07 19:44:18 +13:00
parent 6c8d6f2376
commit 7858abeca6
2 changed files with 30 additions and 12 deletions

View File

@@ -170,14 +170,14 @@ function Tool()
dotgrid.draw();
}
this.export = function()
this.export = function(target = this.layers)
{
return JSON.stringify(this.layers, null, 2);
return JSON.stringify(copy(target), null, 2);
}
this.import = function(layers)
this.import = function(layer)
{
this.layers = layers;
this.layers[this.index] = this.layers[this.index].concat(layer)
dotgrid.history.push(this.layers);
this.clear();
dotgrid.draw();
@@ -198,4 +198,6 @@ function Tool()
dotgrid.draw();
console.log(`layer:${this.index}`)
}
function copy(data){ return data ? JSON.parse(JSON.stringify(data)) : []; }
}