I'm trying to make a function that, given floating point coordinates/arguments, returns the area of a shape within a given pixel. The purpose is drawing anti-aliased shapes for a game's UI.
I know how to do rectangles, as it is very simple, but other shapes (ellipses, triangles, non-regular polygons, etc.) are a bit harder.
So, given a set of points for a polygon, if I loop through the shape on a grid with a cell size of 1x1, I want the area of the shape within said cell.
What about circles/ellipsoids?
Picture example: Pixel in Circle
What is the area of the circle within the bounds of the red pixel, given the pixel coordinates, circle coordinates, and circle radius?
Better example: Zoomed Pixel in Circle
What is the area of the white within the non-shaded area, given the four coordinates of the shaded area, coordinate of circle, and radius of circle?
What about with any polygon, regular or irregular, given a list of coordinates, and a coordinate to find the area within?
What I mean by the checking coordinate is, area within given-coordinate-to-check -> given-coordinate-to-check+1
Sorry if my question is confusing!
To restate the question more clearly, what is the area of a square-shaped shaded region on any possible geometric shape?