From 3f0a45a7c21e66c01f383ae211243fa112600c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 5 Mar 2011 14:17:32 +0000 Subject: [PATCH] Allow Rasters to be created directly from id strings. --- src/item/Raster.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/item/Raster.js b/src/item/Raster.js index d143a8e0..5ff1013f 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -8,6 +8,9 @@ var Raster = this.Raster = Item.extend({ if (object.getContext) { this.setCanvas(object); } else { + // If it's a string, get the element with this id first. + if (typeof object == 'string') + object = document.getElementById(object); this.setImage(object); } this.matrix = new Matrix(); @@ -108,7 +111,7 @@ var Raster = this.Raster = Item.extend({ var canvas = CanvasProvider.getCanvas(rectangle.getSize()); var context = canvas.getContext('2d'); context.drawImage(this.getCanvas(), rectangle.x, rectangle.y, - canvas.width, canvas.height, 0, 0, canvas.width, canvas.height); + canvas.width, canvas.height, 0, 0, canvas.width, canvas.height); return canvas; },