'How to get average color from pixels within polygon?
I have canvas object, and within it some image.
I also do have polygons defined as arrays of vertices, for example:
[ {x:50, y:50}, {x:50, y:150}, {x:200, y:100} ]
This is very simple polygon, some will be more complicated (currently the max is 10 points).
I'd like to either find a way to enumerate all pixels within the polygon, or just find average color of it.
Is there any library to do it? Or some clever algorithm?
As for comment re: getting image data by pixel - I know how to get color of a pixel. But what about getting it for all pixels within polygon?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
