Matrix.Translate Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Applique le vecteur de translation spécifié à ce Matrix en l'ajoutant au début.
Surcharges
Translate(Single, Single) |
Applique le vecteur de translation spécifié ( |
Translate(Single, Single, MatrixOrder) |
Applique le vecteur de translation spécifié à ce Matrix dans l'ordre spécifié. |
Translate(Single, Single)
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
Applique le vecteur de translation spécifié (offsetX
et offsetY
) à ce Matrix en l'ajoutant au début.
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)
Paramètres
Exemples
Pour obtenir un exemple, consultez Translate(Single, Single, MatrixOrder).
S’applique à
Translate(Single, Single, MatrixOrder)
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
Applique le vecteur de translation spécifié à ce Matrix dans l'ordre spécifié.
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)
Paramètres
- order
- MatrixOrder
MatrixOrder qui spécifie l'ordre (ajout au début ou à la fin) dans lequel la translation est appliquée à ce Matrix.
Exemples
L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse
, un objet d’événementPaint. Le code effectue les actions suivantes :
Dessine un rectangle vers l’écran avant d’appliquer une transformation de traduction (rectangle bleu).
Crée une matrice et la traduit par 100 dans les deux axes.
Applique cette transformation de matrice au rectangle,
Dessine le rectangle transformé à l’écran (rectangle rouge).
Notez que le début du rectangle rouge se trouve à 100 points dans les deux axes à partir du début du triangle bleu.
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
S’applique à
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour