I have an image and a convex polygon defined by an array of x,y coordinates.
How would I go about getting a sprite (or a Texture2D) representation of the part of an image encompassed by a polygon?
I know cocos2d's atlas sprite manager can grab a rectangular shape from an image, but I'm having serious difficulty finding a way to get a sprite ( or Texture2D object) from a shape with more than four vertices.
Basically I just need a texture from the image with the part outside the polygon made transparent*.
If the resultant texture were also clipped to the width and height of the polygon I'd do backflips.
Any pointers/snippets would be appreciated. Thank you!
*(These polygons will vary so I'm trying to come up with a function that can be passed the vertex arrray defining the shape I want to grab from the image.)