Compartir vía


GraphicsPathIterator.HasCurve Método

Definición

Indica si la ruta de acceso asociada a este GraphicsPathIterator contiene una curva.

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

Devoluciones

Este método devuelve true si la subruta actual contiene una curva; de lo contrario, false.

Ejemplos

El ejemplo siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, un objeto de evento OnPaint. El código realiza las siguientes acciones:

  • Crea un objeto GraphicsPath, myPath.

  • Agrega tres líneas, un rectángulo y una elipse.

  • Crea un objeto GraphicsPathIterator para myPath.

  • Comprueba si la ruta de acceso actual myPath contiene una curva.

  • Muestra el resultado de la prueba en un cuadro de mensaje.

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

Comentarios

Todas las curvas de un trazado se almacenan como secuencias de splines bézier. Por ejemplo, al agregar una elipse a una ruta de acceso, especifique la esquina superior izquierda, el ancho y el alto del rectángulo delimitador de la elipse. Esos números (esquina superior izquierda, ancho y alto) no se almacenan en la ruta de acceso; en lugar de; la elipse se convierte en una secuencia de cuatro splines bézier. La ruta de acceso almacena los puntos de conexión y los puntos de control de esas splines bézier.

Una ruta de acceso almacena una matriz de puntos de datos, cada una de las cuales pertenece a una línea o a una spline bézier. Si algunos de los puntos de la matriz pertenecen a splines bézier, HasCurve devuelve true. Si todos los puntos de la matriz pertenecen a líneas, HasCurve devuelve false.

Algunos métodos aplanan una ruta de acceso, lo que significa que todas las curvas de la ruta de acceso se convierten en secuencias de líneas. Después de aplanar una ruta de acceso, HasCurve siempre devolverá false. Al llamar al método Flatten, Wideno Warp de la clase GraphicsPath se aplanará una ruta de acceso.

Se aplica a