Graphics.TranslateTransform Méthode

Définition

Modifie l'origine du système de coordonnées en ajoutant la translation spécifiée avant la matrice de transformation de ce Graphics.

Surcharges

TranslateTransform(Single, Single, MatrixOrder)

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

TranslateTransform(Single, Single)

Modifie l'origine du système de coordonnées en ajoutant la translation spécifiée avant la matrice de transformation de ce Graphics.

TranslateTransform(Single, Single, MatrixOrder)

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

Modifie l'origine du système de coordonnées en appliquant la translation spécifiée à la matrice de transformation de ce 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 translation.

dy
Single

Coordonnée y de la translation.

order
MatrixOrder

Membre de l'énumération MatrixOrder qui spécifie si la translation est ajoutée au début ou à la fin de 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 Paint gestionnaire d’événements. Le code effectue les actions suivantes :

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

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

  • Dessine une ellipse pivotée et traduite 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 les dx paramètres et dy . Cette méthode ajoute ou ajoute la matrice de transformation du Graphics par la matrice de traduction en fonction du order paramètre .

Voir aussi

S’applique à

TranslateTransform(Single, Single)

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

Modifie l'origine du système de coordonnées en ajoutant la translation spécifiée avant la matrice de transformation de ce 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 translation.

dy
Single

Coordonnée y de la translation.

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 Paint gestionnaire d’événements. Le code effectue les actions suivantes :

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

  • Déplace l’origine de l’objet graphics en appelant TranslateTransform, avant la traduction vers la matrice de transformation.

  • Dessine une ellipse convertie et pivotée 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.

Ellipse traduite et transformée 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 les dx paramètres et dy . Cette méthode applique la traduction en préparant la matrice de traduction à la matrice de transformation.

Voir aussi

S’applique à