The following example creates a
GraphicsPath object
path, adds two figures to
path (arcs), closes all figures, and then draws
path.
C++
VOID Example_CloseAllFigures(HDC hdc)
{
Graphics graphics(hdc);
Rect rect1(20, 20, 50, 100);
Rect rect2(40, 40, 50, 100);
GraphicsPath path;
path.AddArc(rect1, 0.0f, 180.0f); // first figure
path.StartFigure();
path.AddArc(rect2, 0.0f, 180.0f); // second figure
path.CloseAllFigures();
// Draw the path.
Pen pen(Color(255, 255, 0, 0));
graphics.DrawPath(&pen, &path);
}
PowerBASIC
SUB GDIP_ClosePathFigures (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPath AS DWORD
LOCAL pPen AS DWORD
hStatus = GdipCreateFromHDC(hdc, pGraphics)
hStatus = GdipCreatePath(%FillModeAlternate, pPath)
' // First figure
hStatus = GdipAddPathArc(pPath, 20, 20, 50, 100, 0, 180)
hStatus = GdipStartPathFigure(pPath)
' // Second figure
hStatus = GdipAddPathArc(pPath, 40, 40, 50, 100, 0, 180)
hStatus = GdipClosePathFigures(pPath)
' // Draw the path.
hStatus = GdipCreatePen1(GDIP_ARGB(255, 255, 0, 0), 1, %UnitWorld, pPen)
hStatus = GdipDrawPath(pGraphics, pPen, pPath)
' // Cleanup
IF pPen THEN GdipDeletePen(pPen)
IF pPath THEN GdipDeletePath(pPath)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipClosePathFigures.png)