GraphicsPathIterator.HasCurve 메서드

정의

GraphicsPathIterator와 연결된 경로에 곡선이 포함되어 있는지 여부를 나타냅니다.

public:
 bool HasCurve();
public bool HasCurve ();
member this.HasCurve : unit -> bool
Public Function HasCurve () As Boolean

반환

현재 하위 경로에 곡선이 들어 있으면 이 메서드가 true를 반환하고, 그렇지 않으면 false를 반환합니다.

예제

다음 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 개체인 가 OnPaint 필요합니다PaintEventArgse. 코드는 다음 작업을 수행합니다.

  • 개체myPathGraphicsPath 만듭니다.

  • 세 줄, 사각형 및 줄임표를 추가합니다.

  • 에 대한 개체를 GraphicsPathIteratormyPath만듭니다.

  • 현재 경로 myPath 에 곡선이 포함되어 있는지 테스트합니다.

  • 메시지 상자에 테스트 결과를 표시합니다.

private:
   void HasCurveExample( PaintEventArgs^ /*e*/ )
   {
      // Create a path and add three lines,
      // a rectangle and an ellipse.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      array<Point>^ myPoints = {Point(20,20),Point(120,120),Point(20,120),Point(20,20)};
      Rectangle myRect = Rectangle(120,120,100,100);
      myPath->AddLines( myPoints );
      myPath->AddRectangle( myRect );
      myPath->AddEllipse( 220, 220, 100, 100 );

      // Create a GraphicsPathIterator for myPath.
      GraphicsPathIterator^ myPathIterator = gcnew GraphicsPathIterator( myPath );

      // Test for a curve.
      bool myHasCurve = myPathIterator->HasCurve();

      // Show the test result.
      MessageBox::Show( myHasCurve.ToString() );
   }
private void HasCurveExample(PaintEventArgs e)
{
             
    // Create a path and add three lines,
    // a rectangle and an ellipse.
    GraphicsPath myPath = new GraphicsPath();
    
    Point[] myPoints = {new Point(20, 20), new Point(120, 120), 
        new Point(20, 120),new Point(20, 20) }; 

    Rectangle myRect = new Rectangle(120, 120, 100, 100);
    myPath.AddLines(myPoints);
    myPath.AddRectangle(myRect);
    myPath.AddEllipse(220, 220, 100, 100);
             
    // Create a GraphicsPathIterator for myPath.
    GraphicsPathIterator myPathIterator = new
        GraphicsPathIterator(myPath);
             
    // Test for a curve.
    bool myHasCurve = myPathIterator.HasCurve();
             
    // Show the test result.
    MessageBox.Show(myHasCurve.ToString());
}
Public Sub HasCurveExample(ByVal e As PaintEventArgs)
    Dim myPath As New GraphicsPath
    Dim myPoints As Point() = {New Point(20, 20), _
        New Point(120, 120), New Point(20, 120), New Point(20, 20)}
    Dim myRect As New Rectangle(120, 120, 100, 100)
    myPath.AddLines(myPoints)
    myPath.AddRectangle(myRect)
    myPath.AddEllipse(220, 220, 100, 100)

    ' Create a GraphicsPathIterator for myPath.
    Dim myPathIterator As New GraphicsPathIterator(myPath)
    Dim myHasCurve As Boolean = myPathIterator.HasCurve()
    MessageBox.Show(myHasCurve.ToString())
End Sub

설명

경로의 모든 곡선은 베지어 스플라인 시퀀스로 저장됩니다. 예를 들어 경로에 타원을 추가할 때 왼쪽 위 모서리, 너비 및 타원 경계 사각형의 높이를 지정합니다. 이러한 숫자(왼쪽 위 모서리, 너비 및 높이)는 경로에 저장되지 않습니다. 대신; 타원은 네 개의 베지어 스플라인 시퀀스로 변환됩니다. 경로는 해당 Bézier 스플라인의 엔드포인트 및 제어점을 저장합니다.

경로는 데이터 요소의 배열을 저장하며, 각 데이터 요소는 선 또는 베지어 스플라인에 속합니다. 배열의 일부 점이 Bézier 스플라인에 속하는 경우 를 HasCurve 반환 true합니다. 배열의 모든 점이 줄에 속하면 를 HasCurve 반환합니다 false.

특정 메서드는 경로를 평면화합니다. 즉, 경로의 모든 곡선이 선 시퀀스로 변환됩니다. 경로가 평면화되면 HasCurve 는 항상 를 반환합니다 false. 클래스의 Flatten, Widen또는 Warp 메서드를 GraphicsPath 호출하면 경로가 평면화됩니다.

적용 대상