LinearGradientBrush.TranslateTransform Méthode

Définition

Effectue la translation de la transformation géométrique locale selon les dimensions spécifiées. Cette méthode ajoute la translation avant la transformation.

Surcharges

TranslateTransform(Single, Single, MatrixOrder)

Effectue la translation de la transformation géométrique locale selon les dimensions spécifiées dans l'ordre donné.

TranslateTransform(Single, Single)

Effectue la translation de la transformation géométrique locale selon les dimensions spécifiées. Cette méthode ajoute la translation avant la transformation.

TranslateTransform(Single, Single, MatrixOrder)

Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs

Effectue la translation de la transformation géométrique locale selon les dimensions spécifiées dans l'ordre donné.

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

Valeur de la translation sur l'axe x.

dy
Single

Valeur de la translation sur l'axe y.

order
MatrixOrder

Ordre (ajout au début ou à la fin) dans lequel la translation doit être appliquée.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, un objet d’événementOnPaint. Le code effectue les actions suivantes :

  • Crée un LinearGradientBrush.

  • Utilise ce pinceau pour dessiner un rectangle vers l’écran qui a une transition linéaire de couleurs de gauche à droite.

  • Fait pivoter le LinearGradientBrush de 90 degrés et met à l’échelle le dégradé.

  • Dessine le rectangle, avec le dégradé pivoté et mis à l’échelle, vers l’écran.

  • Traduit le rectangle afin qu’il ait un dégradé linéaire s’exécutant de haut en bas.

  • Dessine le rectangle traduit à l’écran.

Notez que trois rectangles s’affichent : celui du haut montrant le dégradé de gauche à droite, celui du milieu montrant le dégradé pivoté et mis à l’échelle, et celui du bas montrant le dégradé traduit final.

private:
   void TranslateTransformExample( PaintEventArgs^ e )
   {
      // Create a LinearGradientBrush.
      Rectangle myRect = Rectangle(20,20,200,100);
      LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true );

      // Draw a rectangle to the screen using the LinearGradientBrush.
      e->Graphics->FillRectangle( myLGBrush, myRect );

      // Rotate the LinearGradientBrush.
      myLGBrush->RotateTransform( 90.0f );

      // Scale the gradient for the height of the rectangle.
      myLGBrush->ScaleTransform( 0.5f, 1.0f );

      // Draw to the screen, the rotated and scaled gradient.
      e->Graphics->FillRectangle( myLGBrush, 20, 150, 200, 100 );

      // Rejustify the brush to start at the top edge of the
      // rectangle.
      myLGBrush->TranslateTransform(  -20.0f, 0.0f );

      // Draw a third rectangle to the screen using the translated
      // brush.
      e->Graphics->FillRectangle( myLGBrush, 20, 300, 200, 100 );
   }
private void TranslateTransformExample(PaintEventArgs e)
{
             
    // Create a LinearGradientBrush.
    Rectangle myRect = new Rectangle(20, 20, 200, 100);
    LinearGradientBrush myLGBrush = new LinearGradientBrush(
        myRect, Color.Blue, Color.Red,  0.0f, true);
             
    // Draw a rectangle to the screen using the LinearGradientBrush.
    e.Graphics.FillRectangle(myLGBrush, myRect);
             
    // Rotate the LinearGradientBrush.
    myLGBrush.RotateTransform(90.0f);
             
    // Scale the gradient for the height of the rectangle.
    myLGBrush.ScaleTransform(0.5f, 1.0f);
             
    // Draw to the screen, the rotated and scaled gradient.
    e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100);
             
    // Rejustify the brush to start at the top edge of the
    // rectangle.
    myLGBrush.TranslateTransform(-20.0f, 0.0f);
             
    // Draw a third rectangle to the screen using the translated
    // brush.
    e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100);
}
Public Sub TranslateTransformExample(ByVal e As PaintEventArgs)

    ' Create a LinearGradientBrush.
    Dim myRect As New Rectangle(20, 20, 200, 100)
    Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
    Color.Red, 0.0F, True)

    ' Draw a rectangle to the screen using the LinearGradientBrush.
    e.Graphics.FillRectangle(myLGBrush, myRect)

    ' Rotate the LinearGradientBrush.
    myLGBrush.RotateTransform(90.0F)

    ' Scale the gradient for the height of the rectangle.
    myLGBrush.ScaleTransform(0.5F, 1.0F)

    ' Draw to the screen, the rotated and scaled gradient.
    e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100)

    ' Rejustify the brush to start at the top edge of the rectangle.
    myLGBrush.TranslateTransform(-20.0F, 0.0F)

    ' Draw a third rectangle to the screen using the translated brush.
    e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100)
End Sub

S’applique à

TranslateTransform(Single, Single)

Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs

Effectue la translation de la transformation géométrique locale selon les dimensions spécifiées. Cette méthode ajoute la translation avant la transformation.

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

Valeur de la translation sur l'axe x.

dy
Single

Valeur de la translation sur l'axe y.

Exemples

Pour obtenir un exemple, consultez TranslateTransform.

S’applique à