This topic has not yet been rated - Rate this topic

PathGradientBrush.RotateTransform Method

Applies a clockwise rotation of the specified angle to the local geometric transform.

Overload List

Rotates the local geometric transform by the specified amount. This method prepends the rotation to the transform.

[Visual Basic] Overloads Public Sub RotateTransform(Single)
[C#] public void RotateTransform(float);
[C++] public: void RotateTransform(float);
[JScript] public function RotateTransform(float);

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

[Visual Basic] Overloads Public Sub RotateTransform(Single, MatrixOrder)
[C#] public void RotateTransform(float, MatrixOrder);
[C++] public: void RotateTransform(float, MatrixOrder);
[JScript] public function RotateTransform(float, MatrixOrder);

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:

  • Creates a graphics path and adds a rectangle to it.
  • Creates a PathGradientBrush object from the path points (in this example, the points form a rectangle, but it could be most any shape).
  • Sets the center color to red and the surrounding color to blue.
  • Draws the PathGradientBrush to the screen prior to applying the rotate transform.
  • Applies the rotate transform to the brush by using its RotateTransform method.
  • Draws the rotated brush (rectangle) to the screen.

[Visual Basic, C#] Notice that the bottom rectangle is rotated 45 degrees as compared to the one drawn prior to the translation.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of RotateTransform. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub RotateTransformExample(e As PaintEventArgs)
' Create a graphics path and add a rectangle.
Dim myPath As New GraphicsPath()
Dim rect As New Rectangle(100, 20, 100, 50)
myPath.AddRectangle(rect)
' Get the path's array of points.
Dim myPathPointArray As PointF() = myPath.PathPoints
' Create a path gradient brush.
Dim myPGBrush As New PathGradientBrush(myPathPointArray)
' Set the color span.
myPGBrush.CenterColor = Color.Red
Dim mySurroundColor As Color() = {Color.Blue}
myPGBrush.SurroundColors = mySurroundColor
' Draw the brush to the screen prior to transformation.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)
' Apply the rotate transform to the brush.
myPGBrush.RotateTransform(45, MatrixOrder.Append)
' Draw the brush to the screen again after applying the
' transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300)
End Sub
        
[C#] 
public void RotateTransformExample(PaintEventArgs e)
{
// Create a graphics path and add an ellipse.
GraphicsPath myPath = new GraphicsPath();
Rectangle rect = new Rectangle(100, 20, 100, 50);
myPath.AddRectangle(rect);
// Get the path's array of points.
PointF[] myPathPointArray = myPath.PathPoints;
// Create a path gradient brush.
PathGradientBrush myPGBrush = new
PathGradientBrush(myPathPointArray);
// Set the color span.
myPGBrush.CenterColor = Color.Red;
Color[] mySurroundColor = {Color.Blue};
myPGBrush.SurroundColors = mySurroundColor;
// Draw the brush to the screen prior to transformation.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
// Apply the rotate transform to the brush.
myPGBrush.RotateTransform(45, MatrixOrder.Append);
// Draw the brush to the screen again after applying the
// transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

PathGradientBrush Class | PathGradientBrush Members | System.Drawing.Drawing2D Namespace

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.