Graphics.RotateTransform 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將指定的旋轉套用至這個 Graphics 的變換矩陣。
多載
RotateTransform(Single) |
將指定的旋轉套用至這個 Graphics 的變換矩陣。 |
RotateTransform(Single, MatrixOrder) |
依照指定的順序,將指定之旋轉套用至這個 Graphics 的變換矩陣。 |
RotateTransform(Single)
- 來源:
- Graphics.cs
- 來源:
- Graphics.cs
- 來源:
- Graphics.cs
將指定的旋轉套用至這個 Graphics 的變換矩陣。
public:
void RotateTransform(float angle);
public void RotateTransform (float angle);
member this.RotateTransform : single -> unit
Public Sub RotateTransform (angle As Single)
參數
- angle
- Single
旋轉的角度,以度為單位。
範例
下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse
,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:
將 Windows Form 世界轉換矩陣轉譯為向量 (100, 0) 。
以 30 度的角度旋轉世界轉換,並將旋轉矩陣前面加上世界轉換矩陣。
使用藍色畫筆繪製旋轉的翻譯橢圓形。
public:
void RotateTransformAngle( PaintEventArgs^ e )
{
// Set world transform of graphics object to translate.
e->Graphics->TranslateTransform( 100.0F, 0.0F );
// Then to rotate, prepending rotation matrix.
e->Graphics->RotateTransform( 30.0F );
// Draw rotated, translated ellipse to screen.
e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), 0, 0, 200, 80 );
}
private void RotateTransformAngle(PaintEventArgs e)
{
// Set world transform of graphics object to translate.
e.Graphics.TranslateTransform(100.0F, 0.0F);
// Then to rotate, prepending rotation matrix.
e.Graphics.RotateTransform(30.0F);
// Draw rotated, translated ellipse to screen.
e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}
Private Sub RotateTransformAngle(ByVal e As PaintEventArgs)
' Set world transform of graphics object to translate.
e.Graphics.TranslateTransform(100.0F, 0.0F)
' Then to rotate, prepending rotation matrix.
e.Graphics.RotateTransform(30.0F)
' Draw rotated, translated ellipse to screen.
e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub
備註
旋轉作業包含將轉換矩陣乘以衍生自 參數的 angle
矩陣。 此方法會將旋轉套用至轉換矩陣之前。
適用於
RotateTransform(Single, MatrixOrder)
- 來源:
- Graphics.cs
- 來源:
- Graphics.cs
- 來源:
- Graphics.cs
依照指定的順序,將指定之旋轉套用至這個 Graphics 的變換矩陣。
public:
void RotateTransform(float angle, System::Drawing::Drawing2D::MatrixOrder order);
public void RotateTransform (float angle, System.Drawing.Drawing2D.MatrixOrder order);
member this.RotateTransform : single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub RotateTransform (angle As Single, order As MatrixOrder)
參數
- angle
- Single
旋轉的角度,以度為單位。
- order
- MatrixOrder
MatrixOrder 列舉的成員,指定旋轉是附加到矩陣變換之前或之後。
範例
下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse
,這是事件處理程序的參數Paint。 此程式碼會執行下列動作:
將 Windows Form 世界轉換矩陣轉譯為向量 (100, 0) 。
以 30 度的角度旋轉世界轉換,並使用 將旋轉矩陣附加至世界轉換矩陣 Append。
使用藍色畫筆繪製已翻譯的旋轉橢圓形。
public:
void RotateTransformAngleMatrixOrder( PaintEventArgs^ e )
{
// Set world transform of graphics object to translate.
e->Graphics->TranslateTransform( 100.0F, 0.0F );
// Then to rotate, appending rotation matrix.
e->Graphics->RotateTransform( 30.0F, MatrixOrder::Append );
// Draw translated, rotated ellipse to screen.
e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), 0, 0, 200, 80 );
}
private void RotateTransformAngleMatrixOrder(PaintEventArgs e)
{
// Set world transform of graphics object to translate.
e.Graphics.TranslateTransform(100.0F, 0.0F);
// Then to rotate, appending rotation matrix.
e.Graphics.RotateTransform(30.0F, MatrixOrder.Append);
// Draw translated, rotated ellipse to screen.
e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}
Private Sub RotateTransformAngleMatrixOrder(ByVal e As PaintEventArgs)
' Set world transform of graphics object to translate.
e.Graphics.TranslateTransform(100.0F, 0.0F)
' Then to rotate, appending rotation matrix.
e.Graphics.RotateTransform(30.0F, MatrixOrder.Append)
' Draw translated, rotated ellipse to screen.
e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub
備註
旋轉作業包含將轉換矩陣乘以衍生自 參數的 angle
矩陣。 這個方法會根據 order
參數,在旋轉矩陣前面加上或附加 的Graphics轉換矩陣。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應