Correctly handle { x: 0, y: 0 } in Raster#getAverageColor()

Closes #1053
This commit is contained in:
Jürg Lehni 2016-05-27 11:42:08 +02:00
parent 9017bf1767
commit f07927a95e

View file

@ -501,12 +501,16 @@ var Raster = Item.extend(/** @lends Raster# */{
// TODO: How about rounding of bounds.size?
path = object;
bounds = object.getBounds();
} else if (object.width) {
bounds = new Rectangle(object);
} else if (object.x) {
// Create a rectangle of 1px size around the specified coordinates
bounds = new Rectangle(object.x - 0.5, object.y - 0.5, 1, 1);
} else if (typeof object === 'object') {
if ('width' in object) {
bounds = new Rectangle(object);
} else if ('x' in object) {
// Create a rectangle of 1px size around the specified point.
bounds = new Rectangle(object.x - 0.5, object.y - 0.5, 1, 1);
}
}
if (!bounds)
return null;
// Use a sample size of max 32 x 32 pixels, into which the path is
// scaled as a clipping path, and then the actual image is drawn in and
// sampled.