PathGradientBrush::GetCenterColor 方法 (gdipluspath.h)

PathGradientBrush::GetCenterColor方法會取得此路徑漸層筆刷中心點的色彩。

語法

Status GetCenterColor(
  [out] Color *color
);

參數

[out] color

類型: 色彩*

接收中心點色彩之 Color 物件的指標。

傳回值

類型: 狀態

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

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

備註

根據預設, PathGradientBrush 物件的中心點是筆刷界限路徑的中心點,但您可以藉由呼叫 PathGradientBrush::SetCenterPoint 方法PathGradientBrush 方法,將中心點設定為路徑內部或外部的任何位置。

範例

下列範例會建立 PathGradientBrush 物件,並用它來填滿橢圓形。 然後程式碼會呼叫PathGradientBrush::PathGradientBrush 物件的 GetCenterColor方法,以取得中心色彩。

VOID Example_GetCenterColor(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);

   // Fill the ellipse with the path gradient brush.
   graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);

   // Obtain information about the path gradient brush.
   Color color;
   pthGrBrush.GetCenterColor(&color);

   // Fill a rectangle with the retrieved color.
   SolidBrush solidBrush(color);
   graphics.FillRectangle(&solidBrush, 0, 120, 200, 30);
}

需求

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

另請參閱

筆刷和填滿的圖形

Color

建立路徑漸層

以色彩漸層填滿圖形

PathGradientBrush

PathGradientBrush::GetCenterPoint 方法

PathGradientBrush::SetCenterColor

PathGradientBrush::SetCenterPoint 方法