Share via


ID2D1GradientStopCollection 介面 (d2d1.h)

表示線性和星形漸層筆刷 D2D1_GRADIENT_STOP 物件的集合。

繼承

ID2D1GradientStopCollection介面繼承自ID2D1ResourceID2D1GradientStopCollection 也有下列類型的成員:

方法

ID2D1GradientStopCollection介面具有這些方法。

 
ID2D1GradientStopCollection::GetColorInterpolationGamma

指出插補漸層停駐點的 gamma 空間。
ID2D1GradientStopCollection::GetExtendMode

指出正規化漸層範圍外之漸層的行為。
ID2D1GradientStopCollection::GetGradientStopCount

擷取集合中的漸層停駐點數目。
ID2D1GradientStopCollection::GetGradientStops

將集合中的漸層停駐點複製到D2D1_GRADIENT_STOP結構的陣列。

備註

建立 ID2D1GradientStopCollection 物件

若要建立 ID2D1GradientStopCollection,請使用 ID2D1RenderTarget::CreateGradientStopCollection 方法。

漸層停駐點集合是裝置相依的資源:您的應用程式應該在初始化使用漸層停止集合的轉譯目標之後建立漸層停止集合,並在轉譯目標需要重新建立時重新建立漸層停止集合。 (如需資源的詳細資訊,請參閱 資源概觀.)

範例

下列範例會建立漸層停駐點的陣列,然後使用它們來建立 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
        );
}

規格需求

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

另請參閱

ID2D1Resource