LinearGradientBrush.TranslateTransform Метод

Определение

Выполняет смещение локального геометрического преобразования в заданных измерениях. Этот метод добавляет сдвиг к преобразованию.

Перегрузки

TranslateTransform(Single, Single, MatrixOrder)

Выполняет смещение локального геометрического преобразования в заданных измерениях и в указанном порядке.

TranslateTransform(Single, Single)

Выполняет смещение локального геометрического преобразования в заданных измерениях. Этот метод добавляет сдвиг к преобразованию.

TranslateTransform(Single, Single, MatrixOrder)

Исходный код:
LinearGradientBrush.cs
Исходный код:
LinearGradientBrush.cs
Исходный код:
LinearGradientBrush.cs

Выполняет смещение локального геометрического преобразования в заданных измерениях и в указанном порядке.

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)

Параметры

dx
Single

Значение сдвига по оси X.

dy
Single

Значение сдвига по оси Y.

order
MatrixOrder

Порядок применения преобразования (в начале или в конце).

Примеры

Следующий пример кода предназначен для использования с Windows Forms, и для него требуется PaintEventArgseOnPaint объект события . Код выполняет следующие действия.

  • Создает новый экземпляр LinearGradientBrush.

  • Эта кисть используется для рисования прямоугольника на экране с линейным переходом цветов слева направо.

  • Поворачивает на LinearGradientBrush 90 градусов и масштабирует градиент.

  • Рисует прямоугольник с повернутым и масштабируемым градиентом на экране.

  • Преобразует прямоугольник таким образом, чтобы в нем был линейный градиент, выполняющийся сверху вниз.

  • Рисует преобразованный прямоугольник на экран.

Обратите внимание, что в верхней части отображаются три прямоугольника с градиентом слева направо, в середине — повернутый и масштабированный градиент, а в нижнем — окончательный переведенный градиент.

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

Применяется к

TranslateTransform(Single, Single)

Исходный код:
LinearGradientBrush.cs
Исходный код:
LinearGradientBrush.cs
Исходный код:
LinearGradientBrush.cs

Выполняет смещение локального геометрического преобразования в заданных измерениях. Этот метод добавляет сдвиг к преобразованию.

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)

Параметры

dx
Single

Значение сдвига по оси X.

dy
Single

Значение сдвига по оси Y.

Примеры

Пример см. в разделе TranslateTransform.

Применяется к