Refactored piskel controller to extract the event creation

This commit is contained in:
juliandescottes
2014-04-19 16:01:51 +02:00
parent b7e4deae00
commit d45ea00ca5
13 changed files with 234 additions and 117 deletions

View File

@@ -60,6 +60,7 @@
*/
ns.Frame.prototype.setPixels = function (pixels) {
this.pixels = this.clonePixels_(pixels);
this.s = null;
this.version++;
};
@@ -81,13 +82,19 @@
};
ns.Frame.prototype.getHash = function () {
if (!this.s) this.s = JSON.stringify(this.pixels);
return this.s;
return [this.id, this.version].join('-');
};
ns.Frame.prototype.setPixel = function (col, row, color) {
if (this.containsPixel(col, row)) {
this.pixels[col][row] = color;
this.version++;
var p = this.pixels[col][row];
if (p !== color) {
this.s = null;
this.pixels[col][row] = color;
this.version++;
}
}
};