Matrix.Translate 메서드

정의

이동 벡터를 앞에 추가하여 지정된 이동 벡터를 이 Matrix에 적용합니다.Applies the specified translation vector to this Matrix by prepending the translation vector.

오버로드

Translate(Single, Single)

이동 벡터를 앞에 추가하여 지정된 이동 벡터(offsetXoffsetY)를 이 Matrix에 적용합니다.Applies the specified translation vector (offsetX and offsetY) to this Matrix by prepending the translation vector.

Translate(Single, Single, MatrixOrder)

지정된 순서대로 지정된 이동 벡터를 이 Matrix에 적용합니다.Applies the specified translation vector to this Matrix in the specified order.

Translate(Single, Single)

이동 벡터를 앞에 추가하여 지정된 이동 벡터(offsetXoffsetY)를 이 Matrix에 적용합니다.Applies the specified translation vector (offsetX and offsetY) to this Matrix by prepending the translation vector.

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)

매개 변수

offsetX
Single

Matrix를 이동할 x 값입니다.The x value by which to translate this Matrix.

offsetY
Single

Matrix를 이동할 y 값입니다.The y value by which to translate this Matrix.

예제

예를 보려면 Translate(Single, Single, MatrixOrder)을 참조하세요.For an example, see Translate(Single, Single, MatrixOrder).

Translate(Single, Single, MatrixOrder)

지정된 순서대로 지정된 이동 벡터를 이 Matrix에 적용합니다.Applies the specified translation vector to this Matrix in the specified order.

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)

매개 변수

offsetX
Single

Matrix를 이동할 x 값입니다.The x value by which to translate this Matrix.

offsetY
Single

Matrix를 이동할 y 값입니다.The y value by which to translate this Matrix.

order
MatrixOrder

MatrixOrder에 이동이 적용되는 순서(뒤나 앞에 추가)를 지정하는 Matrix입니다.A MatrixOrder that specifies the order (append or prepend) in which the translation is applied to this Matrix.

예제

다음 코드 예제는 Windows Forms와 함께 사용 하도록 설계 되었으며 Paint 이벤트 개체 PaintEventArgse필요 합니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an Paint event object. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • 좌표 이동 변환 (파란색 사각형)를 적용 하기 전에 화면에 사각형을 그립니다.Draws a rectangle to the screen prior to applying a translate transform (the blue rectangle).

  • 행렬을 만들고 양쪽 축에서 100으로 변환 합니다.Creates a matrix and translates it by 100 in both axes.

  • 이 매트릭스 변환을 사각형에 적용 됩니다.Applies this matrix transform to the rectangle,

  • 화면 (빨간색 사각형)으로 변환된 된 사각형을 그립니다.Draws the transformed rectangle to the screen (the red rectangle).

빨간색 사각형의 시작 부분에 있는 요소가 100 개부터 양쪽 축에서 파란색 삼각형은 인지 확인 합니다.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

적용 대상