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)

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 une utilisation avec Windows Forms, et nécessite PaintEventArgs e, un objet d’événementOnPaint. Le code effectue les actions suivantes :

  • Crée un LinearGradientBrush.

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

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

  • Dessine le rectangle, avec le dégradé pivoté et mis à l’échelle, à 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 qu’il existe trois rectangles affichés en haut montrant le dégradé gauche à droite, le milieu montrant le dégradé pivoté et mis à l’échelle, et le bas montrant le dégradé final et traduit.

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)

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 à