GraphicsPath.Transform(Matrix) 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.
Aplica uma matriz de transformação a esta GraphicsPath.
public:
void Transform(System::Drawing::Drawing2D::Matrix ^ matrix);
public void Transform(System.Drawing.Drawing2D.Matrix matrix);
member this.Transform : System.Drawing.Drawing2D.Matrix -> unit
Public Sub Transform (matrix As Matrix)
Parâmetros
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 e adiciona uma elipse ao caminho.
Desenha o caminho até ao ecrã.
Cria uma matriz de transformação para translar o caminho 100 unidades na direção do eixo x.
Desenha o caminho transformado até ao ecrã.
Note que a elipse original está desenhada a preto e a elipse transformada é desenhada a vermelho.
private:
void TransformExample( PaintEventArgs^ e )
{
// Create a path and add and ellipse.
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->AddEllipse( 0, 0, 100, 200 );
// Draw the starting position to screen.
e->Graphics->DrawPath( Pens::Black, myPath );
// Move the ellipse 100 points to the right.
Matrix^ translateMatrix = gcnew Matrix;
translateMatrix->Translate( 100, 0 );
myPath->Transform(translateMatrix);
// Draw the transformed ellipse to the screen.
e->Graphics->DrawPath( gcnew Pen( Color::Red,2.0f ), myPath );
}
private void TransformExample(PaintEventArgs e)
{
// Create a path and add and ellipse.
GraphicsPath myPath = new GraphicsPath();
myPath.AddEllipse(0, 0, 100, 200);
// Draw the starting position to screen.
e.Graphics.DrawPath(Pens.Black, myPath);
// Move the ellipse 100 points to the right.
Matrix translateMatrix = new Matrix();
translateMatrix.Translate(100, 0);
myPath.Transform(translateMatrix);
// Draw the transformed ellipse to the screen.
e.Graphics.DrawPath(new Pen(Color.Red, 2), myPath);
}
Public Sub TransformExample(ByVal e As PaintEventArgs)
' Create a path and add and ellipse.
Dim myPath As New GraphicsPath
myPath.AddEllipse(0, 0, 100, 200)
' Draw the starting position to screen.
e.Graphics.DrawPath(Pens.Black, myPath)
' Move the ellipse 100 points to the right.
Dim translateMatrix As New Matrix
translateMatrix.Translate(100, 0)
myPath.Transform(translateMatrix)
' Draw the transformed ellipse to the screen.
e.Graphics.DrawPath(New Pen(Color.Red, 2), myPath)
End Sub
Observações
A transformação pode escalar, translação, rodar ou distorcer o GraphicsPath.