次の方法で共有


Matrix.Rotate メソッド

原点を中心とする指定した角度の時計回りの回転を、この Matrix オブジェクトに適用します。

オーバーロードの一覧

原点を中心とする指定した角度の時計回りの回転を、この Matrix オブジェクトに付加します。

[Visual Basic] Overloads Public Sub Rotate(Single)

[C#] public void Rotate(float);

[C++] public: void Rotate(float);

[JScript] public function Rotate(float);

angle パラメータで指定された量の、原点 (x 座標と y 座標が 0) を中心とする時計回りの回転を、この Matrix オブジェクトに適用します。

[Visual Basic] Overloads Public Sub Rotate(Single, MatrixOrder)

[C#] public void Rotate(float, MatrixOrder);

[C++] public: void Rotate(float, MatrixOrder);

[JScript] public function Rotate(float, MatrixOrder);

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • 回転の変換を適用する前に、画面に四角形を描画します (青い四角形)。
  • 行列を作成し、それを 45 度回転します。
  • この行列変換を四角形に適用します。
  • 変形した四角形を画面に描画します (赤い四角形)。

[Visual Basic, C#] 赤い四角形は、画面座標 (0, 0) を中心に回転されます。

[Visual Basic, C#] メモ   ここでは、Rotate のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。

 
Public Sub RotateExample(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
        
[C#] 
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);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

参照

Matrix クラス | Matrix メンバ | System.Drawing.Drawing2D 名前空間