The following example defines a polygon and fills it.
C++
VOID Example_FillPolygon4(HDC hdc)
{
Graphics graphics(hdc);
// Create a SolidBrush object.
SolidBrush blackBrush(Color(255, 0, 0, 0));
// Create an array of PointF objects that define the polygon.
PointF point1(100.0f, 100.0f);
PointF point2(200.0f, 130.0f);
PointF point3(150.0f, 200.0);
PointF point4(50.0f, 200.0f);
PointF point5(0.0f, 130.0f);
PointF points[5] = {point1, point2, point3, point4, point5};
// Fill the polygon.
graphics.FillPolygon(&blackBrush, points, 5, FillModeAlternate);
}
PowerBASIC
SUB GDIP_FillPolygon (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pBrush AS DWORD
DIM pt(4) AS POINTF
hStatus = GdipCreateFromHDC(hdc, pGraphics)
' // Create a SolidBrush
hStatus = GdipCreateSolidFill(GDIP_ARGB(255, 0, 0, 0), pBrush)
' // Create an array of PointF objects that define the polygon.
pt(0).x = 100.0! : pt(0).y = 100.0!
pt(1).x = 150.0! : pt(1).y = 130.0!
pt(2).x = 150.0! : pt(2).y = 200.0!
pt(3).x = 50.0! : pt(3).y = 200.0!
pt(4).x = 0.0! : pt(4).y = 130.0!
' // Fill the polygon.
hStatus = GdipFillPolygon(pGraphics, pBrush, pt(0), 5, %FillModeAlternate)
' // Cleanup
IF pBrush THEN GdipDeleteBrush(pBrush)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipFillPolygon.png)