GraphicsPath.StartFigure Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Começa uma nova figura sem fechar a atual. Todos os pontos subsequentes adicionados ao percurso são adicionados a esta nova figura.
public:
void StartFigure();
public void StartFigure();
member this.StartFigure : unit -> unit
Public Sub StartFigure ()
Exemplos
O seguinte exemplo de código foi concebido para uso com Windows Forms e requer PaintEventArgse, um objeto de evento OnPaint. O código executa as seguintes ações:
Cria um caminho.
Adiciona dois conjuntos de figuras. O primeiro conjunto de figuras combina quatro primitivas em duas figuras. O segundo conjunto de figuras combina as mesmas quatro primitivas (exceto que estão deslocadas no eixo y) em três figuras.
Desenha todas as figuras para o ecrã.
Repare na 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
Observações
O utilizador deve manter os pontos originais se forem necessários. Os pontos originais são convertidos internamente em pontos cúbicos de controlo de Bézier, pelo que não existe mecanismo para devolver os pontos originais.
Este método inicia um novo subcaminho no caminho. Os subcaminhos permitem-te separar um caminho em secções e usar a GraphicsPathIterator classe para iterar pelos subcaminhos.