PathGradientBrush::SetBlend 方法 (gdipluspath.h)
PathGradientBrush::SetBlend方法會設定此路徑漸層筆刷的混合因數和混合位置。
語法
Status SetBlend(
[in] const REAL *blendFactors,
[in] const REAL *blendPositions,
[in] INT count
);
參數
[in] blendFactors
類型: REAL*
混合因數陣列的指標。 陣列中的每個數位都應該在範圍 0 到 1 中。
[in] blendPositions
類型: REAL*
混合位置陣列的指標。 陣列中的每個數位都應該在範圍 0 到 1 中。
[in] count
類型: INT
整數,指定 blendFactors 陣列中的專案數目。 這與 blendPositions 陣列中的元素數目相同。
傳回值
類型: 狀態
如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。
如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。
備註
PathGradientBrush物件具有界限路徑和中心點。 當您以路徑漸層筆刷填滿區域時,當您從界限路徑移至中心點時,色彩會逐漸變更。 根據預設,色彩與距離線性相關,但您可以呼叫 PathGradientBrush::SetBlend 方法來自訂色彩與距離之間的關聯性。
範例
下列範例會根據省略號建立 PathGradientBrush 物件。 程式碼會呼叫 PathGradientBrush::SetBlend 方法 PathGradientBrush 物件,以建立筆刷的一組混合因數和混合位置。 然後程式碼會使用路徑漸層筆刷填滿橢圓形。
VOID Example_SetBlend(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);
// Set blend factors and positions for the path gradient brush.
REAL fac[] = {
0.0f,
0.4f, // 40 percent of the way from aqua to blue
0.8f, // 80 percent of the way from aqua to blue
1.0f};
REAL pos[] = {
0.0f,
0.3f, // 30 percent of the way from the boundary to the center
0.7f, // 70 percent of the way from the boundary to the center
1.0f};
pthGrBrush.SetBlend(fac, pos, 4);
// Fill the ellipse with the path gradient brush.
graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);
}
需求
最低支援的用戶端 | Windows XP、Windows 2000 Professional [僅限傳統型應用程式] |
最低支援的伺服器 | Windows 2000 Server [僅限傳統型應用程式] |
目標平台 | Windows |
標頭 | gdipluspath.h (包含 Gdiplus.h) |
程式庫 | Gdiplus.lib |
Dll | Gdiplus.dll |