ID2D1GradientStopCollection インターフェイス (d2d1.h)

線形および放射状グラデーション ブラシの D2D1_GRADIENT_STOP オブジェクトのコレクションを表します。

継承

ID2D1GradientStopCollection インターフェイスは、ID2D1Resource から継承されます。 ID2D1GradientStopCollection には、次の種類のメンバーもあります。

メソッド

ID2D1GradientStopCollection インターフェイスには、これらのメソッドがあります。

 
ID2D1GradientStopCollection::GetColorInterpolationGamma

グラデーションが補間されるガンマ空間を示します。
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 7、Windows Vista SP2 および Windows Vista 用プラットフォーム更新プログラム [デスクトップ アプリ |UWP アプリ]
サポートされている最小のサーバー Windows Server 2008 R2、Windows Server 2008 SP2 および Windows Server 2008 用プラットフォーム更新プログラム [デスクトップ アプリ |UWP アプリ]
対象プラットフォーム Windows
ヘッダー d2d1.h

関連項目

ID2D1Resource