Graphics.MultiplyTransform 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
MultiplyTransform(Matrix) | |
MultiplyTransform(Matrix, MatrixOrder) |
MultiplyTransform(Matrix)
- 來源:
- Graphics.cs
- 來源:
- Graphics.cs
- 來源:
- Graphics.cs
public:
void MultiplyTransform(System::Drawing::Drawing2D::Matrix ^ matrix);
public void MultiplyTransform (System.Drawing.Drawing2D.Matrix matrix);
member this.MultiplyTransform : System.Drawing.Drawing2D.Matrix -> unit
Public Sub MultiplyTransform (matrix As Matrix)
參數
範例
下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse
,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:
transformMatrix
(兩個識別矩陣加上零轉譯向量) 建立兩個矩陣。依向量 (200、100) 轉譯轉換矩陣。
將 Windows Form 的世界轉換矩陣旋轉 30 度,在窗體的轉換矩陣前面加上 30 度的旋轉矩陣。
將旋轉世界轉換矩陣乘以已轉譯
transformMatrix
的 ,並將 前面加上transformMatrix
世界轉換矩陣。繪製旋轉、翻譯的橢圓形。
public:
void MultiplyTransformMatrix( PaintEventArgs^ e )
{
// Create transform matrix.
Matrix^ transformMatrix = gcnew Matrix;
// Translate matrix, prepending translation vector.
transformMatrix->Translate( 200.0F, 100.0F );
// Rotate transformation matrix of graphics object,
// prepending rotation matrix.
e->Graphics->RotateTransform( 30.0F );
// Multiply (prepend to) transformation matrix of
// graphics object to translate graphics transformation.
e->Graphics->MultiplyTransform( transformMatrix );
// Draw rotated, translated ellipse.
e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), -80, -40, 160, 80 );
}
private void MultiplyTransformMatrix(PaintEventArgs e)
{
// Create transform matrix.
Matrix transformMatrix = new Matrix();
// Translate matrix, prepending translation vector.
transformMatrix.Translate(200.0F, 100.0F);
// Rotate transformation matrix of graphics object,
// prepending rotation matrix.
e.Graphics.RotateTransform(30.0F);
// Multiply (prepend to) transformation matrix of
// graphics object to translate graphics transformation.
e.Graphics.MultiplyTransform(transformMatrix);
// Draw rotated, translated ellipse.
e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), -80, -40, 160, 80);
}
Private Sub MultiplyTransformMatrix(ByVal e As PaintEventArgs)
' Create transform matrix.
Dim transformMatrix As New Matrix
' Translate matrix, prepending translation vector.
transformMatrix.Translate(200.0F, 100.0F)
' Rotate transformation matrix of graphics object,
' prepending rotation matrix.
e.Graphics.RotateTransform(30.0F)
' Multiply (prepend to) transformation matrix of
' graphics object to translate graphics transformation.
e.Graphics.MultiplyTransform(transformMatrix)
' Draw rotated, translated ellipse.
e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), -80, -40, 160, 80)
End Sub
備註
這個方法會在 參數指定的 matrix
矩陣前面加上 ,因此結果為 matrix
x world 轉換。
另請參閱
適用於
MultiplyTransform(Matrix, MatrixOrder)
- 來源:
- Graphics.cs
- 來源:
- Graphics.cs
- 來源:
- Graphics.cs
public:
void MultiplyTransform(System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Drawing2D::MatrixOrder order);
public void MultiplyTransform (System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order);
member this.MultiplyTransform : System.Drawing.Drawing2D.Matrix * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub MultiplyTransform (matrix As Matrix, order As MatrixOrder)
參數
- order
- MatrixOrder
MatrixOrder 列舉的成員,決定相乘的順序。
範例
下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse
,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:
transformMatrix
(兩個識別矩陣加上零轉譯向量) 建立兩個矩陣。依向量 (200、100) 轉譯轉換矩陣。
將 Windows Form 的世界轉換矩陣旋轉 30 度,在窗體的轉換矩陣前面加上 30 度的旋轉矩陣。
將旋轉世界轉換矩陣乘以已轉譯
transformMatrix
的 ,並將transformMatrix
附加至世界轉換矩陣。繪製旋轉、翻譯的橢圓形。
public:
void MultiplyTransformMatrixOrder( PaintEventArgs^ e )
{
// Create transform matrix.
Matrix^ transformMatrix = gcnew Matrix;
// Translate matrix, prepending translation vector.
transformMatrix->Translate( 200.0F, 100.0F );
// Rotate transformation matrix of graphics object,
// prepending rotation matrix.
e->Graphics->RotateTransform( 30.0F );
// Multiply (append to) transformation matrix of
// graphics object to translate graphics transformation.
e->Graphics->MultiplyTransform( transformMatrix, MatrixOrder::Append );
// Draw rotated, translated ellipse.
e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), -80, -40, 160, 80 );
}
private void MultiplyTransformMatrixOrder(PaintEventArgs e)
{
// Create transform matrix.
Matrix transformMatrix = new Matrix();
// Translate matrix, prepending translation vector.
transformMatrix.Translate(200.0F, 100.0F);
// Rotate transformation matrix of graphics object,
// prepending rotation matrix.
e.Graphics.RotateTransform(30.0F);
// Multiply (append to) transformation matrix of
// graphics object to translate graphics transformation.
e.Graphics.MultiplyTransform(transformMatrix, MatrixOrder.Append);
// Draw rotated, translated ellipse.
e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), -80, -40, 160, 80);
}
Private Sub MultiplyTransformMatrixOrder(ByVal e As PaintEventArgs)
' Create transform matrix.
Dim transformMatrix As New Matrix
' Translate matrix, prepending translation vector.
transformMatrix.Translate(200.0F, 100.0F)
' Rotate transformation matrix of graphics object,
' prepending rotation matrix.
e.Graphics.RotateTransform(30.0F)
' Multiply (append to) transformation matrix of
' graphics object to translate graphics transformation.
e.Graphics.MultiplyTransform(transformMatrix, MatrixOrder.Append)
' Draw rotated, translated ellipse.
e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), -80, -40, 160, 80)
End Sub
備註
參數的 order
值Prepend會指定乘法的順序為 matrix
x world 轉換。 的 Appendorder
值,指定乘法的順序是世界轉換 x matrix
。
另請參閱
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應