PathGradientBrush::GetCenterPoint (Point*) 方法 (gdipluspath.h)

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

語法

Status GetCenterPoint(
  [out] Point *point
);

參數

[out] point

類型: *

接收中心點之 Point 物件的指標。

傳回值

類型: 狀態

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

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

備註

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

範例

下列範例示範 PathGradientBrush 類別的數種方法,包括 PathGradientBrush::GetCenterPointPathGradientBrush::SetCenterColor。 此程式代碼會建立 PathGradientBrush 對象,然後設定筆刷的中心色彩和界限色彩。 此程式代碼會呼叫 PathGradientBrush::GetCenterPoint 方法,以判斷路徑漸層筆刷的中心點,然後將線條從原點繪製到該中心點。

VOID Example_GetCenterPoint(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.
   Point  centerPoint;
   pthGrBrush.GetCenterPoint(&centerPoint);

   // Draw a line from the origin to the center of the ellipse.
   Pen pen(Color(255, 0, 255, 0));
   graphics.DrawLine(&pen, Point(0, 0), centerPoint);
}

規格需求

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

另請參閱

筆刷和填滿的圖形

色彩

建立路徑漸層

使用色彩漸層填滿圖形

PathGradientBrush

PathGradientBrush::GetCenterColor

PathGradientBrush::SetCenterColor

PathGradientBrush::SetCenterPoint 方法