PathGradientBrush::SetBlend 方法设置此路径渐变画笔的混合因子和混合位置。
语法
Status SetBlend(
  [in] const REAL *blendFactors,
  [in] const REAL *blendPositions,
  [in] INT        count
);
parameters
[in] blendFactors
类型: REAL*
指向混合因子数组的指针。 数组中的每个数字都应在 0 到 1 的范围内。
[in] blendPositions
类型: REAL*
指向混合位置数组的指针。 数组中的每个数字都应在 0 到 1 的范围内。
[in] count
类型: INT
指定 blendFactors 数组中的元素数的整数。 这与 blendPositions 数组中的元素数相同。
返回值
类型: 状态
如果该方法成功,则返回 Ok,这是 Status 枚举的元素。
如果方法失败,它将返回 Status 枚举的其他元素之一。
注解
PathGradientBrush 对象具有边界路径和中心点。 使用路径渐变画笔填充区域时,从边界路径移动到中心点时,颜色会逐渐变化。 默认情况下,颜色与距离呈线性相关,但可以通过调用 PathGradientBrush::SetBlend 方法自定义颜色与距离之间的关系。
示例
以下示例基于椭圆创建 PathGradientBrush 对象。 代码调用 PathGradientBrush 对象的 PathGradientBrush::SetBlend 方法,为画笔建立一组混合因子和混合位置。 然后,代码使用路径渐变画笔填充椭圆形。
VOID Example_SetBlend(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);
   // Set blend factors and positions for the path gradient brush.
   REAL fac[] = {
      0.0f, 
      0.4f,     // 40 percent of the way from aqua to blue
      0.8f,     // 80 percent of the way from aqua to blue
      1.0f};
   REAL pos[] = {
      0.0f, 
      0.3f,   // 30 percent of the way from the boundary to the center
      0.7f,   // 70 percent of the way from the boundary to the center
      1.0f};
   pthGrBrush.SetBlend(fac, pos, 4);
   // Fill the ellipse with the path gradient brush.
   graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);  
}
要求
| 最低受支持的客户端 | Windows XP、Windows 2000 Professional [仅限桌面应用] | 
| 最低受支持的服务器 | Windows 2000 Server [仅限桌面应用] | 
| 目标平台 | Windows | 
| 标头 | gdipluspath.h (包括 Gdiplus.h) | 
| Library | Gdiplus.lib | 
| DLL | Gdiplus.dll |