• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipAddPathBezier

Started by José Roca, June 22, 2008, 04:46:23 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 a Bézier spline to path, closes the current figure (the only figure in this case), and then draws path.

C++


VOID Example_AddBezier(HDC hdc)
{
   Graphics graphics(hdc);
   GraphicsPath  path;
   
   path.AddBezier(50.0f, 50.0f, 60.0f, 20.0f, 70.0f, 100.0f, 80.0f, 50.0f);
   path.CloseFigure();
   
   // Draw the path.
   Pen pen(Color(255, 255, 0, 0));
   graphics.DrawPath(&pen, &path);
}


PowerBASIC


SUB GDIP_AddPathBezier (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 = GdipAddPathBezier(pPath, 50, 50, 60, 20, 70, 100, 80, 50)
   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




Documentation: GdipAddPathBezier