Compartir a través de


LinearGradientBrush.TranslateTransform Método

Definición

Convierte la transformación geométrica local en las dimensiones especificadas. Este método antepone la conversión a la transformación.

Sobrecargas

TranslateTransform(Single, Single, MatrixOrder)

Convierte la transformación geométrica local en las dimensiones especificadas en el orden indicado.

TranslateTransform(Single, Single)

Convierte la transformación geométrica local en las dimensiones especificadas. Este método antepone la conversión a la transformación.

TranslateTransform(Single, Single, MatrixOrder)

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

Convierte la transformación geométrica local en las dimensiones especificadas en el orden indicado.

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)

Parámetros

dx
Single

El valor de la conversión en X.

dy
Single

El valor de la conversión en Y.

order
MatrixOrder

El orden (antes o después) en que se va a aplicar la conversión.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, un OnPaint objeto de evento. El código realiza las siguientes acciones:

  • Crea un nuevo LinearGradientBrush.

  • Usa este pincel para dibujar un rectángulo en la pantalla que tiene una transición lineal de izquierda a derecha de colores.

  • Gira en LinearGradientBrush 90 grados y escala el degradado.

  • Dibuja el rectángulo, con el degradado girado y escalado, en la pantalla.

  • Convierte el rectángulo para que tenga un degradado lineal que se ejecuta de arriba a abajo.

  • Dibuja el rectángulo traducido en la pantalla.

Observe que hay tres rectángulos mostrados en la parte superior que muestran el degradado de izquierda a derecha, el medio que muestra el degradado girado y escalado, y el inferior que muestra el degradado final traducido.

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

Se aplica a

TranslateTransform(Single, Single)

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

Convierte la transformación geométrica local en las dimensiones especificadas. Este método antepone la conversión a la transformación.

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)

Parámetros

dx
Single

El valor de la conversión en X.

dy
Single

El valor de la conversión en Y.

Ejemplos

Para obtener un ejemplo, consulte TranslateTransform.

Se aplica a