Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
The PathGradientBrush::SetCenterColor method sets the center color of this path gradient brush. The center color is the color that appears at the brush's center point.
Status SetCenterColor(
[in, ref] const Color & color
);
[in, ref] color
Type: const Color
Reference to a Color object that specifies the center color.
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 is the centroid of the brush's boundary path, but you can set the center point to any location inside or outside the path.
The following example creates a PathGradientBrush object based on an ellipse. The code calls the PathGradientBrush::SetCenterColor method of the PathGradientBrush object to set the center color to blue. The PathGradientBrush::SetSurroundColors method sets the color along the entire boundary to aqua. The FillRectangle Methods method uses the path gradient brush to paint a rectangle that contains the ellipse.
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 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);
}
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 |
Filling a Shape with a Color Gradient
PathGradientBrush::GetCenterColor
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register today