GraphicsPath.StartFigure Metodo

Definizione

Inizia una nuova figura senza chiudere quella corrente. Tutti i punti successivi aggiunti al percorso vengono aggiunti a questa nuova figura.

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

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, un OnPaint oggetto evento. Il codice esegue le azioni seguenti:

  • Crea un percorso.

  • Aggiunge due set di figure. Il primo set di figure combina quattro primitive in due figure. Il secondo set di figure combina le stesse quattro primitive (ad eccezione del fatto che sono offset nell'asse y) in tre figure.

  • Disegna tutte le figure sullo schermo.

Si noti la differenza nell'aspetto tra i due set di figure.

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

Commenti

L'utente deve mantenere i punti originali se necessari. I punti originali vengono convertiti in punti di controllo Bézier cubici internamente, pertanto non esiste alcun meccanismo per restituire i punti originali.

Questo metodo avvia un nuovo sottopath nel percorso. I percorsi secondari consentono di separare un percorso in sezioni e usare la GraphicsPathIterator classe per scorrere i percorsi secondari.

Si applica a