If I have a QuadCurve like this (+ = node):
+ +
\ ./
+--⁻⁻
And I fill it in Java 2D the result is something like this: (x = colored)
+xxxxxxxxx+
\xxxxxx./
+--⁻⁻
But I want to color the other side:
+ +
x\ ./x
xxx +--⁻⁻xx
xxxxxxxxxxx
This succeeds by drawing a rectangle around the curve in the color I want to color the other side and then fill the curve with the background color.
But this isn’t good enough to fill a convex rounded (based on QuadCurves) polygon. In case of some coordinates for the rectangles (as explained in the trick I used) overlap other pieces of the polygon. Here are two images (the green area is my polygon):
alt text http://img204.imageshack.us/img204/7823/convexpolygon.png alt text http://img708.imageshack.us/img708/3669/convexpolygon2.png
So, the question is simple: “How can I color a shape build of curves?”
But to the answer will not be simple I think…
Any advice would be VERY VERY appreciated.
Thanks in advance.
Maybe I’m going to make a bounty for this question if I don’t get an answer
Pick a point known to be inside the Polygon.
Know the “boundary color” (in this case, black).
You can adapt this as necessary to suit your specific needs.
This works for any fill for a completely bounded shape. You’ll also want to incorporate special conditions (edges of the picture, for example).