ID2D1Factory::CreateGeometryGroup method (d2d1.h)

Creates an ID2D1GeometryGroup, which is an object that holds other geometries.

Syntax

HRESULT CreateGeometryGroup(
        D2D1_FILL_MODE     fillMode,
  [in]  ID2D1Geometry      **geometries,
        UINT32             geometriesCount,
  [out] ID2D1GeometryGroup **geometryGroup
);

Parameters

fillMode

Type: D2D1_FILL_MODE

A value that specifies the rule that a composite shape uses to determine whether a given point is part of the geometry.

[in] geometries

Type: ID2D1Geometry**

An array containing the geometry objects to add to the geometry group. The number of elements in this array is indicated by the geometriesCount parameter.

geometriesCount

Type: UINT

The number of elements in geometries.

[out] geometryGroup

Type: ID2D1GeometryGroup**

When this method returns, contains the address of a pointer to the geometry group created by this method.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Geometry groups are a convenient way to group several geometries simultaneously so all figures of several distinct geometries are concatenated into one. To create a ID2D1GeometryGroup object, call the CreateGeometryGroup method on the ID2D1Factory object, passing in the fillMode with possible values of D2D1_FILL_MODE_ALTERNATE (alternate) and D2D1_FILL_MODE_WINDING, an array of geometry objects to add to the geometry group, and the number of elements in this array.

Examples

The following code example first declares an array of geometry objects. These objects are four concentric circles that have the following radii: 25, 50, 75, and 100. Then call the CreateGeometryGroup on the ID2D1Factory object, passing in D2D1_FILL_MODE_ALTERNATE, an array of geometry objects to add to the geometry group, and the number of elements in this array.

ID2D1Geometry *ppGeometries[] =
{
    m_pEllipseGeometry1,
    m_pEllipseGeometry2,
    m_pEllipseGeometry3,
    m_pEllipseGeometry4
};

hr = m_pD2DFactory->CreateGeometryGroup(
    D2D1_FILL_MODE_ALTERNATE,
    ppGeometries,
    ARRAYSIZE(ppGeometries),
    &m_pGeoGroup_AlternateFill
    );

if (SUCCEEDED(hr))
{
    hr = m_pD2DFactory->CreateGeometryGroup(
        D2D1_FILL_MODE_WINDING,
        ppGeometries,
        ARRAYSIZE(ppGeometries),
        &m_pGeoGroup_WindingFill
        );
}

The following illustration shows the results of rendering the two group geometries from the example.

Illustration of two sets of four concentric circles, one with the second and fourth rings filled and one with all rings filled

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]
Target Platform Windows
Header d2d1.h
Library D2d1.lib
DLL D2d1.dll

See also

Geometries Overview

ID2D1Factory