• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipReversePath

Started by José Roca, June 22, 2008, 06:00:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca


The following example creates a GraphicsPath object path, adds two lines to path, calls the GdipReversePath function, and then draws path.

C++


VOID ReverseExample(HDC hdc)
{
   Graphics graphics(hdc);
   GraphicsPath path;

   // Set up and call Reverse.
   Point pts[] = {Point(10, 60),
                  Point(50, 110),
                  Point(90, 60)};
   path.AddLines(pts, 3);
   path.Reverse();

   // Draw the path.
   graphics.DrawPath(&Pen(Color(128, 255, 0, 0), 2), &path);
}


PowerBASIC


SUB GDIP_ReversePath (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)

   ' // Set up and call Reverse.
   pts(0).x = 10 : pts(0).y = 60
   pts(1).x = 50 : pts(1).y = 110
   pts(2).x = 90 : pts(2).y = 60
   hStatus = GdipAddPathLine2(pPath, pts(0), 3)
   hStatus = GdipReversePath(pPath)
   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