LinearGradientBrush.TranslateTransform 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将局部几何转换平移指定的尺寸。 该方法将预先计算对转换的平移。
重载
TranslateTransform(Single, Single, MatrixOrder) |
按指定的顺序将局部几何转换平移指定的尺寸。 |
TranslateTransform(Single, Single) |
将局部几何转换平移指定的尺寸。 该方法将预先计算对转换的平移。 |
TranslateTransform(Single, Single, MatrixOrder)
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- 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 窗体,它需要 PaintEventArgse
事件OnPaint对象。 此代码执行以下操作:
创建一个新的 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)
- Source:
- LinearGradientBrush.cs
- Source:
- LinearGradientBrush.cs
- Source:
- 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。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈