Matrix.Translate Método
Definição
Sobrecargas
| Translate(Single, Single) |
Aplica-se do vetor de conversão especificado ( |
| Translate(Single, Single, MatrixOrder) |
Aplica-se o vetor de conversão especificada a este Matrix na ordem especificada.Applies the specified translation vector to this Matrix in the specified order. |
Translate(Single, Single)
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
- offsetX
- Single
O valor de x pelo qual converter esse Matrix.The x value by which to translate this Matrix.
- offsetY
- Single
O valor de y pelo qual converter esse Matrix.The y value by which to translate this Matrix.
Exemplos
Para ver um exemplo, consulte Translate(Single, Single, MatrixOrder).For an example, see Translate(Single, Single, MatrixOrder).
Aplica-se a
Translate(Single, Single, MatrixOrder)
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
- offsetX
- Single
O valor de x pelo qual converter esse Matrix.The x value by which to translate this Matrix.
- offsetY
- Single
O valor de y pelo qual converter esse Matrix.The y value by which to translate this Matrix.
- order
- MatrixOrder
Um MatrixOrder que especifica a ordem (suceder ou preceder) em que a translação é aplicada a este Matrix.A MatrixOrder that specifies the order (append or prepend) in which the translation is applied to this Matrix.
Exemplos
O exemplo de código a seguir foi projetado para uso com Windows Forms, e ele requer PaintEventArgs e um Paint objeto de evento.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an Paint event object. O código executa as seguintes ações:The code performs the following actions:
Desenha um retângulo na tela antes de aplicar uma transformação de conversão (o retângulo azul).Draws a rectangle to the screen prior to applying a translate transform (the blue rectangle).
Cria uma matriz e a traduz por 100 em ambos os eixos.Creates a matrix and translates it by 100 in both axes.
Aplica essa transformação de matriz ao retângulo,Applies this matrix transform to the rectangle,
Desenha o retângulo transformado na tela (o retângulo vermelho).Draws the transformed rectangle to the screen (the red rectangle).
Observe que o início do retângulo vermelho está localizado 100 pontos em ambos os eixos desde o início do triângulo azul.Notice that the beginning of the red rectangle is located 100 points in both axes from the beginning of the blue triangle.
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