ID2D1PathGeometry 介面 (d2d1.h)

代表可能由弧線、曲線和線條組成的複雜圖形。

繼承

ID2D1PathGeometry 介面繼承自ID2D1GeometryID2D1PathGeometry 也有下列類型的成員:

方法

ID2D1PathGeometry 介面具有這些方法。

 
ID2D1PathGeometry::GetFigureCount

擷取路徑幾何中的圖形數目。
ID2D1PathGeometry::GetSegmentCount

擷取路徑幾何中的區段數目。
ID2D1PathGeometry::Open

擷取用來填入圖形和線段的路徑幾何接收。
ID2D1PathGeometry::Stream

將路徑幾何的內容複製到指定的ID2D1GeometrySink。

備註

ID2D1PathGeometry 物件可讓您描述幾何路徑。 若要描述 ID2D1PathGeometry 對象的路徑,請使用物件的 Open 方法來擷取 ID2D1GeometrySink。 使用接收將路徑幾何填入圖形和區段。

建立ID2D1PathGeometry物件

若要建立路徑幾何,請使用 ID2D1Factory::CreatePathGeometry 方法。

ID2D1PathGeometry 物件是由 ID2D1Factory所建立的裝置獨立資源。 一般而言,您應該建立一次幾何,並在應用程式存留期間保留它們,或直到需要修改它們為止。 如需與裝置無關和裝置相依資源的詳細資訊,請參閱 資源概觀

範例

下列範例會建立 ID2D1PathGeometry、擷取接收,並使用它來定義沙漏圖形。 如需完整的範例,請參閱 如何繪製和填滿複雜圖形

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))
        {
            pSink->BeginFigure(
                D2D1::Point2F(0, 0),
                D2D1_FIGURE_BEGIN_FILLED
                );

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

            pSink->AddBezier(
                D2D1::BezierSegment(
                    D2D1::Point2F(150, 50),
                    D2D1::Point2F(150, 150),
                    D2D1::Point2F(200, 200))
                );

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

            pSink->AddBezier(
                D2D1::BezierSegment(
                    D2D1::Point2F(50, 150),
                    D2D1::Point2F(50, 50),
                    D2D1::Point2F(0, 0))
                );

            pSink->EndFigure(D2D1_FIGURE_END_CLOSED);

            hr = pSink->Close();
        }
        SafeRelease(&pSink);
    }
}

規格需求

需求
最低支援的用戶端 適用於 Windows Vista 的 Windows 7、Windows Vista SP2 和平臺更新 [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows Server 2008 R2、Windows Server 2008 SP2 和 Platform Update for Windows Server 2008 [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 d2d1.h

另請參閱

幾何 HOW TO 主題

幾何概觀

ID2D1Factory::CreatePathGeometry

ID2D1Geometry

路徑幾何概觀