How to Draw "Doughnut" Polygons?

Hi all,

i have a number of polygons that i have to draw on the screen. Each polygon is represented by a number of points (x, y). If the points run clockwise, the inside of the polygon is to be filled. If the points run counter-clockwise, the inside of the polygon is to be "excluded".

What this means is, if i have a "counter-clockwise polygon" within a "clockwise polygon", i should end up with a "doughnut-like" polygon on screen.

How can i achieve this in .NET (C#)?

Firstly, i'm having problems detecting whether the points run clockwise or counter-clockwise.

Secondly, the relevant API (Graphics.FillPolygon) takes one polygon at a time. This means that i couldn't say "fill this first polygon but exclude the second one". (Filling the "clockwise polygon" and then filling the excluded "counter-clockwise polygon" with the original background is not a viable option either.)

One of the Graphics.FillPolygon overloads takes as an argument the FillMode, which does SEEM to be able to solve my first problem of whether the points run clockwise or counter (i.e. i should choose FillMode.Winding), however the problem remains that the method only "draws" one polygon at a time.

TIA and Regards,
Edwin

[1300 byte] By [edwin11] at [2007-12-23]
# 1
Why not create a single polygon from the 2 separate polygons and then call FillPolygon?
RabbiJosephGordon at 2007-8-30 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified