PathGradientBrush.RotateTransform 方法

定义

将指定角度的顺时针旋转应用到局部几何变换。Applies a clockwise rotation of the specified angle to the local geometric transform.

重载

RotateTransform(Single)

将局部几何转换旋转指定大小。Rotates the local geometric transform by the specified amount. 此方法预先计算对转换的旋转。This method prepends the rotation to the transform.

RotateTransform(Single, MatrixOrder)

将局部几何转换以指定顺序旋转指定量。Rotates the local geometric transform by the specified amount in the specified order.

RotateTransform(Single)

将局部几何转换旋转指定大小。Rotates the local geometric transform by the specified amount. 此方法预先计算对转换的旋转。This method prepends the rotation to the transform.

public:
 void RotateTransform(float angle);
public void RotateTransform (float angle);
member this.RotateTransform : single -> unit
Public Sub RotateTransform (angle As Single)

参数

angle
Single

旋转角度(范围)。The angle (extent) of rotation.

示例

有关示例,请参阅RotateTransformFor an example, see RotateTransform.

RotateTransform(Single, MatrixOrder)

将局部几何转换以指定顺序旋转指定量。Rotates the local geometric transform by the specified amount in the specified order.

public:
 void RotateTransform(float angle, System::Drawing::Drawing2D::MatrixOrder order);
public void RotateTransform (float angle, System.Drawing.Drawing2D.MatrixOrder order);
member this.RotateTransform : single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub RotateTransform (angle As Single, order As MatrixOrder)

参数

angle
Single

旋转角度(范围)。The angle (extent) of rotation.

order
MatrixOrder

一个 MatrixOrder,它指定是在后面追加旋转矩阵还是在前面添加旋转矩阵。A MatrixOrder that specifies whether to append or prepend the rotation matrix.

示例

下面的代码示例是为与 Windows 窗体一起使用而设计的,它需要 PaintEventArgseOnPaint 事件对象。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. 该代码执行下列操作:The code performs the following actions:

  • 创建图形路径并向其添加一个矩形。Creates a graphics path and adds a rectangle to it.

  • 从路径点创建一个 PathGradientBrush (在此示例中,点构成一个矩形,但它可以是大多数形状)。Creates a PathGradientBrush 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.

  • 在应用旋转变换之前,将 PathGradientBrush 绘制到屏幕上。Draws the PathGradientBrush to the screen prior to applying the rotate transform.

  • 使用画笔 RotateTransform 方法将旋转转换应用到画笔。Applies the rotate transform to the brush by using its RotateTransform method.

  • 将旋转的画笔(矩形)绘制到屏幕上。Draws the rotated brush (rectangle) to the screen.

请注意,底部矩形旋转了45度,与平移前绘制的矩形相比。Notice that the bottom rectangle is rotated 45 degrees as compared to the one drawn prior to the translation.

public:
   void RotateTransformExample( PaintEventArgs^ e )
   {
      // Create a graphics path and add an ellipse.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Rectangle rect = Rectangle(100,20,100,50);
      myPath->AddRectangle( rect );

      // Get the path's array of points.
      array<PointF>^myPathPointArray = myPath->PathPoints;

      // Create a path gradient brush.
      PathGradientBrush^ myPGBrush = gcnew PathGradientBrush( myPathPointArray );

      // Set the color span.
      myPGBrush->CenterColor = Color::Red;
      array<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 );
   }
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);
}
Public Sub RotateTransformExample(ByVal 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

适用于