LinearGradientBrush::RotateTransform Method (Single, MatrixOrder)
Rotates the local geometric transform by the specified amount in the specified order.
Assembly: System.Drawing (in System.Drawing.dll)
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
Creates a new LinearGradientBrush.
Draws an ellipse to the screen using this brush.
Rotates the LinearGradientBrush 45 degrees by calling the RotateTransform method.
Draws an ellipse to the screen directly below the first ellipse, using the rotated brush.
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 ); }
Available since 1.1