Allow Rasters to be created directly from id strings.

This commit is contained in:
Jürg Lehni 2011-03-05 14:17:32 +00:00
parent 8e25a951bc
commit 3f0a45a7c2

View file

@ -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;
},