PathGradientBrush::GetCenterPoint method

The PathGradientBrush::GetCenterPoint method gets the center point of this path gradient brush.


Status GetCenterPoint(
  OUT Point *point



Type: Point*

Pointer to a Point object that receives the center point.

Return Value

Type: Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.


By default, the center point of a PathGradientBrush object is at the centroid of the brush's boundary path, but you can set the center point to any location, inside or outside the path, by calling the SetCenterPoint method of the PathGradientBrush object.


The following example demonstrates several methods of the PathGradientBrush class including PathGradientBrush::GetCenterPoint and PathGradientBrush::SetCenterColor. The code creates a PathGradientBrush object and then sets the brush's center color and boundary color. The code calls the PathGradientBrush::GetCenterPoint method to determine the center point of the path gradient brush and then draws a line from the origin to that center point.

VOID Example_GetCenterPoint(HDC hdc)
   Graphics graphics(hdc);

   // Create a path that consists of a single ellipse.
   GraphicsPath path;
   path.AddEllipse(0, 0, 200, 100);

   // Use the path to construct a brush.
   PathGradientBrush pthGrBrush(&path);

   // Set the color at the center of the path to blue.
   pthGrBrush.SetCenterColor(Color(255, 0, 0, 255));

   // Set the color along the entire boundary of the path to aqua.
   Color colors[] = {Color(255, 0, 255, 255)};
   INT count = 1;
   pthGrBrush.SetSurroundColors(colors, &count);

   // Fill the ellipse with the path gradient brush.
   graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);

   // Obtain information about the path gradient brush.
   Point  centerPoint;

   // Draw a line from the origin to the center of the ellipse.
   Pen pen(Color(255, 0, 255, 0));
   graphics.DrawLine(&pen, Point(0, 0), centerPoint);


Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdipluspath.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See Also

Brushes and Filled Shapes


Creating a Path Gradient

Filling a Shape with a Color Gradient




PathGradientBrush::SetCenterPoint Methods