Język

Matrix.Translate Metoda

Definicja

Stosuje określony wektor tłumaczenia do tego Matrix , poprzedzając wektor tłumaczenia.

Przeciążenia

Nazwa Opis
Translate(Single, Single)

Stosuje określony wektor translacji (offsetX i offsetY) do tego Matrix , poprzedzając wektor tłumaczenia.

Translate(Single, Single, MatrixOrder)

Stosuje określony wektor tłumaczenia do tego Matrix w określonej kolejności.

Translate(Single, Single)

Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs

Stosuje określony wektor translacji (offsetX i offsetY) do tego Matrix , poprzedzając wektor tłumaczenia.

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)

Parametry

offsetX
Single

Wartość x, za pomocą której należy przetłumaczyć ten Matrixelement .

offsetY
Single

Wartość y, za pomocą której należy przetłumaczyć ten Matrixelement .

Przykłady

Aby zapoznać się z przykładem, zobacz Translate(Single, Single, MatrixOrder).

Dotyczy

Translate(Single, Single, MatrixOrder)

Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs

Stosuje określony wektor tłumaczenia do tego Matrix w określonej kolejności.

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)

Parametry

offsetX
Single

Wartość x, za pomocą której należy przetłumaczyć ten Matrixelement .

offsetY
Single

Wartość y, za pomocą której należy przetłumaczyć ten Matrixelement .

order
MatrixOrder

Element MatrixOrder określający kolejność (dołączanie lub poprzedzanie), w której tłumaczenie jest stosowane do tego Matrixelementu .

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgse, obiektu zdarzenia Paint. Kod wykonuje następujące akcje:

  • Rysuje prostokąt na ekranie przed zastosowaniem przekształcenia tłumaczenia (niebieski prostokąt).

  • Tworzy macierz i tłumaczy ją o 100 w obu osiach.

  • Stosuje tę transformację macierzy do prostokąta,

  • Rysuje przekształcony prostokąt na ekran (czerwony prostokąt).

Zwróć uwagę, że początek czerwonego prostokąta znajduje się 100 punktów w obu osiach od początku niebieskiego trójkąta.

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

Dotyczy