TextureBrush.TranslateTransform 方法

定义

按指定顺序将此 TextureBrush 对象的局部几何转换平移指定的尺寸。Translates the local geometric transformation of this TextureBrush object by the specified dimensions in the specified order.

重载

TranslateTransform(Single, Single)

根据指定维度,转换此 TextureBrush 对象的局部几何变换。Translates the local geometric transformation of this TextureBrush object by the specified dimensions. 此方法将平移添加到转换前。This method prepends the translation to the transformation.

TranslateTransform(Single, Single, MatrixOrder)

按指定顺序将此 TextureBrush 对象的局部几何转换平移指定的尺寸。Translates the local geometric transformation of this TextureBrush object by the specified dimensions in the specified order.

TranslateTransform(Single, Single)

根据指定维度,转换此 TextureBrush 对象的局部几何变换。Translates the local geometric transformation of this TextureBrush object by the specified dimensions. 此方法将平移添加到转换前。This method prepends the translation to the transformation.

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 方向平移变换时要使用的维度。The dimension by which to translate the transformation in the x direction.

dy
Single

沿 y 方向平移变换时要使用的维度。The dimension by which to translate the transformation in the y direction.

示例

下面的示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:

  • 创建一个 TextureBrush 对象。Creates a TextureBrush object.

  • 将纹理图像50单位转换为 x 方向。Translates the texture image 50 units in the x-direction.

  • 使用纹理画笔在屏幕上填充矩形。Fills a rectangle on the screen, using the texture brush.

void TranslateTransform_Example1( PaintEventArgs^ e )
{
   // Create a TextureBrush object.
   TextureBrush^ tBrush = gcnew TextureBrush( gcnew Bitmap( "texture.jpg" ) );

   // Move the texture image 2X in the x-direction.
   tBrush->TranslateTransform( 50, 0, MatrixOrder::Prepend );

   // Fill a rectangle with tBrush.
   e->Graphics->FillRectangle( tBrush, 0, 0, 100, 100 );
}
public void TranslateTransform_Example1(PaintEventArgs e)
{
             
    // Create a TextureBrush object.
    TextureBrush tBrush = new TextureBrush(new Bitmap("texture.jpg"));
             
    // Move the texture image 2X in the x-direction.
    tBrush.TranslateTransform(50, 0, MatrixOrder.Prepend);
             
    // Fill a rectangle with tBrush.
    e.Graphics.FillRectangle(tBrush, 0, 0, 100, 100);
}
Public Sub TranslateTransform_Example1(ByVal e As PaintEventArgs)

    ' Create a TextureBrush object.
    Dim tBrush As New TextureBrush(New Bitmap("texture.jpg"))

    ' Move the texture image 2X in the x-direction.
    tBrush.TranslateTransform(50, 0, MatrixOrder.Prepend)

    ' Fill a rectangle with tBrush.
    e.Graphics.FillRectangle(tBrush, 0, 0, 100, 100)
End Sub

适用于

TranslateTransform(Single, Single, MatrixOrder)

按指定顺序将此 TextureBrush 对象的局部几何转换平移指定的尺寸。Translates the local geometric transformation of this TextureBrush object by the specified dimensions in the specified order.

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 方向平移变换时要使用的维度。The dimension by which to translate the transformation in the x direction.

dy
Single

沿 y 方向平移变换时要使用的维度。The dimension by which to translate the transformation in the y direction.

order
MatrixOrder

应用转换的顺序(在前面添加或在后面追加)。The order (prepend or append) in which to apply the translation.

示例

下面的示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:

  • 创建一个 TextureBrush 对象。Creates a TextureBrush object.

  • 将纹理图像50单位转换为 x 方向。Translates the texture image 50 units in the x-direction.

  • 使用纹理画笔在屏幕上填充矩形。Fills a rectangle on the screen, using the texture brush.

void TranslateTransform_Example2( PaintEventArgs^ e )
{
   // Create a TextureBrush object.
   TextureBrush^ tBrush = gcnew TextureBrush( gcnew Bitmap( "texture.jpg" ) );

   // Move the texture image 2X in the x-direction.
   tBrush->TranslateTransform( 50, 0 );

   // Fill a rectangle with tBrush.
   e->Graphics->FillRectangle( tBrush, 0, 0, 100, 100 );
}
public void TranslateTransform_Example2(PaintEventArgs e)
{
         
    // Create a TextureBrush object.
    TextureBrush tBrush = new TextureBrush(new Bitmap("texture.jpg"));
         
    // Move the texture image 2X in the x-direction.
    tBrush.TranslateTransform(50, 0);
         
    // Fill a rectangle with tBrush.
    e.Graphics.FillRectangle(tBrush, 0, 0, 100, 100);
}
Public Sub TranslateTransform_Example2(ByVal e As PaintEventArgs)

    ' Create a TextureBrush object.
    Dim tBrush As New TextureBrush(New Bitmap("texture.jpg"))

    ' Move the texture image 2X in the x-direction.
    tBrush.TranslateTransform(50, 0)

    ' Fill a rectangle with tBrush.
    e.Graphics.FillRectangle(tBrush, 0, 0, 100, 100)
End Sub

适用于