Matrix.RotateAt Method (Single, PointF, MatrixOrder) (System.Drawing.Drawing2D)

Switch View :
ScriptFree
.NET Framework Class Library
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)
Syntax

Visual Basic
Public Sub RotateAt ( _
	angle As Single, _
	point As PointF, _
	order As MatrixOrder _
)
C#
public void RotateAt(
	float angle,
	PointF point,
	MatrixOrder order
)
Visual C++
public:
void RotateAt(
	float angle, 
	PointF point, 
	MatrixOrder order
)
F#
member RotateAt : 
        angle:float32 * 
        point:PointF * 
        order:MatrixOrder -> unit 

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.
Examples

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

Visual Basic

Public Sub RotateAtExample(ByVal e As PaintEventArgs)
    Dim myPen As New Pen(Color.Blue, 1)
    Dim myPen2 As New Pen(Color.Red, 1)
    Dim rotatePoint As 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.
    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);
}


Visual C++

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


Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also

Reference