PathGradientBrush.GetCenterPoint(PointF*) method

Applies to: desktop apps only

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

Syntax

Status GetCenterPoint(
  [out]  PointF *point
);

Parameters

  • point [out]
    Type: PointF*

    Pointer to a PointF 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.

Remarks

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.

Examples

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 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.
   PointF centerPoint;
   pthGrBrush.GetCenterPoint(&centerPoint);

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

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdipluspath.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

PathGradientBrush

Color

PathGradientBrush::GetCenterColor

PathGradientBrush::SetCenterColor

PathGradientBrush::SetCenterPoint Methods

Creating a Path Gradient

Filling a Shape with a Color Gradient

Brushes and Filled Shapes

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012