Interactive PowerBasic Forum

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Graphics and Multimedia => GDI+ (GDI Plus) => Topic started by: José Roca on June 22, 2008, 04:41:13 AM

Title: GDI+: GdipAddPathArc
Post by: José Roca on June 22, 2008, 04:41:13 AM


The following example creates a GraphicsPath object path, adds an arc to path, closes the arc, and then draws path.

C++


VOID AddArcExample2(HDC hdc)
{
   Graphics graphics(hdc);

   GraphicsPath path;
   path.AddArc(20.0f, 20.0f, 50.0f, 100.0f, 0.0f, 180.0f);
   path.CloseFigure();
   
   // Draw the path.
   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawPath(&pen, &path);
}


PowerBASIC


SUB GDIP_AddPathArc (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)
   hStatus = GdipAddPathArc(pPath, 20, 20, 50, 100, 0, 180)
   hStatus = GdipClosePathFigure(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/GdipAddPathArc.png)