Export (0) Print
Expand All
Expand Minimize

D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES structure

Contains the gradient origin offset and the size and position of the gradient ellipse for an ID2D1RadialGradientBrush.

Syntax


struct D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES {
  D2D1_POINT_2F center;
  D2D1_POINT_2F gradientOriginOffset;
  FLOAT         radiusX;
  FLOAT         radiusY;
};

Members

center

Type: D2D1_POINT_2F

In the brush's coordinate space, the center of the gradient ellipse.

gradientOriginOffset

Type: D2D1_POINT_2F

In the brush's coordinate space, the offset of the gradient origin relative to the gradient ellipse's center.

radiusX

Type: FLOAT

In the brush's coordinate space, the x-radius of the gradient ellipse.

radiusY

Type: FLOAT

In the brush's coordinate space, the y-radius of the gradient ellipse.

Remarks

Different values for center, gradientOriginOffset, radiusX and/or radiusY produce different gradients. The following illustration shows several radial gradients that have different gradient origin offsets, creating the appearance of the light illuminating the circles from different angles.

Illustration of four circles with radial gradients that have different origin offsets

For convenience, Direct2D provides the D2D1::RadialGradientBrushProperties function for creating new D2D1_RADIAL_GRADIENT_BRUSH structures.

Examples

The following example calls CreateRadialGradientBrush to create an ID2D1RadialGradientBrush. It uses the D2D1::RadialGradientBrushProperties helper function to create a D2D1_RADIAL_GRADIENT_BRUSH structure that has a center value of (75, 5), a gradientOriginOffset of (0, 0), and a radiusX and radiusY of to 75 and passes the structure to the CreateRadialGradientBrush method. When the gradient brush is used to fill a rectangle, it produces output as shown in the following illustration.

Illustration of a circle with a radial gradient brush


// The center of the gradient is in the center of the box.
// The gradient origin offset was set to zero(0, 0) or center in this case.
if (SUCCEEDED(hr))
{
    hr = m_pRenderTarget->CreateRadialGradientBrush(
        D2D1::RadialGradientBrushProperties(
            D2D1::Point2F(75, 75),
            D2D1::Point2F(0, 0),
            75,
            75),
        pGradientStops,
        &m_pRadialGradientBrush
        );
}


Code has been omitted from this example. For the complete code, see the Brush Types Example. For more information about radial gradient brushes, see the How to Create a Radial 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 Radial Gradient Brush
Brushes Overview
D2D1::RadialGradientBrushProperties
ID2D1RadialGradientBrush

 

 

Community Additions

ADD
Show:
© 2014 Microsoft