LinearGradientBrush::RotateTransform Method (Single, MatrixOrder)

 

Rotates the local geometric transform by the specified amount in the specified order.

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

public:
void RotateTransform(
	float angle,
	MatrixOrder order
)

Parameters

angle
Type: System::Single

The angle of rotation.

order
Type: System.Drawing.Drawing2D::MatrixOrder

A MatrixOrder that specifies whether to append or prepend the rotation matrix.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. The code

Notice that the gradient of the lower ellipse is at a 45 degree angle to the x-axis of the top ellipse. Also notice that a call to the TranslateTransform method is used to justify the left edge of the gradient fill with the left edge of the lower ellipse.

private:
   void RotateTransformExample( PaintEventArgs^ e )
   {
      // Create a LinearGradientBrush.
      Rectangle myRect = Rectangle(20,20,200,100);
      LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true );

      // Draw an ellipse to the screen using the LinearGradientBrush.
      e->Graphics->FillEllipse( myLGBrush, myRect );

      // Rotate the LinearGradientBrush.
      myLGBrush->RotateTransform( 45.0f, MatrixOrder::Prepend );

      // Rejustify the brush to start at the left edge of the ellipse.
      myLGBrush->TranslateTransform(  -100.0f, 0.0f );

      // Draw a second ellipse to the screen using
      // the transformed brush.
      e->Graphics->FillEllipse( myLGBrush, 20, 150, 200, 100 );
   }

.NET Framework
Available since 1.1
Return to top
Show: