GraphicsPathIterator.HasCurve メソッド

定義

GraphicsPathIterator に関連付けられているパスに曲線が含まれているかどうかを示します。

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

戻り値

このメソッドは、現在のサブパスに曲線が含まれている場合は true を返します。それ以外の場合は false を返します。

次の例は、Windows フォームで使用するように設計されており、イベント オブジェクトがOnPaint必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • オブジェクト を GraphicsPath 作成します myPath

  • 3 本の線、四角形、楕円を追加します。

  • の オブジェクトを GraphicsPathIterator 作成します myPath

  • 現在のパス 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

注釈

パス内のすべてのカーブは、ベジエ スプラインのシーケンスとして格納されます。 たとえば、パスに楕円を追加する場合は、楕円の外接する四角形の左上隅、幅、高さを指定します。 これらの数値 (左上隅、幅、高さ) はパスに格納されません。その代わりに;楕円は 4 つのベジエ スプラインのシーケンスに変換されます。 パスには、これらのベジエ スプラインの端点とコントロール ポイントが格納されます。

パスにはデータ ポイントの配列が格納され、それぞれが線またはベジエ スプラインに属します。 配列内のポイントの一部がベジエ スプラインに属している場合は、 を HasCurve 返します true。 配列内のすべてのポイントが行に属している場合は、 を HasCurve 返します false

特定のメソッドはパスをフラット化します。つまり、パス内のすべての曲線が一連の線に変換されます。 パスがフラット化されると、 HasCurve は常に を返します false。 クラスの FlattenWiden、または Warp メソッドを GraphicsPath 呼び出すと、パスがフラット化されます。

適用対象