ID2D1PathGeometry interface

Represents a complex shape that may be composed of arcs, curves, and lines.


The ID2D1PathGeometry interface inherits from ID2D1Geometry. ID2D1PathGeometry also has these types of members:


The ID2D1PathGeometry interface has these methods.

Method Description
ID2D1PathGeometry::GetFigureCount Retrieves the number of figures in the path geometry.
ID2D1PathGeometry::GetSegmentCount Retrieves the number of segments in the path geometry.
ID2D1PathGeometry::Open Retrieves the geometry sink that is used to populate the path geometry with figures and segments.
ID2D1PathGeometry::Stream Copies the contents of the path geometry to the specified ID2D1GeometrySink.


An ID2D1PathGeometry object enables you to describe a geometric path. To describe an ID2D1PathGeometry object's path, use the object's Open method to retrieve an ID2D1GeometrySink. Use the sink to populate the path geometry with figures and segments.

Creating ID2D1PathGeometry Objects

To create a path geometry, use the ID2D1Factory::CreatePathGeometry method.

ID2D1PathGeometry objects are device-independent resources created by ID2D1Factory. In general, you should create geometries once and retain them for the life of the application, or until they need to be modified. For more information about device-independent and device-dependent resources, see the Resources Overview.


The following example creates an ID2D1PathGeometry, retrieves a sink, and uses it to define an hourglass shape. For the complete example, see How to Draw and Fill a Complex Shape.

ID2D1GeometrySink *pSink = NULL;

// Create a path geometry.
if (SUCCEEDED(hr))
    hr = m_pD2DFactory->CreatePathGeometry(&m_pPathGeometry);

    if (SUCCEEDED(hr))
        // Write to the path geometry using the geometry sink.
        hr = m_pPathGeometry->Open(&pSink);

        if (SUCCEEDED(hr))
                D2D1::Point2F(0, 0),

            pSink->AddLine(D2D1::Point2F(200, 0));

                    D2D1::Point2F(150, 50),
                    D2D1::Point2F(150, 150),
                    D2D1::Point2F(200, 200))

            pSink->AddLine(D2D1::Point2F(0, 200));

                    D2D1::Point2F(50, 150),
                    D2D1::Point2F(50, 50),
                    D2D1::Point2F(0, 0))


            hr = pSink->Close();


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

See also

Geometries How-to Topics

Geometries Overview



Path Geometries Overview