PathGradientBrush::SetCenterColor 方法 (gdipluspath.h)

PathGradientBrush::SetCenterColor 方法會設定此路徑漸層筆刷的中心色彩。 中央色彩是出現在筆刷中心點的色彩。

語法

Status SetCenterColor(
  [in, ref] const Color & color
);

參數

[in, ref] color

類型: const Color

指定中央色彩的 Color 物件參考。

傳回值

類型: 狀態

如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。

備註

根據預設,中心點是筆刷界限路徑的中心點,但您可以將中心點設定為路徑內部或外部的任何位置。

範例

下列範例會根據省略號建立 PathGradientBrush 物件。 程序代碼會呼叫 PathGradientBrush::P athGradientBrush 物件的 SetCenterColor 方法,將中心色彩設定為藍色。 PathGradientBrush::SetSurroundColors 方法會將整個界限的色彩設定為青色。 FillRectangle 方法會使用路徑漸層筆刷繪製包含橢圓形的矩形。

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); 
}

規格需求

需求
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 gdipluspath.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

筆刷和填滿的圖形

色彩

建立路徑漸層

以色彩漸層填滿圖形

GraphicsPath

PathGradientBrush

PathGradientBrush::GetCenterColor

PathGradientBrush::GetCenterPoint 方法

PathGradientBrush::SetCenterPoint 方法