fixed bug when reaching stage 0

This commit is contained in:
juliandescottes 2012-09-07 00:56:31 +02:00
parent 17bf7b3807
commit 14bf3f97c5

View File

@ -3,7 +3,7 @@
ns.Frame = function (pixels) {
this.pixels = pixels;
this.previousStates = [pixels];
this.previousStates = [this._clonePixels()];
this.stateIndex = 0;
};
@ -56,7 +56,7 @@
};
ns.Frame.prototype.containsPixel = function (col, row) {
return col >= 0 && row >= 0 && col <= this.pixels.length && row <= this.pixels[0].length;
return col >= 0 && row >= 0 && col < this.pixels.length && row < this.pixels[0].length;
};
ns.Frame.prototype.saveState = function () {
@ -69,10 +69,10 @@
};
ns.Frame.prototype.loadPreviousState = function () {
if (this.stateIndex >= 0) {
if (this.stateIndex > 0) {
this.stateIndex--;
this.pixels = this.previousStates[this.stateIndex];
}
}
};
ns.Frame.prototype.loadNextState = function () {