Matrix.Translate Método

Definición

Aplica el vector de conversión especificado a esta Matrix anteponiendo el vector de conversión.

Sobrecargas

Translate(Single, Single)

Aplica el vector de conversión especificado (offsetX y offsetY) a esta Matrix anteponiendo el vector de conversión.

Translate(Single, Single, MatrixOrder)

Aplica el vector de conversión especificado a esta Matrix en el orden especificado.

Translate(Single, Single)

Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs

Aplica el vector de conversión especificado (offsetX y offsetY) a esta Matrix anteponiendo el vector de conversión.

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

Valor x por el que se va a convertir este objeto Matrix.

offsetY
Single

Valor y por el que se va a convertir este objeto Matrix.

Ejemplos

Para obtener un ejemplo, consulte Translate(Single, Single, MatrixOrder).

Se aplica a

Translate(Single, Single, MatrixOrder)

Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs

Aplica el vector de conversión especificado a esta Matrix en el orden especificado.

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

Valor x por el que se va a convertir este objeto Matrix.

offsetY
Single

Valor y por el que se va a convertir este objeto Matrix.

order
MatrixOrder

Un MatrixOrder que especifica el orden (agregar o anteponer) en el que se aplica la conversión a esta Matrix.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, un Paint objeto de evento. El código realiza las siguientes acciones:

  • Dibuja un rectángulo en la pantalla antes de aplicar una transformación de traducción (el rectángulo azul).

  • Crea una matriz y la traduce en 100 ejes.

  • Aplica esta transformación de matriz al rectángulo,

  • Dibuja el rectángulo transformado en la pantalla (el rectángulo rojo).

Observe que el principio del rectángulo rojo se encuentra 100 puntos en ambos ejes desde el principio del 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

Se aplica a