Partager via


Graphics.TranslateTransform Méthode

Définition

Modifie l’origine du système de coordonnées en préparant la traduction spécifiée vers la matrice de transformation de cette Graphics.

Surcharges

TranslateTransform(Single, Single, MatrixOrder)

Modifie l’origine du système de coordonnées en appliquant la traduction spécifiée à la matrice de transformation de cette Graphics dans l’ordre spécifié.

TranslateTransform(Single, Single)

Modifie l’origine du système de coordonnées en préparant la traduction spécifiée vers la matrice de transformation de cette Graphics.

TranslateTransform(Single, Single, MatrixOrder)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Modifie l’origine du système de coordonnées en appliquant la traduction spécifiée à la matrice de transformation de cette Graphics dans l’ordre spécifié.

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)

Paramètres

dx
Single

Coordonnée x de la traduction.

dy
Single

Coordonnée y de la traduction.

order
MatrixOrder

Membre de l’énumération MatrixOrder qui spécifie si la traduction est ajoutée ou ajoutée à la matrice de transformation.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d’événements Paint. Le code effectue les actions suivantes :

  • Fait pivoter la matrice de transformation mondiale de Windows Form de 30,0F degrés.

  • Déplace l’origine de l’objet graphique en appelant TranslateTransform, en ajoutant la traduction à la matrice de transformation mondiale.

  • Dessine un ellipse pivoté et traduit avec un stylet bleu.

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

Remarques

L’opération de traduction consiste à multiplier la matrice de transformation par une matrice dont la partie de traduction est la dx et les paramètres dy. Cette méthode précède ou ajoute la matrice de transformation de l'Graphics par la matrice de traduction en fonction du paramètre order.

Voir aussi

S’applique à

TranslateTransform(Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Modifie l’origine du système de coordonnées en préparant la traduction spécifiée vers la matrice de transformation de cette Graphics.

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)

Paramètres

dx
Single

Coordonnée x de la traduction.

dy
Single

Coordonnée y de la traduction.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d’événements Paint. Le code effectue les actions suivantes :

  • Fait pivoter la matrice de transformation mondiale de Windows Form de 30,0F degrés.

  • Déplace l’origine de l’objet graphique en appelant TranslateTransform, en préparant la traduction vers la matrice de transformation.

  • Dessine un ellipse traduit et pivoté avec un stylet bleu.

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

L’illustration suivante montre la sortie de l’exécution de l’exemple de code précédent.

Traduit et transformé ellipse

Remarques

L’origine est généralement le coin supérieur gauche de la surface de dessin. L’opération de traduction consiste à multiplier la matrice de transformation par une matrice dont la partie de traduction est la dx et les paramètres dy. Cette méthode applique la traduction en préparant la matrice de traduction à la matrice de transformation.

Voir aussi

S’applique à