Export (0) Print
Expand All

ID2D1GradientStopCollection interface

Represents an collection of D2D1_GRADIENT_STOP objects for linear and radial gradient brushes.

When to implement

Custom implementations are not supported.

Members

The ID2D1GradientStopCollection interface inherits from ID2D1Resource. ID2D1GradientStopCollection also has these types of members:

Methods

The ID2D1GradientStopCollection interface has these methods.

MethodDescription
GetColorInterpolationGamma

Indicates the gamma space in which the gradient stops are interpolated.

GetExtendMode

Indicates the behavior of the gradient outside the normalized gradient range.

GetGradientStopCount

Retrieves the number of gradient stops in the collection.

GetGradientStops

Copies the gradient stops from the collection into an array of D2D1_GRADIENT_STOP structures.

 

Remarks

Creating ID2D1GradientStopCollection Objects

To create an ID2D1GradientStopCollection, use the ID2D1RenderTarget::CreateGradientStopCollection method.

A gradient stop collection is a device-dependent resource: your application should create gradient stop collections after it initializes the render target with which the gradient stop collection will be used, and recreate the gradient stop collection whenever the render target needs recreated. (For more information about resources, see Resources Overview.)

Examples

The following example creates an array of gradient stops, then uses them to create an 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
    );


The next code example uses the ID2D1GradientStopCollection to create an 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
        );
}


For the complete code, see the Brush Types Example.

Requirements

Minimum supported client

Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | Windows Store apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Header

D2d1.h

Library

D2d1.lib

DLL

D2d1.dll

 

 

Community Additions

ADD
Show:
© 2014 Microsoft