0

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?

eijeze
  • 109
  • 1
  • You might want to be a little more specific... assuming you're working in a canvas? You'd fist have to obtain pixel data... see: https://stackoverflow.com/questions/667045/get-a-pixel-from-html-canvas – bob May 08 '22 at 00:15

0 Answers0