Matrix.Translate 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 o vetor de translação especificado a este Matrix ao anteceder o vetor de translação.
Sobrecargas
| Name | Description |
|---|---|
| Translate(Single, Single) |
Aplica o vetor de translação especificado ( |
| Translate(Single, Single, MatrixOrder) |
Aplica o vetor de translação especificado a isto Matrix na ordem especificada. |
Translate(Single, Single)
Aplica o vetor de translação especificado (offsetX e offsetY) a isto Matrix ao preencher o vetor de translação.
public:
void Translate(float offsetX, float offsetY);
public void Translate(float offsetX, float offsetY);
member this.Translate : single * single -> unit
Public Sub Translate (offsetX As Single, offsetY As Single)
Parâmetros
Exemplos
Para obter um exemplo, consulte Translate(Single, Single, MatrixOrder).
Aplica-se a
Translate(Single, Single, MatrixOrder)
Aplica o vetor de translação especificado a isto Matrix na ordem especificada.
public:
void Translate(float offsetX, float offsetY, System::Drawing::Drawing2D::MatrixOrder order);
public void Translate(float offsetX, float offsetY, System.Drawing.Drawing2D.MatrixOrder order);
member this.Translate : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub Translate (offsetX As Single, offsetY As Single, order As MatrixOrder)
Parâmetros
- order
- MatrixOrder
A MatrixOrder que especifica a ordem (anexar ou prepender) em que a tradução é aplicada a este Matrix.
Exemplos
O seguinte exemplo de código foi concebido para uso com Windows Forms e requer PaintEventArgse, um objeto de evento Paint. O código executa as seguintes ações:
Desenha um retângulo para o ecrã antes de aplicar uma transformação de translação (o retângulo azul).
Cria uma matriz e traduz-a por 100 em ambos os eixos.
Aplica esta transformação matricial ao retângulo,
Desenha o retângulo transformado para o ecrã (o retângulo vermelho).
Note que o início do retângulo vermelho está localizado a 100 pontos em ambos os eixos em relação ao início do triângulo azul.
public:
void TranslateExample( PaintEventArgs^ e )
{
Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );
// Draw a rectangle to the screen before applying the
// transform.
e->Graphics->DrawRectangle( myPen, 20, 20, 100, 50 );
// Create a matrix and translate it.
Matrix^ myMatrix = gcnew Matrix;
myMatrix->Translate( 100, 100, MatrixOrder::Append );
// Draw the Points to the screen again after applying the
// transform.
e->Graphics->Transform = myMatrix;
e->Graphics->DrawRectangle( myPen2, 20, 20, 100, 50 );
}
public void TranslateExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
// Draw a rectangle to the screen before applying the
// transform.
e.Graphics.DrawRectangle(myPen, 20, 20, 100, 50);
// Create a matrix and translate it.
Matrix myMatrix = new Matrix();
myMatrix.Translate(100, 100, MatrixOrder.Append);
// Draw the Points to the screen again after applying the
// transform.
e.Graphics.Transform = myMatrix;
e.Graphics.DrawRectangle(myPen2, 20, 20, 100, 50);
}
Public Sub TranslateExample(ByVal e As PaintEventArgs)
Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
' Draw a rectangle to the screen before applying the
' transform.
e.Graphics.DrawRectangle(myPen, 20, 20, 100, 50)
' Create a matrix and translate it.
Dim myMatrix As New Matrix
myMatrix.Translate(100, 100, MatrixOrder.Append)
' Draw the Points to the screen again after applying the
' transform.
e.Graphics.Transform = myMatrix
e.Graphics.DrawRectangle(myPen2, 20, 20, 100, 50)
End Sub