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 23, 2008, 05:00:20 AM

Title: GDI+: GdipDrawArc
Post by: José Roca on June 23, 2008, 05:00:20 AM


The following example draws a 90-degree arc.

C++


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

   // Set up the arc.
   Pen redPen(Color(255, 255, 0, 0), 3);
   REAL x = 0;
   REAL y = 0;
   REAL width = 200.0f;
   REAL height = 100.0f;
   REAL startAngle = 0.0f;
   REAL sweepAngle = 90.0f;

   // Draw the arc.
   graphics.DrawArc(&redPen, x, y, width, height, startAngle, sweepAngle);
}


PowerBASIC


SUB GDIP_DrawArc (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pPen AS DWORD

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a red Pen
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 255, 0, 0), 1.0!, %UnitWorld, pPen)

   ' // Draw the arc
   hStatus = GdipDrawArc(pGraphics, pPen, 0, 0, 200, 100, 0, 90)

   ' // Cleanup
   IF pPen THEN GdipDeletePen(pPen)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB


(http://www.jose.it-berater.org/captures/GdipDrawArc.png)