LinearGradientBrush.TranslateTransform Metoda

Definicja

Tłumaczy lokalną transformację geometryczną według określonych wymiarów. Ta metoda poprzedza tłumaczenie transformacji.

Przeciążenia

TranslateTransform(Single, Single, MatrixOrder)

Tłumaczy lokalną transformację geometryczną według określonych wymiarów w określonej kolejności.

TranslateTransform(Single, Single)

Tłumaczy lokalną transformację geometryczną według określonych wymiarów. Ta metoda poprzedza tłumaczenie transformacji.

TranslateTransform(Single, Single, MatrixOrder)

Źródło:
LinearGradientBrush.cs
Źródło:
LinearGradientBrush.cs
Źródło:
LinearGradientBrush.cs

Tłumaczy lokalną transformację geometryczną według określonych wymiarów w określonej kolejności.

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)

Parametry

dx
Single

Wartość tłumaczenia w x.

dy
Single

Wartość tłumaczenia w y.

order
MatrixOrder

Kolejność (prepend lub dołączanie), w której ma zostać zastosowane tłumaczenie.

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgseOnPaint obiektu zdarzenia . Kod wykonuje następujące akcje:

  • Tworzy nowy adres LinearGradientBrush.

  • Używa tego pędzla do rysowania prostokąta na ekranie, który ma liniowe, od lewej do prawej przejścia kolorów.

  • Obraca o LinearGradientBrush 90 stopni i skaluje gradient.

  • Rysuje prostokąt z obróconym i skalowalnym gradientem do ekranu.

  • Tłumaczy prostokąt tak, aby miał gradient liniowy działający od góry do dołu.

  • Rysuje przetłumaczony prostokąt na ekran.

Zwróć uwagę, że istnieją trzy prostokąty wyświetlane u góry, pokazujące gradient od lewej do prawej, środkowy, pokazujący obrócony i skalowany gradient, a dolny pokazujący ostatni, przetłumaczony gradient.

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

Dotyczy

TranslateTransform(Single, Single)

Źródło:
LinearGradientBrush.cs
Źródło:
LinearGradientBrush.cs
Źródło:
LinearGradientBrush.cs

Tłumaczy lokalną transformację geometryczną według określonych wymiarów. Ta metoda poprzedza tłumaczenie transformacji.

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)

Parametry

dx
Single

Wartość tłumaczenia w x.

dy
Single

Wartość tłumaczenia w y.

Przykłady

Aby zapoznać się z przykładem, zobacz TranslateTransform.

Dotyczy