From 73a2f0f25686dffd3d65ca8e3f42f6d679ab5612 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sat, 21 May 2011 12:50:02 +0200 Subject: [PATCH] Implement Raster#clone. --- src/item/Raster.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/item/Raster.js b/src/item/Raster.js index ab9d047b..700ce12f 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -35,8 +35,16 @@ var Raster = this.Raster = Item.extend({ }, clone: function() { - // TODO: Implement! - return this.base(); + var image = this._image; + if (!image) { + // If the Raster contains a Canvas object, we need to create + // a new one and draw this raster's canvas on it. + image = CanvasProvider.getCanvas(this._size); + image.getContext('2d').drawImage(this._canvas, 0, 0); + } + var raster = new Raster(image); + raster.matrix = this.matrix.clone(); + return raster; }, /**