Raster = Item.extend({
	beans: true,

	// TODO: implement url / type, width, height
	// TODO: have PlacedSymbol & Raster inherit from a shared class?
	// TODO: draw image directly onto a canvas, so we can use drawImage / setPixel
	// or wait for user to call such a function and only then do so?
	initialize: function(image) {
		this.base();
		if(image) {
			this.image = image;
			var width = image.width;
			var height = image.height;
			this.size = new Size(width, height);
			this._bounds = new Rectangle(-width / 2, -height / 2, width, height);
			this.matrix = new Matrix();
		}
	},
	
	// TODO: getSize / setSize
	
	/**
	 * The width of the raster in pixels.
	 */
	getWidth: function() {
		return this.size.width;
	},
	
	/**
	 * The height of the raster in pixels.
	 */
	getHeight: function() {
		return this.size.height;
	},
	
	// TODO: getPpi
	// TODO: getSubImage
	// TODO: getImage
	// TODO: drawImage
	
	// TODO: support getAverageColor paramaters: point, rect, path
	// TODO: Idea for path: draw the path, then draw the image on top
	// with globalCompositeOperation = 'xor' - then resize and count
	// values.
	getAverageColor: function() {
		var size = 32;
		var tempCanvas = CanvasProvider.getCanvas(size, size);
		var ctx = tempCanvas.getContext('2d');
		ctx.drawImage(this.image, 0, 0, size, size);
		var pixels = ctx.getImageData(0.5, 0.5, size, size).data;
		var rgba = [0, 0, 0];
		
		for(var i = 0; i < size; i++) {
			var offset = i * size;
			var alpha = pixels[offset + 3] / 255;
			rgba[0] += pixels[offset] * alpha;
			rgba[1] += pixels[offset + 1] * alpha;
			rgba[2] += pixels[offset + 2] * alpha;
		}
		
		for(var i = 0; i < 3; i++)
			rgba[i] = rgba[i] / (size * 255);
		
		CanvasProvider.returnCanvas(tempCanvas);
		return Color.read(rgba);
	},
	
	// TODO: getPixel(point)
	// TODO: test this
	getPixel: function(x, y) {
		var channels = ctx.getImageData(x + 0.5, y + 0.5, 1, 1).data;
		return Color.read(channels);
	},
	
	// TODO: setPixel(point, color)
	// setPixel: function(x, y, color) {
	// 	
	// }
	
	transformContent: function(matrix, flags) {
		var bounds = this.bounds;
		var coords = [bounds.x, bounds.y,
			bounds.x + bounds.width, bounds.y + bounds.height];
		matrix.transform(coords, 0, coords, 0, 2);
		this.matrix.preConcatenate(matrix);
		bounds.x = coords[0];
		bounds.y = coords[1];
		bounds.width = coords[2] - coords[0];
		bounds.height = coords[3] - coords[1];
	},
	
	getBounds: function() {
		return this._bounds;
	},
	
	draw: function(ctx) {
		ctx.save();
		var matrix = this.matrix;
		ctx.setTransform(
			matrix._m00, matrix._m01, matrix._m10,
			matrix._m11, matrix._m02, matrix._m12
		);
		var image = this.image;
		ctx.drawImage(this.image, -this.size.width / 2, -this.size.height / 2);
		ctx.restore();
	}
});
@@ -994,104 +994,148 @@
 for 
-path: draw the path, then draw the image on top%0A%09// with globalCompositeOperation = 'xor' - then
+getAverageColor(path): set globalCompositeOperation = 'xor',%0A%09// then fillRect with black, then draw the path, then draw the image, then%0A%09//
  res
@@ -1147,20 +1147,16 @@
 nd count
-%0A%09//
  values.

Update comments about implementing getAverageColor(path).