GraphicsPath.StartFigure Método

Definição

Inicia uma nova figura sem fechar a figura atual. Todos os pontos subsequentes adicionados ao caminho são adicionados a essa nova figura.

public:
 void StartFigure();
public void StartFigure ();
member this.StartFigure : unit -> unit
Public Sub StartFigure ()

Exemplos

O exemplo de código 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 caminho.

  • Adiciona dois conjuntos de figuras. O primeiro conjunto de figuras combina quatro primitivos em duas figuras. O segundo conjunto de figuras combina os mesmos quatro primitivos (exceto que eles são deslocados no eixo y) em três dígitos.

  • Desenha todas as figuras para a tela.

Observe a diferença na aparência entre os dois conjuntos de figuras.

public:
   void StartFigureExample( PaintEventArgs^ e )
   {
      // Create a GraphicsPath object.
      GraphicsPath^ myPath = gcnew GraphicsPath;

      // First set of figures.
      myPath->StartFigure();
      myPath->AddArc( 10, 10, 50, 50, 0, 270 );
      myPath->AddLine( Point(50,0), Point(100,50) );
      myPath->AddArc( 50, 100, 75, 75, 0, 270 );
      myPath->CloseFigure();
      myPath->StartFigure();
      myPath->AddArc( 100, 10, 50, 50, 0, 270 );

      // Second set of figures.
      myPath->StartFigure();
      myPath->AddArc( 10, 200, 50, 50, 0, 270 );
      myPath->CloseFigure();
      myPath->StartFigure();
      myPath->AddLine( Point(60,200), Point(110,250) );
      myPath->AddArc( 50, 300, 75, 75, 0, 270 );
      myPath->CloseFigure();
      myPath->StartFigure();
      myPath->AddArc( 100, 200, 50, 50, 0, 270 );

      // Draw the path to the screen.
      e->Graphics->DrawPath( gcnew Pen( Color::Black ), myPath );
   }
   // End StartFigureExample
public void StartFigureExample(PaintEventArgs e)
{
             
    // Create a GraphicsPath object.
    GraphicsPath myPath = new GraphicsPath();
             
    // First set of figures.
    myPath.StartFigure();
    myPath.AddArc(10, 10, 50, 50, 0, 270);
    myPath.AddLine(new Point(50, 0), new Point(100, 50));
    myPath.AddArc(50, 100, 75, 75, 0, 270);
    myPath.CloseFigure();
    myPath.StartFigure();
    myPath.AddArc(100, 10, 50, 50, 0, 270);
             
    // Second set of figures.
    myPath.StartFigure();
    myPath.AddArc(10, 200, 50, 50, 0, 270);
    myPath.CloseFigure();
    myPath.StartFigure();
    myPath.AddLine(new Point(60, 200), new Point(110, 250));
    myPath.AddArc(50, 300, 75, 75, 0, 270);
    myPath.CloseFigure();
    myPath.StartFigure();
    myPath.AddArc(100, 200, 50, 50, 0, 270);
             
    // Draw the path to the screen.
    e.Graphics.DrawPath(new Pen(Color.Black), myPath);
} 
// End StartFigureExample
Public Sub StartFigureExample(ByVal e As PaintEventArgs)

    ' Create a GraphicsPath object.
    Dim myPath As New GraphicsPath

    ' First set of figures.
    myPath.StartFigure()
    myPath.AddArc(10, 10, 50, 50, 0, 270)
    myPath.AddLine(New Point(50, 0), New Point(100, 50))
    myPath.AddArc(50, 100, 75, 75, 0, 270)
    myPath.CloseFigure()
    myPath.StartFigure()
    myPath.AddArc(100, 10, 50, 50, 0, 270)

    ' Second set of figures.
    myPath.StartFigure()
    myPath.AddArc(10, 200, 50, 50, 0, 270)
    myPath.CloseFigure()
    myPath.StartFigure()
    myPath.AddLine(New Point(60, 200), New Point(110, 250))
    myPath.AddArc(50, 300, 75, 75, 0, 270)
    myPath.CloseFigure()
    myPath.StartFigure()
    myPath.AddArc(100, 200, 50, 50, 0, 270)

    ' Draw the path to the screen.
    e.Graphics.DrawPath(New Pen(Color.Black), myPath)
End Sub

Comentários

O usuário deve manter os pontos originais se necessário. Os pontos originais são convertidos em pontos de controle Bézier cúbicos internamente, portanto, não há mecanismo para retornar os pontos originais.

Esse método inicia um novo subcaminho no caminho. Os subcaminhos permitem separar um caminho em seções e usar a GraphicsPathIterator classe para iterar por meio dos subcaminhos.

Aplica-se a