PathGradientBrush::SetFocusScales 方法 (gdipluspath.h)
PathGradientBrush::SetFocusScales 方法會設定此路徑漸層筆刷的焦點縮放比例。
語法
Status SetFocusScales(
[in] REAL xScale,
[in] REAL yScale
);
參數
[in] xScale
類型: REAL
指定 x 焦點縮放比例的實數。
[in] yScale
類型: REAL
指定 Y 焦點縮放比例的實數。
傳回值
類型: 狀態
如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。
如果方法失敗,它會傳回 Status 列舉的其他其中一個專案。
備註
根據預設,路徑漸層的中心色彩位於中心點。 藉由呼叫 PathGradientBrush::SetFocusScales,您可以指定中央色彩應該沿著圍繞中心點的路徑顯示。 該路徑是以 x 方向的 xScale 因數和 yScale 為 y 方向的因數來調整的界限路徑。 縮放路徑內的區域會填滿中心色彩。
範例
下列範例會根據三角形路徑建立 PathGradientBrush 物件。 程序代碼會呼叫 PathGradientBrush::SetFocusScales物件的 PathGradientBrush 方法,將筆刷的焦點縮放比例設定為 (0.2、 0.2) 。 然後,程式代碼會使用路徑漸層筆刷繪製包含三角形路徑的矩形。
VOID Example_SetFocusScales(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);
}
規格需求
需求 | 值 |
---|---|
最低支援的用戶端 | Windows XP、Windows 2000 Professional [僅限桌面應用程式] |
最低支援的伺服器 | Windows 2000 Server [僅限桌面應用程式] |
目標平台 | Windows |
標頭 | gdipluspath.h (包含 Gdiplus.h) |
程式庫 | Gdiplus.lib |
Dll | Gdiplus.dll |