GraphicsPath.CloseFigure メソッド

定義

現在の図形を閉じ、新しい図形を開始します。 現在の図形に接続された直線と曲線のシーケンスが含まれる場合、このメソッドは終了点と開始点を直線で接続することでループを閉じます。

public:
 void CloseFigure();
public void CloseFigure ();
member this.CloseFigure : unit -> unit
Public Sub CloseFigure ()

次のコード例は、Windows フォームで使用するように設計されており、イベント オブジェクトがOnPaint必要PaintEventArgseです。 このコードでは、新しいパスを作成し、図形を開始し、2 つの交差する線を図形に追加し、図形を閉じて三角形を形成することで、三角形を作成します。 その後、パスが画面に描画されます。

private:
   void CloseFigureExample( PaintEventArgs^ e )
   {
      // Create a path consisting of two, open-ended lines and close
      // the lines using CloseFigure.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->StartFigure();
      myPath->AddLine( Point(10,10), Point(200,10) );
      myPath->AddLine( Point(200,10), Point(200,200) );
      myPath->CloseFigure();

      // Draw the path to the screen.
      e->Graphics->DrawPath( Pens::Black, myPath );
   }
private void CloseFigureExample(PaintEventArgs e)
{
             
    // Create a path consisting of two, open-ended lines and close
             
    // the lines using CloseFigure.
    GraphicsPath myPath = new GraphicsPath();
    myPath.StartFigure();
    myPath.AddLine(new Point(10, 10), new Point(200, 10));
    myPath.AddLine(new Point(200, 10), new Point(200, 200));
    myPath.CloseFigure();
             
    // Draw the path to the screen.
    e.Graphics.DrawPath(Pens.Black, myPath);
}
Public Sub CloseFigureExample(ByVal e As PaintEventArgs)

    ' Create a path consisting of two, open-ended lines and close

    ' the lines using CloseFigure.
    Dim myPath As New GraphicsPath
    myPath.StartFigure()
    myPath.AddLine(New Point(10, 10), New Point(200, 10))
    myPath.AddLine(New Point(200, 10), New Point(200, 200))
    myPath.CloseFigure()

    ' Draw the path to the screen.
    e.Graphics.DrawPath(Pens.Black, myPath)
End Sub

適用対象