次の方法で共有


Matrix.RotateAt メソッド

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

オーバーロードの一覧

回転を前に付加することで、 point パラメータで指定した点を中心とする時計回りの回転を、この Matrix オブジェクトに適用します。

[Visual Basic] Overloads Public Sub RotateAt(Single, PointF)

[C#] public void RotateAt(float, PointF);

[C++] public: void RotateAt(float, PointF);

[JScript] public function RotateAt(float, PointF);

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

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

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

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

[JScript] public function RotateAt(float, PointF, MatrixOrder);

使用例

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

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

[Visual Basic, C#] 赤い四角形は、四角形の左上隅 (RotateAt メソッドで指定した回転点) を中心に回転されます。

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

 
Public Sub RotateAtExample(e As PaintEventArgs)
Dim myPen As New Pen(Color.Blue, 1)
Dim myPen2 As New Pen(Color.Red, 1)
Dim rotatePoint As New PointF(150F, 50F)
' 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.RotateAt(45, rotatePoint, 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 RotateAtExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
PointF rotatePoint = new PointF(150.0f, 50.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 = new Matrix();
myMatrix.RotateAt(45, rotatePoint, 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 名前空間