Matrix.Rotate 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
對此 Matrix施加以指定角度順時針旋轉。
多載
| 名稱 | Description |
|---|---|
| Rotate(Single) |
在此之前,順 Matrix 時針繞原點旋轉,並依指定角度旋轉。 |
| Rotate(Single, MatrixOrder) |
對參數 |
Rotate(Single)
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
在此之前,順 Matrix 時針繞原點旋轉,並依指定角度旋轉。
public:
void Rotate(float angle);
public void Rotate(float angle);
member this.Rotate : single -> unit
Public Sub Rotate (angle As Single)
參數
- angle
- Single
旋轉的角度,以度數為單位。
範例
如需範例,請參閱 Rotate(Single, MatrixOrder)。
適用於
Rotate(Single, MatrixOrder)
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
- 來源:
- Matrix.cs
對參數angle中指定的Matrix順時針旋轉,繞原點(零 x 與 y 座標)進行。
public:
void Rotate(float angle, System::Drawing::Drawing2D::MatrixOrder order);
public void Rotate(float angle, System.Drawing.Drawing2D.MatrixOrder order);
member this.Rotate : single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub Rotate (angle As Single, order As MatrixOrder)
參數
- angle
- Single
旋轉的角度(範圍),以度數為單位。
- order
- MatrixOrder
A MatrixOrder 指定旋轉應用於此 Matrix的順序(附加或前置)。
範例
以下程式碼範例是為 Windows Forms 設計,並需要 PaintEventArgse,一個 Paint 事件物件。 此程式碼會執行下列動作:
在套用旋轉變換(藍色矩形)前,先在螢幕上畫一個矩形。
建立一個矩陣並旋轉45度。
將此矩陣轉換應用於矩形。
將轉換後的矩形(紅色矩形)繪製到螢幕上。
注意紅色矩形已經繞著 0, 0 螢幕座標旋轉。
public:
void RotateExample( PaintEventArgs^ e )
{
Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );
// Draw the rectangle to the screen before applying the transform.
e->Graphics->DrawRectangle( myPen, 150, 50, 200, 100 );
// Create a matrix and rotate it 45 degrees.
Matrix^ myMatrix = gcnew Matrix;
myMatrix->Rotate( 45, MatrixOrder::Append );
// Draw the rectangle to the screen again after applying the
// transform.
e->Graphics->Transform = myMatrix;
e->Graphics->DrawRectangle( myPen2, 150, 50, 200, 100 );
}
public void RotateExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
// Draw the rectangle to the screen before applying the transform.
e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100);
// Create a matrix and rotate it 45 degrees.
Matrix myMatrix = new Matrix();
myMatrix.Rotate(45, MatrixOrder.Append);
// Draw the rectangle to the screen again after applying the
// transform.
e.Graphics.Transform = myMatrix;
e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100);
}
Public Sub RotateExample(ByVal e As PaintEventArgs)
Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
' Draw the rectangle to the screen before applying the transform.
e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100)
' Create a matrix and rotate it 45 degrees.
Dim myMatrix As New Matrix
myMatrix.Rotate(45, MatrixOrder.Append)
' Draw the rectangle to the screen again after applying the
' transform.
e.Graphics.Transform = myMatrix
e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100)
End Sub