Condividi tramite


LinearGradientBrush.TranslateTransform Metodo

Definizione

Sottopone a traslazione la trasformazione geometrica locale in base alle dimensioni specificate. Questo metodo antepone la traslazione alla trasformazione.

Overload

TranslateTransform(Single, Single, MatrixOrder)

Sottopone a traslazione la trasformazione geometrica locale in base alle dimensioni specificate nell'ordine indicato.

TranslateTransform(Single, Single)

Sottopone a traslazione la trasformazione geometrica locale in base alle dimensioni specificate. Questo metodo antepone la traslazione alla trasformazione.

TranslateTransform(Single, Single, MatrixOrder)

Origine:
LinearGradientBrush.cs
Origine:
LinearGradientBrush.cs
Origine:
LinearGradientBrush.cs

Sottopone a traslazione la trasformazione geometrica locale in base alle dimensioni specificate nell'ordine indicato.

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)

Parametri

dx
Single

Valore della traslazione in X.

dy
Single

Valore della traslazione in Y.

order
MatrixOrder

Ordine, di anteposizione o accodamento, in cui applicare la traslazione.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, un OnPaint oggetto evento. Il codice esegue le azioni seguenti:

  • Crea un nuovo oggetto LinearGradientBrush.

  • Usa questo pennello per disegnare un rettangolo sullo schermo con una transizione lineare da sinistra a destra dei colori.

  • Ruota di LinearGradientBrush 90 gradi e ridimensiona la sfumatura.

  • Disegna il rettangolo, con la sfumatura ruotata e ridimensionata, sullo schermo.

  • Converte il rettangolo in modo che abbia una sfumatura lineare in esecuzione dall'alto verso il basso.

  • Disegna il rettangolo convertito sullo schermo.

Si noti che sono presenti tre rettangoli visualizzati nella parte superiore che mostra la sfumatura da sinistra a destra, quella centrale che mostra la sfumatura ruotata e ridimensionata e quella inferiore che mostra la sfumatura finale tradotta.

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

Si applica a

TranslateTransform(Single, Single)

Origine:
LinearGradientBrush.cs
Origine:
LinearGradientBrush.cs
Origine:
LinearGradientBrush.cs

Sottopone a traslazione la trasformazione geometrica locale in base alle dimensioni specificate. Questo metodo antepone la traslazione alla trasformazione.

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)

Parametri

dx
Single

Valore della traslazione in X.

dy
Single

Valore della traslazione in Y.

Esempio

Per un esempio, vedere TranslateTransform.

Si applica a