mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Correctly handle { x: 0, y: 0 } in Raster#getAverageColor()
Closes #1053
This commit is contained in:
parent
9017bf1767
commit
f07927a95e
1 changed files with 9 additions and 5 deletions
|
@ -501,12 +501,16 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
// TODO: How about rounding of bounds.size?
|
// TODO: How about rounding of bounds.size?
|
||||||
path = object;
|
path = object;
|
||||||
bounds = object.getBounds();
|
bounds = object.getBounds();
|
||||||
} else if (object.width) {
|
} else if (typeof object === 'object') {
|
||||||
bounds = new Rectangle(object);
|
if ('width' in object) {
|
||||||
} else if (object.x) {
|
bounds = new Rectangle(object);
|
||||||
// Create a rectangle of 1px size around the specified coordinates
|
} else if ('x' in object) {
|
||||||
bounds = new Rectangle(object.x - 0.5, object.y - 0.5, 1, 1);
|
// 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
|
// 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
|
// scaled as a clipping path, and then the actual image is drawn in and
|
||||||
// sampled.
|
// sampled.
|
||||||
|
|
Loading…
Reference in a new issue