Share via


D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES結構 (d2d1.h)

包含 ID2D1LinearGradientBrush 之漸層軸的起點和端點。

語法

typedef struct D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES {
  D2D1_POINT_2F startPoint;
  D2D1_POINT_2F endPoint;
} D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES;

成員

startPoint

類型: D2D1_POINT_2F

在筆刷的座標空間中,漸層軸的起點。

endPoint

類型: D2D1_POINT_2F

在筆刷的座標空間中,漸層軸的端點。

備註

使用 CreateLinearGradientBrush 方法建立新的 ID2D1LinearGradientBrush 物件時,請使用此方法。 為了方便起見,Direct2D 提供 D2D1::LinearGradientBrushProperties 協助程式函式來建立新的 D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES 結構。

下圖顯示當您變更線性漸層的起點和終點時,如何變更。 在第一個漸層中,起點會設定為 (0,0) ,並將端點設定為 (150,50) ;這會建立從左上角開始的對角漸層,並延伸至所繪製區域的右下角。 當您將起點設定為 (0、25) ,並將端點設定為 (150、25) 時,會建立水準漸層。 同樣地,將起點設定為 (75、0) ,並將端點設定為 (75、50) 會建立垂直漸層。 將起點設定為 (0、50) ,並將端點設定為 (150,0) 會建立從左下角開始的對角漸層,並延伸至繪製區域的右上角。

具有不同軸的四個漸層圖例

範例

下列範例會使用 CreateLinearGradientBrush 方法來建立 ID2D1LinearGradientBrush (m_pLinearGradientBrush) 。 它會使用 D2D1::LinearGradientBrushProperties 協助程式方法來建立 D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES 結構,其中包含 (0、0) 和 (150、150) 的終點,並將其傳遞至 CreateLinearGradientBrush 方法。

// The line that determines the direction of the gradient starts at
// the upper-left corner of the square and ends at the lower-right corner.

if (SUCCEEDED(hr))
{
    hr = m_pRenderTarget->CreateLinearGradientBrush(
        D2D1::LinearGradientBrushProperties(
            D2D1::Point2F(0, 0),
            D2D1::Point2F(150, 150)),
        pGradientStops,
        &m_pLinearGradientBrush
        );
}

如需建立和使用線性漸層筆刷的詳細資訊,請參閱 如何建立線性漸層筆刷 主題和 筆刷概觀

規格需求

需求
最低支援的用戶端 適用於 Windows Vista 的 Windows 7、Windows Vista SP2 和平臺更新 [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows Server 2008 R2、Windows Server 2008 SP2 和 Platform Update for Windows Server 2008 [傳統型應用程式 |UWP 應用程式]
標頭 d2d1.h

另請參閱

筆刷概觀

如何建立線性漸層筆刷