Added clear method to pskl.model.Frame

This commit is contained in:
juliandescottes 2012-09-10 23:32:34 +02:00
parent 99e9cf8856
commit feadca9d1f
2 changed files with 13 additions and 5 deletions

View File

@ -210,8 +210,4 @@
this.overlayRenderer.render(this.overlayFrame); this.overlayRenderer.render(this.overlayFrame);
} }
}; };
ns.DrawingController.prototype.clearOverlay = function () {
this.overlayFrame = pskl.model.Frame.createEmptyFromFrame(this.frame);
};
})(); })();

View File

@ -8,6 +8,11 @@
}; };
ns.Frame.createEmpty = function (width, height) { ns.Frame.createEmpty = function (width, height) {
var pixels = ns.Frame.createEmptyPixelGrid_(width, height);
return new ns.Frame(pixels);
};
ns.Frame.createEmptyPixelGrid_ = function (width, height) {
var pixels = []; //new Array(width); var pixels = []; //new Array(width);
for (var columnIndex=0; columnIndex < width; columnIndex++) { for (var columnIndex=0; columnIndex < width; columnIndex++) {
var columnArray = []; var columnArray = [];
@ -16,7 +21,7 @@
} }
pixels[columnIndex] = columnArray; pixels[columnIndex] = columnArray;
} }
return new ns.Frame(pixels); return pixels;
}; };
ns.Frame.createEmptyFromFrame = function (frame) { ns.Frame.createEmptyFromFrame = function (frame) {
@ -41,6 +46,13 @@
this.pixels = this.clonePixels_(pixels); this.pixels = this.clonePixels_(pixels);
}; };
ns.Frame.prototype.clear = function () {
var pixels = ns.Frame.createEmptyPixelGrid_(this.getWidth(), this.getHeight());
this.setPixels(pixels);
};
/** /**
* Clone a set of pixels. Should be static utility method * Clone a set of pixels. Should be static utility method
* @private * @private