PathGradientBrush::GetCenterColor method (gdipluspath.h)

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

Syntax

Status GetCenterColor(
  [out] Color *color
);

Parameters

[out] color

Type: Color*

Pointer to a Color object that receives the color of 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

By default, the center point of a PathGradientBrush object is 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 PathGradientBrush::SetCenterPoint Methods method of the PathGradientBrush object.

Examples

The following example creates a PathGradientBrush object and uses it to fill an ellipse. Then the code calls the PathGradientBrush::GetCenterColor method of the PathGradientBrush object to obtain the center color.

VOID Example_GetCenterColor(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.
   Color color;
   pthGrBrush.GetCenterColor(&color);

   // Fill a rectangle with the retrieved color.
   SolidBrush solidBrush(color);
   graphics.FillRectangle(&solidBrush, 0, 120, 200, 30);
}

Requirements

Requirement Value
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

Color

Creating a Path Gradient

Filling a Shape with a Color Gradient

PathGradientBrush

PathGradientBrush::GetCenterPoint Methods

PathGradientBrush::SetCenterColor

PathGradientBrush::SetCenterPoint Methods