Expand Minimize

D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES structure

Contains the starting point and endpoint of the gradient axis for an ID2D1LinearGradientBrush.

Syntax


struct D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES {
  D2D1_POINT_2F startPoint;
  D2D1_POINT_2F endPoint;
};

Members

startPoint

Type: D2D1_POINT_2F

In the brush's coordinate space, the starting point of the gradient axis.

endPoint

Type: D2D1_POINT_2F

In the brush's coordinate space, the endpoint of the gradient axis.

Remarks

Use this method when creating new ID2D1LinearGradientBrush objects with the CreateLinearGradientBrush method. For convenience, Direct2D provides the D2D1::LinearGradientBrushProperties helper function for creating new D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES structures.

The following illustration shows how a linear gradient changes as you change its start and end points. For the first gradient, the start point is set to (0,0) and the end point to (150, 50); this creates a diagonal gradient that starts at the upper-left corner and extends to the lower-right corner of the area being painted. When you set the start point to (0, 25) and the end point to (150, 25), a horizontal gradient is created. Similarly, setting the start point to (75, 0) and the end point to (75, 50) creates a vertical gradient. Setting the start point to (0, 50) and the end point to (150, 0) creates a diagonal gradient that starts at the lower-left corner and extends to the upper-right corner of the area being painted.

Illustration of four gradients with different axes

Examples

The following example uses the CreateLinearGradientBrush method to create an ID2D1LinearGradientBrush (m_pLinearGradientBrush). It uses the D2D1::LinearGradientBrushProperties helper method to create a D2D1_LINEAR_GRADIENT_BRUSH_PROPERTIES structure that contains a start point of (0, 0) and and end point of (150, 150) and passes it to the CreateLinearGradientBrush method.


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


Code has been omitted from this example. For the complete example, see the Brush Types Example. For more information about creating and using linear gradient brushes, see the How to Create a Linear Gradient Brush topic and the Brushes Overview.

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

See also

How to Create a Linear Gradient Brush
Brushes Overview

 

 

Community Additions

ADD
Show:
© 2014 Microsoft