PathGradientBrush::SetCenterPoint(constPointF&) method (gdipluspath.h)

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(
  const PointF & point
);

Parameters

point

Reference to a PointF object that specifies the center point.

Return value

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

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

Requirement Value
Header gdipluspath.h

See also

Brushes and Filled Shapes

Creating a Path Gradient

Filling a Shape with a Color Gradient

GraphicsPath

PathGradientBrush

PathGradientBrush::GetCenterColor

PathGradientBrush::GetCenterPoint Methods

PathGradientBrush::SetCenterColor