共用方式為


PathGradientBrush::GetFocusScales 方法 (gdipluspath.h)

PathGradientBrush::GetFocusScales方法會取得此路徑漸層筆刷的焦點尺規。

語法

Status GetFocusScales(
  [out] REAL *xScale,
  [out] REAL *yScale
);

參數

[out] xScale

類型: REAL*

接收 x 焦點縮放值的 REAL 指標。

[out] yScale

類型: REAL*

接收 Y 焦點縮放值的 REAL 指標。

傳回值

類型: 狀態

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

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

備註

根據預設,路徑漸層的中心色彩位於中心點。 藉由呼叫 PathGradientBrush::SetFocusScales,您可以指定中央色彩應該沿著圍繞中心點的路徑顯示。 例如,假設界限路徑是三角形,而中心點位於該三角形的距心。 也假設界限色彩為紅色,而中心色彩為藍色。 如果您將焦點縮放比例設定為 (0.2、0.2) ,則色彩會沿著圍繞中心點的小型三角形界限呈現藍色。 該小三角形是縮放比例為 0.2 的主要界限路徑,以 x 方向為 0.2,而 y 方向為 0.2。 當您使用路徑漸層筆刷繪製時,當您從大型三角形的界限移至小型三角形的界限時,色彩會逐漸從紅色變更為藍色。 小三角形內的區域會填滿藍色。

範例

下列範例會根據三角形路徑建立 PathGradientBrush 物件。 程式碼會將路徑漸層筆刷的焦點縮放比例設定為 (0.2、 0.2) ,然後使用路徑漸層筆刷填滿包含三角形路徑的區域。 最後,程式碼會呼叫 PathGradientBrush::GetFocusScales方法 PathGradientBrush 物件,以取得 x 焦點小數位數和 y 焦點小數位數的值。

VOID Example_GetFocusScales(HDC hdc)
{
   Graphics graphics(hdc);

   Point points[] = {Point(100, 0), Point(200, 200), Point(0, 200)};

   // No GraphicsPath object is created. The PathGradientBrush
   // object is constructed directly from the array of points.
   PathGradientBrush pthGrBrush(points, 3);

   Color colors[] = {
      Color(255, 255, 0, 0),    // red
      Color(255, 0, 0, 255)};   // blue

   REAL relativePositions[] = {
      0.0f,    // red at the boundary of the outer triangle
      1.0f};   // blue at the boundary of the inner triangle

   pthGrBrush.SetInterpolationColors(colors, relativePositions, 2);

   // The inner triangle is formed by scaling the outer triangle
   // about its centroid. The scaling factor is 0.2 in both
   // the x and y directions.
   pthGrBrush.SetFocusScales(0.2f, 0.2f);

   // Fill a rectangle that is larger than the triangle
   // specified in the Point array. The portion of the
   // rectangle outside the triangle will not be painted.
   graphics.FillRectangle(&pthGrBrush, 0, 0, 200, 200);

   // Obtain information about the path gradient brush.
   REAL xScale = 0.0f;
   REAL yScale = 0.0f;
   pthGrBrush.GetFocusScales(&xScale, &yScale);

   // The value of xScale is now 0.2.
   // The value of yScale is now 0.2. 
}

需求

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

另請參閱

筆刷和填滿的圖形

使用色彩漸層填滿圖形

GraphicsPath

PathGradientBrush

PathGradientBrush::SetFocusScales