This documentation is archived and is not being maintained.

Matrix.RotateAt Method

Applies a clockwise rotation about the specified point to this Matrix object by prepending the rotation.

Overload List

Applies a clockwise rotation to this Matrix object around the point specified in the point parameter, and by prepending the rotation.

[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);

Applies a clockwise rotation about the specified point to this Matrix object in the specified order.

[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);

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:

  • Draws a rectangle to the screen prior to applying a rotation transform (the blue rectangle).
  • Creates a matrix and rotates it 45 degrees around a specified point.
  • Applies this matrix transform is to the rectangle.
  • Draws the transformed rectangle to the screen (the red rectangle).

[Visual Basic, C#] Notice that the red rectangle has been rotated around the upper left-hand corner of the rectangle (the rotation point specified the RotateAt method).

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of RotateAt. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
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] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Matrix Class | Matrix Members | System.Drawing.Drawing2D Namespace

Show: