Matrix.Translate 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將指定的平移向量置於此 Matrix ,並加前置平移向量。
多載
| 名稱 | Description |
|---|---|
| Translate(Single, Single) |
將指定的平移向量( |
| Translate(Single, Single, MatrixOrder) |
以指定順序將指定的平移向量套用於此。Matrix |
Translate(Single, Single)
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- 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)
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- 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
A MatrixOrder 指定了將平移應用於此 Matrix的順序(附加或前置)。
範例
以下程式碼範例是為 Windows Forms 設計,並需要 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