This documentation is archived and is not being maintained.

# Matrix.Rotate Method (Single, MatrixOrder)

Visual Studio 2010

Applies a clockwise rotation of an amount specified in the angle parameter, around the origin (zero x and y coordinates) for this Matrix.

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

## Syntax

```public void Rotate(
float angle,
MatrixOrder order
)
```

#### Parameters

angle
Type: System.Single
The angle (extent) of the rotation, in degrees.
order
Type: System.Drawing.Drawing2D.MatrixOrder
A MatrixOrder that specifies the order (append or prepend) in which the rotation is applied to this Matrix.

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

• Applies this matrix transform to the rectangle.

• Draws the transformed rectangle to the screen (the red rectangle).

Notice that the red rectangle has been rotated around the 0, 0 screen coordinates.

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

```

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