D2D1_RADIAL_GRADIENT_BRUSH_PROPERTIES structure (d2d1.h)

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

Syntax

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

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

For more information about radial gradient brushes, see the How to Create a Radial Gradient Brush topic and the Brushes Overview.

Requirements

Requirement Value
Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]
Header d2d1.h

See also

Brushes Overview

D2D1::RadialGradientBrushProperties

How to Create a Radial Gradient Brush

ID2D1RadialGradientBrush