From feadca9d1f4e81eb602d85fcac741bd07feafe0c Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Mon, 10 Sep 2012 23:32:34 +0200 Subject: [PATCH] Added clear method to pskl.model.Frame --- js/controller/DrawingController.js | 4 ---- js/model/Frame.js | 14 +++++++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/js/controller/DrawingController.js b/js/controller/DrawingController.js index 1e62ee61..e77e4e85 100644 --- a/js/controller/DrawingController.js +++ b/js/controller/DrawingController.js @@ -210,8 +210,4 @@ this.overlayRenderer.render(this.overlayFrame); } }; - - ns.DrawingController.prototype.clearOverlay = function () { - this.overlayFrame = pskl.model.Frame.createEmptyFromFrame(this.frame); - }; })(); \ No newline at end of file diff --git a/js/model/Frame.js b/js/model/Frame.js index b8c7a5eb..17652313 100644 --- a/js/model/Frame.js +++ b/js/model/Frame.js @@ -8,6 +8,11 @@ }; 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); for (var columnIndex=0; columnIndex < width; columnIndex++) { var columnArray = []; @@ -16,7 +21,7 @@ } pixels[columnIndex] = columnArray; } - return new ns.Frame(pixels); + return pixels; }; ns.Frame.createEmptyFromFrame = function (frame) { @@ -41,6 +46,13 @@ 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 * @private