PathGradientBrush::SetCenterPoint (constPointF&) 方法 (gdipluspath.h)

PathGradientBrush::SetCenterPoint 方法设置此路径渐变画笔的中心点。 默认情况下,中心点位于画笔边界路径的质心处,但你可以将中心点设置为路径内部或外部的任何位置。

语法

Status SetCenterPoint(
  const PointF & point
);

参数

point

对指定中心点的 PointF 对象的引用。

返回值

类型:状态

如果该方法成功,则返回 Ok,这是 Status 枚举的元素。

如果方法失败,它将返回 Status 枚举的其他元素之一。

注解

示例

以下示例基于椭圆创建 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);
}

要求

要求
Header gdipluspath.h

另请参阅

画笔和填充形状

创建路径渐变

使用颜色渐变填充形状

GraphicsPath

PathGradientBrush

PathGradientBrush::GetCenterColor

PathGradientBrush::GetCenterPoint 方法

PathGradientBrush::SetCenterColor