GraphicsPathIterator.HasCurve Método

Definición

Indica si el trazado asociado a este objeto GraphicsPathIterator contiene una curva.

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

Devoluciones

Boolean

Este método devuelve true si el subtrazado actual contiene una curva; en caso contrario, false.

Ejemplos

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

  • Crea un GraphicsPath objeto , myPath.

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

  • Crea un GraphicsPathIterator objeto para myPath.

  • Comprueba si la ruta de acceso myPath actual 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, se especifica 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 su lugar; 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.

Ciertos métodos aplanan una ruta de acceso, lo que significa que todas las curvas del trazado se convierten en secuencias de líneas. Una vez que se haya aplanado una ruta de acceso, HasCurve siempre devolverá false. Al llamar al Flattenmétodo , Wideno Warp de la GraphicsPath clase se aplanará una ruta de acceso.

Se aplica a