PathGradientBrush::SetInterpolationColors 方法 (gdipluspath.h)

PathGradientBrush::SetInterpolationColors 方法會設定此路徑漸層筆刷的預設色彩和混合位置。

語法

Status SetInterpolationColors(
  [in] const Color *presetColors,
  [in] const REAL  *blendPositions,
  [in] INT         count
);

參數

[in] presetColors

類型: const Color*

指定漸層插補色彩之 Color 物件的陣列指標。 presetColors 陣列中指定索引的色彩會對應至 blendPositions 陣列中相同索引的混合位置。

[in] blendPositions

類型: REAL*

指定混合位置之陣列的指標。 每個混合位置都是從 0 到 1 的數位,其中 0 表示漸層的界限,1 表示中心點。 介於 0 到 1 之間的混合位置會指定一組介於界限到中心點之間距離的特定分數的所有點。 例如,混合位置 0.7 會指定從界限到中心點的所有點集 70%。

[in] count

類型: INT

整數,指定 presetColors 陣列中的 Color 物件數目。 這與 blendPositions 陣列中的元素數目相同。

傳回值

類型: 狀態

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

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

備註

簡單的路徑漸層筆刷有兩種色彩:界限色彩和中央色彩。 當您使用這類筆刷繪製時,當從界限路徑移至中心點時,色彩會逐漸從界限色彩變更為中心色彩。 您可以藉由指定預設色彩陣列和混合位置的陣列,來建立更複雜的漸層。

範例

下列範例會根據三角形路徑建立 PathGradientBrush 物件。 PathGradientBrush::SetInterpolationColors 方法會將筆刷的默認色彩設定為紅色、藍色和青色,並將混合位置設定為 0、0、4 和 1。 Graphics::FillRectangle 方法會使用路徑漸層筆刷繪製包含三角形路徑的矩形。

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

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

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

   REAL pos[] = {
      0.0f,    // red at the boundary
      0.4f,    // blue 40 percent of the way from the boundary to the center
      1.0f};   // aqua at the center

   pthGrBrush.SetInterpolationColors(col, pos, 3);
   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

另請參閱

筆刷和填滿的圖形

色彩

建立路徑漸層

以色彩漸層填滿圖形

PathGradientBrush

PathGradientBrush::GetInterpolationColors