PathGradientBrush::SetCenterPoint 方法设置此路径渐变画笔的中心点。 默认情况下,中心点位于画笔边界路径的质心处,但可以将中心点设置为路径内外的任何位置。
语法
Status SetCenterPoint(
  const PointF & point
);
参数
point
对指定中心点的 PointF 对象的引用。
返回值
类型:状态
如果方法成功,则返回 Ok,这是 状态 枚举的元素。
如果方法失败,它将返回 状态 枚举的其他元素之一。
言论
例子
以下示例基于椭圆创建 PathGradientBrush 对象。 代码将中心颜色设置为蓝色,并将边界上的颜色设置为水绿色。 默认情况下,中心点位于椭圆中心(100,50),但对 pathGradientBrush::SetCenterPoint 方法的调用会将中心点设置为(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);
}
要求
| 要求 | 价值 | 
|---|---|
| 标头 | gdipluspath.h | 
另请参阅
PathGradientBrush::GetCenterColor