Improved new file/history
This commit is contained in:
parent
a440752f73
commit
e98978249c
@ -193,9 +193,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
|
||||
this.new = function()
|
||||
{
|
||||
dotgrid.segments = [];
|
||||
dotgrid.history.push(dotgrid.segments)
|
||||
dotgrid.draw();
|
||||
dotgrid.clear();
|
||||
}
|
||||
|
||||
this.save = function()
|
||||
@ -663,6 +661,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y,thickness = 3,lineca
|
||||
|
||||
this.clear = function()
|
||||
{
|
||||
this.history.clear();
|
||||
this.reset();
|
||||
this.segments = [];
|
||||
this.thickness = 10
|
||||
|
@ -3,6 +3,12 @@ function History()
|
||||
this.index = 0;
|
||||
this.a = [];
|
||||
|
||||
this.clear = function()
|
||||
{
|
||||
this.a = [];
|
||||
this.index = 0;
|
||||
}
|
||||
|
||||
this.push = function(data)
|
||||
{
|
||||
if(this.index < this.a.length-1){
|
||||
@ -35,6 +41,6 @@ function History()
|
||||
return copy(this.a[this.index]);
|
||||
}
|
||||
|
||||
function copy(data){ return data.slice(0); }
|
||||
function copy(data){ return data ? data.slice(0) : []; }
|
||||
function clamp(v, min, max) { return v < min ? min : v > max ? max : v; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user