• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipFillPie

Started by José Roca, June 23, 2008, 05:30:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example defines a pie and then fills it.

C++


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

   // Create a SolidBrush object.
   SolidBrush blackBrush(Color(255, 0, 0, 0));

   // Define the pie shape.
   REAL x = 0.0f;
   REAL y = 2.0f;
   REAL width = 200.8f;
   REAL height = 100.1f;
   REAL startAngle = 0.0f;
   REAL sweepAngle = 45.7f;

   // Fill the pie.
   graphics.FillPie(&blackBrush, x, y, width, height, startAngle, sweepAngle);
}


PowerBASIC


SUB GDIP_FillPie (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pBrush AS DWORD
   LOCAL x AS SINGLE
   LOCAL y AS SINGLE
   LOCAL nWidth AS SINGLE
   LOCAL nHeight AS SINGLE
   LOCAL startAngle AS SINGLE
   LOCAL sweepAngle AS SINGLE

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a SolidBrush
   hStatus = GdipCreateSolidFill(GDIP_ARGB(255, 0, 0, 0), pBrush)

   ' // Define the pie shape.
   x = 0.0!
   y = 2.0!
   nWidth = 200.8!
   nHeight = 100.1!
   startAngle = 0.0!
   sweepAngle = 45.7!

   ' // Fill the pie.
   hStatus = GdipFillPie(pGraphics, pBrush, x, y, nWidth, nHeight, startAngle, sweepAngle)

   ' // Cleanup
   IF pBrush THEN GdipDeleteBrush(pBrush)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB