Graphics.TranslateTransform Metoda

Definicja

Zmienia początek układu współrzędnych, poprzedzając określone tłumaczenie do macierzy transformacji tego Graphicselementu .

Przeciążenia

TranslateTransform(Single, Single, MatrixOrder)

Zmienia początek układu współrzędnych, stosując określone tłumaczenie do macierzy przekształceń w Graphics określonej kolejności.

TranslateTransform(Single, Single)

Zmienia początek układu współrzędnych, poprzedzając określone tłumaczenie do macierzy transformacji tego Graphicselementu .

TranslateTransform(Single, Single, MatrixOrder)

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

Zmienia początek układu współrzędnych, stosując określone tłumaczenie do macierzy przekształceń w Graphics określonej kolejności.

public:
 void TranslateTransform(float dx, float dy, System::Drawing::Drawing2D::MatrixOrder order);
public void TranslateTransform (float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order);
member this.TranslateTransform : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub TranslateTransform (dx As Single, dy As Single, order As MatrixOrder)

Parametry

dx
Single

Współrzędna x tłumaczenia.

dy
Single

Współrzędna y tłumaczenia.

order
MatrixOrder

MatrixOrder Element członkowski wyliczenia, który określa, czy tłumaczenie jest prependowane, czy dołączane do macierzy przekształceń.

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgseparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:

  • Obraca macierz transformacji świata formularza systemu Windows o 30,0 stopni.

  • Przenosi początek obiektu graficznego przez wywołanie TranslateTransformmetody , dołączając tłumaczenie do macierzy transformacji świata.

  • Rysuje obrócony, przetłumaczony wielokropek niebieskim piórem.

public:
   void TranslateTransformAngleMatrixOrder( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to rotate.
      e->Graphics->RotateTransform( 30.0F );

      // Then to translate, appending to world transform.
      e->Graphics->TranslateTransform( 100.0F, 0.0F, MatrixOrder::Append );

      // Draw rotated, translated ellipse to screen.
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), 0, 0, 200, 80 );
   }
private void TranslateTransformAngleMatrixOrder(PaintEventArgs e)
{

    // Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F);

    // Then to translate, appending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F, MatrixOrder.Append);

    // Draw rotated, translated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}
Private Sub TranslateTransformAngleMatrixOrder(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F)

    ' Then to translate, appending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F, MatrixOrder.Append)

    ' Draw rotated, translated ellipse to screen.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub

Uwagi

Operacja tłumaczenia składa się z mnożenia macierzy transformacji przez macierz, której część tłumaczenia jest dx parametrami i dy . Ta metoda poprzedza lub dołącza macierz Graphics przekształceń macierzy translacji zgodnie z parametrem order .

Zobacz też

Dotyczy

TranslateTransform(Single, Single)

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

Zmienia początek układu współrzędnych, poprzedzając określone tłumaczenie do macierzy transformacji tego Graphicselementu .

public:
 void TranslateTransform(float dx, float dy);
public void TranslateTransform (float dx, float dy);
member this.TranslateTransform : single * single -> unit
Public Sub TranslateTransform (dx As Single, dy As Single)

Parametry

dx
Single

Współrzędna x tłumaczenia.

dy
Single

Współrzędna y tłumaczenia.

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgseparametru Paint programu obsługi zdarzeń. Kod wykonuje następujące akcje:

  • Obraca macierz transformacji świata formularza systemu Windows o 30,0 stopni.

  • Przenosi początek obiektu graficznego przez wywołanie TranslateTransformmetody , co powoduje przeniesienie translacji do macierzy przekształceń.

  • Rysuje przetłumaczony, obracany wielokropek z niebieskim piórem.

public:
   void TranslateTransformAngle( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to rotate.
      e->Graphics->RotateTransform( 30.0F );

      // Then to translate, prepending to world transform.
      e->Graphics->TranslateTransform( 100.0F, 0.0F );

      // Draw translated, rotated ellipse to screen.
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), 0, 0, 200, 80 );
   }
private void TranslateTransformAngle(PaintEventArgs e)
{

    // Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F);

    // Then to translate, prepending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F);

    // Draw translated, rotated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}
Private Sub TranslateTransformAngle(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F)

    ' Then to translate, prepending to world transform.
    e.Graphics.TranslateTransform(100.0F, 0.0F)

    ' Draw translated, rotated ellipse to screen.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub

Na poniższej ilustracji przedstawiono dane wyjściowe uruchamiania poprzedniego przykładu kodu.

Przetłumaczony i przekształcony wielokropek

Uwagi

Początek jest zazwyczaj lewym górnym róg powierzchni rysunkowej. Operacja tłumaczenia składa się z mnożenia macierzy transformacji przez macierz, której część tłumaczenia jest dx parametrami i dy . Ta metoda stosuje tłumaczenie przez wstępne przypisywanie macierzy tłumaczenia do macierzy przekształceń.

Zobacz też

Dotyczy