Matrix.Translate 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
通过追加翻译向量,将指定的翻译向量应用于此 Matrix 向量。
重载
| 名称 | 说明 |
|---|---|
| Translate(Single, Single) |
通过附加翻译向量,将指定的翻译向量 ( |
| Translate(Single, Single, MatrixOrder) |
按指定顺序将指定的翻译向量应用于此 Matrix 矢量。 |
Translate(Single, Single)
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
通过附加翻译向量,将指定的翻译向量 (offsetX 和 offsetY) 应用于此 Matrix 向量。
public:
void Translate(float offsetX, float offsetY);
public void Translate(float offsetX, float offsetY);
member this.Translate : single * single -> unit
Public Sub Translate (offsetX As Single, offsetY As Single)
参数
示例
有关示例,请参阅 Translate(Single, Single, MatrixOrder)。
适用于
Translate(Single, Single, MatrixOrder)
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
- Source:
- Matrix.cs
按指定顺序将指定的翻译向量应用于此 Matrix 矢量。
public:
void Translate(float offsetX, float offsetY, System::Drawing::Drawing2D::MatrixOrder order);
public void Translate(float offsetX, float offsetY, System.Drawing.Drawing2D.MatrixOrder order);
member this.Translate : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub Translate (offsetX As Single, offsetY As Single, order As MatrixOrder)
参数
- order
- MatrixOrder
一个 MatrixOrder ,用于指定将翻译应用于此 Matrix顺序(追加或前面)。
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse(Paint 事件对象)。 该示例执行以下操作:
在应用平移转换(蓝色矩形)之前,将矩形绘制到屏幕。
创建一个矩阵,并在两个轴中按 100 对其进行转换。
将此矩阵转换应用于矩形,
将转换后的矩形绘制到屏幕(红色矩形)。
请注意,红色矩形的开头位于蓝色三角形开头的两个轴中 100 磅。
public:
void TranslateExample( PaintEventArgs^ e )
{
Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );
// Draw a rectangle to the screen before applying the
// transform.
e->Graphics->DrawRectangle( myPen, 20, 20, 100, 50 );
// Create a matrix and translate it.
Matrix^ myMatrix = gcnew Matrix;
myMatrix->Translate( 100, 100, MatrixOrder::Append );
// Draw the Points to the screen again after applying the
// transform.
e->Graphics->Transform = myMatrix;
e->Graphics->DrawRectangle( myPen2, 20, 20, 100, 50 );
}
public void TranslateExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
// Draw a rectangle to the screen before applying the
// transform.
e.Graphics.DrawRectangle(myPen, 20, 20, 100, 50);
// Create a matrix and translate it.
Matrix myMatrix = new Matrix();
myMatrix.Translate(100, 100, MatrixOrder.Append);
// Draw the Points to the screen again after applying the
// transform.
e.Graphics.Transform = myMatrix;
e.Graphics.DrawRectangle(myPen2, 20, 20, 100, 50);
}
Public Sub TranslateExample(ByVal e As PaintEventArgs)
Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
' Draw a rectangle to the screen before applying the
' transform.
e.Graphics.DrawRectangle(myPen, 20, 20, 100, 50)
' Create a matrix and translate it.
Dim myMatrix As New Matrix
myMatrix.Translate(100, 100, MatrixOrder.Append)
' Draw the Points to the screen again after applying the
' transform.
e.Graphics.Transform = myMatrix
e.Graphics.DrawRectangle(myPen2, 20, 20, 100, 50)
End Sub