mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -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?
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue