The following example creates a
path and adds two figures to that
path. The first figure has three arcs, and the second figure has two arcs. The arcs within a figure are connected by straight lines, but there is no connecting line between the last arc in the first figure and the first arc in the second figure.
C++
VOID StartFigureExample(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
Rect rect(0, 0, 100, 50);
GraphicsPath path;
path.AddArc(0, 0, 100, 50, 0.0f, 180.0f);
path.AddArc(0, 60, 100, 50, 0.0f, 180.0f);
path.AddArc(0, 120, 100, 50, 0.0f, 180.0f);
// Start a new figure (subpath).
// Do not close the current figure.
path.StartFigure();
path.AddArc(0, 180, 100, 50, 0.0f, 180.0f);
path.AddArc(0, 240, 100, 50, 0.0f, 180.0f);
graphics.DrawPath(&pen, &path);
}
PowerBASIC
SUB GDIP_StartPathFigure (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPath AS DWORD
LOCAL pPen AS DWORD
DIM pts(2) AS POINTF
hStatus = GdipCreateFromHDC(hdc, pGraphics)
hStatus = GdipCreatePath(%FillModeAlternate, pPath)
hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 255), 1, %UnitWorld, pPen)
hStatus = GdipAddPathArc(pPath, 0, 0, 100, 50, 0, 180)
hStatus = GdipAddPathArc(pPath, 0, 60, 100, 50, 0, 180)
hStatus = GdipAddPathArc(pPath, 0, 120, 100, 50, 0, 180)
' // Start a new figure (subpath).
' // Do not close the current figure.
hStatus = GdipStartPathFigure(pPath)
hStatus = GdipAddPathArc(pPath, 0, 180, 100, 50, 0, 180)
hStatus = GdipAddPathArc(pPath, 0, 240, 100, 50, 0, 180)
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/GdipStartPathFigure.png)