Matrix::RotateAt Method (Single, PointF, MatrixOrder)

 

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

Namespace:   System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)

public:
void RotateAt(
	float angle,
	PointF point,
	MatrixOrder order
)

Parameters

angle
Type: System::Single

The angle of the rotation, in degrees.

point
Type: System.Drawing::PointF

A PointF that represents the center of the rotation.

order
Type: System.Drawing.Drawing2D::MatrixOrder

A MatrixOrder that specifies the order (append or prepend) in which the rotation is applied.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an Paint 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).

Notice that the red rectangle has been rotated around the upper left-hand corner of the rectangle (the rotation point specified the RotateAt method).

public:
   void RotateAtExample( PaintEventArgs^ e )
   {
      Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
      Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );
      PointF rotatePoint = 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 = gcnew 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 );
   }

.NET Framework
Available since 1.1
Return to top
Show: