GraphicsPathIterator.HasCurve Método

Definição

Indica se o caminho associado a este GraphicsPathIterator contém ou não uma curva.

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

Retornos

Este método retorna true se subcaminho atual contém uma curva; caso contrário, false.

Exemplos

O exemplo a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, um OnPaint objeto de evento. O código executa as seguintes ações:

  • Cria um GraphicsPath objeto , myPath.

  • Adiciona três linhas, um retângulo e uma elipse.

  • Cria um GraphicsPathIterator objeto para myPath.

  • Testa para ver se o caminho myPath atual contém uma curva.

  • Mostra o resultado do teste em uma caixa de mensagem.

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

Comentários

Todas as curvas em um caminho são armazenadas como sequências de splines Bézier. Por exemplo, quando você adiciona uma elipse a um caminho, especifica o canto superior esquerdo, a largura e a altura do retângulo delimitador da elipse. Esses números (canto superior esquerdo, largura e altura) não são armazenados no caminho; Ao invés; a elipse é convertida em uma sequência de quatro splines Bézier. O caminho armazena os pontos de extremidade e pontos de controle desses splines Bézier.

Um caminho armazena uma matriz de pontos de dados, cada um dos quais pertence a uma linha ou um spline Bézier. Se alguns dos pontos na matriz pertencerem a splines Bézier, retornará HasCurvetrue. Se todos os pontos na matriz pertencerem a linhas, retornará HasCurvefalse.

Determinados métodos mesclam um caminho, o que significa que todas as curvas no caminho são convertidas em sequências de linhas. Depois que um caminho tiver sido mesclado, HasCurve sempre retornará false. Chamar o Flattenmétodo , Widenou Warp da GraphicsPath classe achatará um caminho.

Aplica-se a