Fix bugs in Raster#getAverageColor.

This commit is contained in:
Jonathan Puckey 2011-05-15 14:13:47 +02:00
parent 2c36f3a62e
commit 3f8f539aeb

View file

@ -247,7 +247,7 @@ var Raster = this.Raster = Item.extend({
var image;
if (object) {
var bounds, path;
if (object instanceof Path) {
if (object instanceof PathItem) {
// TODO: what if the path is smaller than 1 px?
// TODO: how about rounding of bounds.size?
// TODO: test with compound paths.
@ -266,14 +266,11 @@ var Raster = this.Raster = Item.extend({
ctx.translate(delta.x, delta.y);
if (path) {
var style = object.getStyle();
path.draw(ctx);
path.draw(ctx, {});
ctx.clip();
path.setStyle(style);
}
var matrix = this.matrix.clone(),
transMatrix = Matrix.getTranslateInstance(delta);
matrix.preConcatenate(transMatrix);
matrix.applyToContext(ctx);
this.matrix.applyToContext(ctx);
ctx.drawImage(this._canvas || this._image,
-this._size.width / 2, -this._size.height / 2);
image = canvas;