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::SetBlendTriangularShape method sets the blend shape of this path gradient brush.
Status SetBlendTriangularShape(
[in] REAL focus,
[in, optional] REAL scale
);
[in] focus
Type: REAL
Real number that specifies where the center color will be at its highest intensity. This number must be in the range 0 through 1.
[in, optional] scale
Type: REAL
Optional. Real number that specifies the maximum intensity of center color that gets blended with the boundary color. This number must be in the range 0 through 1. The default value is 1.
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, as you move from the boundary of a path gradient to the center point, the color changes gradually from the boundary color to the center color. You can customize the positioning and blending of the boundary and center colors by calling the PathGradientBrush::SetBlendTriangularShape method.
The following example creates a PathGradientBrush object based on an ellipse. The code calls the PathGradientBrush::SetBlendTriangularShape method of the PathGradientBrush object, passing a focus of 0.2 and a scale of 0.7. Then the code uses the path gradient brush to paint a rectangle that contains the ellipse.
VOID Example_SetBlendShape(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 red.
pthGrBrush.SetCenterColor(Color(255, 255, 0, 0));
// Set the color along the entire boundary of the path to blue.
Color colors[] = {Color(255, 0, 0, 255)};
INT count = 1;
pthGrBrush.SetSurroundColors(colors, &count);
pthGrBrush.SetBlendTriangularShape(0.2f, 0.7f);
// The color is blue on the boundary and at the center.
// At points that are 20 percent of the way from the boundary to the
// center, the color is 70 percent red and 30 percent blue.
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
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