4

ID2D1PathGeometry::Open は、線、円弧、および曲線の追加をサポートする ID2D1GeometrySink を返します。しかし、円 (楕円) を追加する方法、または少なくとも何らかの方法でシミュレートする方法はありますか?

4

1 に答える 1

8

関数 AddArc を使用すると、x と y の半径が同じ 2 つの円弧を描くだけで、円を作成できます。ここに写真とコードがあります。これが役に立てば幸いです。

ここに画像の説明を入力

// create circle with two arcs
hr = g_pD2DFactory->CreatePathGeometry(&g_pCircleGeometry) ;
if (SUCCEEDED(hr))
{
    ID2D1GeometrySink *pSink = NULL;

    hr = g_pCircleGeometry->Open(&pSink);
    if (SUCCEEDED(hr))
    {
        pSink->SetFillMode(D2D1_FILL_MODE_WINDING);

        pSink->BeginFigure(
            D2D1::Point2F(100, 300), // Start point of the top half circle
            D2D1_FIGURE_BEGIN_FILLED
            );

        // Add the top half circle
        pSink->AddArc(
            D2D1::ArcSegment(
            D2D1::Point2F(400, 300), // end point of the top half circle, also the start point of the bottom half circle
            D2D1::SizeF(150, 150), // radius
            0.0f, // rotation angle
            D2D1_SWEEP_DIRECTION_CLOCKWISE,
            D2D1_ARC_SIZE_SMALL
            ));            

        // Add the bottom half circle
        pSink->AddArc(
            D2D1::ArcSegment(
            D2D1::Point2F(100, 300), // end point of the bottom half circle
            D2D1::SizeF(150, 150),   // radius of the bottom half circle, same as previous one.
            0.0f, // rotation angle
            D2D1_SWEEP_DIRECTION_CLOCKWISE,
            D2D1_ARC_SIZE_SMALL
            ));       

        pSink->EndFigure(D2D1_FIGURE_END_CLOSED);
    }
    hr = pSink->Close();
    SAFE_RELEASE(pSink);
}
于 2012-12-15T02:16:15.267 に答える