GraphicsPathIterator.HasCurve 方法

定义

指示与此 GraphicsPathIterator 关联的路径是否包含曲线。

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

返回

如果当前子路径包含曲线,该方法返回 true;否则,返回 false

示例

以下示例设计用于 Windows 窗体,它需要 PaintEventArgse事件OnPaint对象。 此代码执行以下操作:

  • GraphicsPath创建 对象 myPath

  • 添加三条线、一个矩形和一个椭圆。

  • 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

注解

路径中的所有曲线都存储为贝塞尔样条序列。 例如,向路径添加椭圆时,可以指定椭圆边框的左上角、宽度和高度。 这些 (左上角、宽度和高度) 的数字不存储在路径中;相反;椭圆将转换为由四个贝塞尔样条构成的序列。 路径存储这些贝塞尔曲线的端点和控制点。

路径存储一个数据点数组,其中每个数据点都属于一条线或一条贝塞尔样条。 如果数组中的某些点属于贝塞尔样条,则 HasCurve 返回 true。 如果数组中的所有点都属于行,则 HasCurve 返回 false

某些方法平展路径,这意味着路径中的所有曲线都转换为线条序列。 平展路径后, HasCurve 将始终返回 false。 调用 类的 FlattenGraphicsPathWidenWarp 方法将平展路径。

适用于