PathGradientBrush::SetBlendTriangularShape 方法 (gdipluspath.h)
PathGradientBrush::SetBlendTriangularShape 方法會設定此路徑漸層筆刷的混合圖形。
語法
Status SetBlendTriangularShape(
[in] REAL focus,
[in, optional] REAL scale
);
參數
[in] focus
類型: REAL
實際數位,指定中心色彩在最高濃度的位置。 此數字必須介於 0 到 1 的範圍內。
[in, optional] scale
類型: REAL
選擇性。 實數,指定與界限色彩混合之中心色彩的最大濃度。 此數字必須介於 0 到 1 的範圍內。 預設值為 1。
傳回值
類型: 狀態
如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。
如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。
備註
根據預設,當您從路徑漸層的界限移至中心點時,色彩會逐漸從界限色彩變更為中央色彩。 您可以呼叫 PathGradientBrush::SetBlendTriangularShape 方法來自定義界限和中心色彩的定位和混合。
範例
下列範例會根據省略號建立 PathGradientBrush 物件。 此程式代碼會呼叫 PathGradientBrush::SetBlendTriangularShape 方法的 PathGradientBrush 物件,並傳遞 0.2 的焦點和 0.7 的縮放比例。 然後,程式代碼會使用路徑漸層筆刷繪製包含橢圓形的矩形。
VOID Example_SetBlendShape(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 red.
pthGrBrush.SetCenterColor(Color(255, 255, 0, 0));
// Set the color along the entire boundary of the path to blue.
Color colors[] = {Color(255, 0, 0, 255)};
INT count = 1;
pthGrBrush.SetSurroundColors(colors, &count);
pthGrBrush.SetBlendTriangularShape(0.2f, 0.7f);
// The color is blue on the boundary and at the center.
// At points that are 20 percent of the way from the boundary to the
// center, the color is 70 percent red and 30 percent blue.
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 |