Skip to main content

[JAVA2D] Drawing complex polygons over images

1 reply [Last post]
Anonymous

Hi, I'm drawing a filled polygon over a bitmap, and the polygon has a
hole in the center. It's really two nested polygons, but I'd like to
somehow have java2d obey an even-odd winding rule to not fill in the
internal polygon.

I can't just draw the outer, then draw the inner with the original
color, because that would cover up the bitmap that I want to show
through the center.

What's the most efficient way to draw this complex polygon in Java2D?

thanks!

-Jim

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kevin Weiner

No problem. See the GeneralPath and Area APIs. GP sounds like
what you need in this case. Create a GeneralPath from the first
shape, and append the second. The default winding rule should do
what you want. Or consider Area if you have specific constructive
geometry needs.

James Carroll wrote:
>
> Hi, I’m drawing a filled polygon over a bitmap, and the polygon has a
> hole in the center. It’s really two nested polygons, but I’d like to
> somehow have java2d obey an even-odd winding rule to not fill in the
> internal polygon.
>
> I can’t just draw the outer, then draw the inner with the original
> color, because that would cover up the bitmap that I want to show
> through the center.
>
> What’s the most efficient way to draw this complex polygon in Java2D?

---------------------------------------------------------------------
Kevin Weiner FM Software 610-997-3930 http://www.fmsware.com

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".