LinearGradientBrush.TranslateTransform Método

Definição

Converte a transformação geométrica local pelas dimensões especificadas. Esse método precede a translação à transformação.

Sobrecargas

TranslateTransform(Single, Single, MatrixOrder)

Converte a transformação geométrica local pelas dimensões especificadas na ordem especificada.

TranslateTransform(Single, Single)

Converte a transformação geométrica local pelas dimensões especificadas. Esse método precede a translação à transformação.

TranslateTransform(Single, Single, MatrixOrder)

Origem:
LinearGradientBrush.cs
Origem:
LinearGradientBrush.cs
Origem:
LinearGradientBrush.cs

Converte a transformação geométrica local pelas dimensões especificadas na ordem especificada.

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

O valor da conversão em x.

dy
Single

O valor da conversão em y.

order
MatrixOrder

A ordem (preceder ou acrescentar) em que a translação é aplicada.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, um OnPaint objeto de evento. O código executa as seguintes ações:

  • Cria um novo LinearGradientBrush.

  • Usa esse pincel para desenhar um retângulo para a tela que tem uma transição linear da esquerda para a direita de cores.

  • Gira o LinearGradientBrush em 90 graus e dimensiona o gradiente.

  • Desenha o retângulo, com o gradiente girado e dimensionado, para a tela.

  • Converte o retângulo para que ele tenha um gradiente linear em execução de cima para baixo.

  • Desenha o retângulo traduzido para a tela.

Observe que há três retângulos exibidos na parte superior mostrando o gradiente da esquerda para a direita, o do meio mostrando o gradiente girado e dimensionado e o inferior mostrando o gradiente final traduzido.

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

Aplica-se a

TranslateTransform(Single, Single)

Origem:
LinearGradientBrush.cs
Origem:
LinearGradientBrush.cs
Origem:
LinearGradientBrush.cs

Converte a transformação geométrica local pelas dimensões especificadas. Esse método precede a translação à transformação.

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

O valor da conversão em x.

dy
Single

O valor da conversão em y.

Exemplos

Para ver um exemplo, consulte TranslateTransform.

Aplica-se a