ID2D1RenderTarget::CreateGradientStopCollection 方法

指定的D2D1_GRADIENT_STOP結構陣列建立ID2D1GradientStopCollection

多載清單

方法 Description
CreateGradientStopCollection (D2D1_GRADIENT_STOP*,D2D1_GAMMA,D2D1_EXTEND_MODE,ID2D1GradientStopCollection**) 從指定的漸層停駐點、色彩插補 gamma 和擴充模式建立 ID2D1GradientStopCollection
CreateGradientStopCollection (D2D1_GRADIENT_STOP*,ID2D1GradientStopCollection**) 從指定的漸層停駐點建立 ID2D1GradientStopCollection ,該停駐點使用 D2D1_GAMMA_2_2 色彩插補 gamma 和固定擴充模式。

範例

下列範例會建立漸層停駐點的陣列,然後使用它們來建立 ID2D1GradientStopCollection

// Create an array of gradient stops to put in the gradient stop
// collection that will be used in the gradient brush.
ID2D1GradientStopCollection *pGradientStops = NULL;

D2D1_GRADIENT_STOP gradientStops[2];
gradientStops[0].color = D2D1::ColorF(D2D1::ColorF::Yellow, 1);
gradientStops[0].position = 0.0f;
gradientStops[1].color = D2D1::ColorF(D2D1::ColorF::ForestGreen, 1);
gradientStops[1].position = 1.0f;
// Create the ID2D1GradientStopCollection from a previously
// declared array of D2D1_GRADIENT_STOP structs.
hr = m_pRenderTarget->CreateGradientStopCollection(
    gradientStops,
    2,
    D2D1_GAMMA_2_2,
    D2D1_EXTEND_MODE_CLAMP,
    &pGradientStops
    );

下一個程式碼範例會使用 ID2D1GradientStopCollection 來建立 ID2D1LinearGradientBrush

// 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
        );
}

規格需求

需求
標頭
D2d1_1.h (包含 D2d1.h)
程式庫
D2d1.lib
DLL
D2d1.dll

另請參閱

ID2D1RenderTarget

D2D1_GRADIENT_STOP

如何建立線性漸層筆刷

如何建立星形漸層筆刷

筆刷概觀