RotateTransform Method (Single, MatrixOrder)
Collapse the table of content
Expand the table of content

Graphics.RotateTransform Method (Single, MatrixOrder)

Applies the specified rotation to the transformation matrix of this Graphics in the specified order.

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

public void RotateTransform(
	float angle,
	MatrixOrder order
)

Parameters

angle
Type: System.Single

Angle of rotation in degrees.

order
Type: System.Drawing.Drawing2D.MatrixOrder

Member of the MatrixOrder enumeration that specifies whether the rotation is appended or prepended to the matrix transformation.

The rotation operation consists of multiplying the transformation matrix by a matrix whose elements are derived from the angle parameter. This method prepends or appends the transformation matrix of the Graphics by the rotation matrix according to the order parameter.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Translates the world transformation matrix of the Windows Form by the vector (100, 0).

  • Rotates the world transform by an angle of 30 degrees, appending the rotation matrix to the world transformation matrix with Append.

  • Draws a translated, rotated ellipse with a blue pen.

private void RotateTransformAngleMatrixOrder(PaintEventArgs e)
{

    // Set world transform of graphics object to translate.
    e.Graphics.TranslateTransform(100.0F, 0.0F);

    // Then to rotate, appending rotation matrix.
    e.Graphics.RotateTransform(30.0F, MatrixOrder.Append);

    // Draw translated, rotated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

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

Community Additions

ADD
Show:
© 2016 Microsoft