PathGradientBrush.SetCenterPoint(const PointF) method

Applies to: desktop apps only

The PathGradientBrush::SetCenterPoint method sets the center point of this path gradient brush. By default, the center point 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.

Syntax

Status SetCenterPoint(
  [in, ref]  const PointF &point
);

Parameters

  • point [in, ref]
    Type: const PointF

    Reference to a PointF object that specifies 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.

Examples

The following example creates a PathGradientBrush object based on an ellipse. The code sets the center color to blue and sets the color along the boundary to aqua. By default, the center point would be at the center of the ellipse (100, 50), but the call to the PathGradientBrush::SetCenterPoint method sets the center point to (180.5, 50.0).

VOID Example_SetCenter(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 center point.
   pthGrBrush.SetCenterPoint(PointF(180.5f, 50.0f));

   // 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);

   graphics.FillRectangle(&pthGrBrush, 0, 0, 300, 300); 
}

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

PathGradientBrush::GetCenterColor

PathGradientBrush::GetCenterPoint Methods

GraphicsPath

PathGradientBrush::SetCenterColor

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