Pen.RotateTransform 方法

定义

按指定角度旋转局部几何转换。 此方法将旋转追加到转换之前。

重载

RotateTransform(Single, MatrixOrder)

按指定顺序按指定角度旋转局部几何转换。

RotateTransform(Single)

按指定角度旋转局部几何转换。 此方法将旋转追加到转换之前。

RotateTransform(Single, MatrixOrder)

Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs

按指定顺序按指定角度旋转局部几何转换。

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

旋转角度。

order
MatrixOrder

一个 MatrixOrder,指定是追加还是追加旋转矩阵。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建 Pen

  • 在 x 轴方向将笔缩放 2 次。

  • 使用笔绘制矩形。

  • 顺时针旋转笔 90 度。

  • 绘制第二个矩形来演示差异。

public:
   void RotateTransform_Example2( PaintEventArgs^ e )
   {
      
      // Create a Pen object.
      Pen^ rotatePen = gcnew Pen( Color::Black,5.0f );
      
      // Scale rotatePen by 2X in the x-direction.
      rotatePen->ScaleTransform( 2, 1 );
      
      // Draw a rectangle with rotatePen.
      e->Graphics->DrawRectangle( rotatePen, 10, 10, 100, 100 );
      
      // Rotate rotatePen 90 degrees clockwise.
      rotatePen->RotateTransform( 90, MatrixOrder::Append );
      
      // Draw a second rectangle with rotatePen.
      e->Graphics->DrawRectangle( rotatePen, 120, 10, 100, 100 );
   }
public void RotateTransform_Example2(PaintEventArgs e)
{
             
    // Create a Pen object.
    Pen rotatePen = new Pen(Color.Black, 5);
             
    // Scale rotatePen by 2X in the x-direction.
    rotatePen.ScaleTransform(2, 1);
             
    // Draw a rectangle with rotatePen.
    e.Graphics.DrawRectangle(rotatePen, 10, 10, 100, 100);
             
    // Rotate rotatePen 90 degrees clockwise.
    rotatePen.RotateTransform(90, MatrixOrder.Append);
             
    // Draw a second rectangle with rotatePen.
    e.Graphics.DrawRectangle(rotatePen, 120, 10, 100, 100);
}
Public Sub RotateTransform_Example2(ByVal e As PaintEventArgs)

    ' Create a Pen object.
    Dim rotatePen As New Pen(Color.Black, 5)

    ' Scale rotatePen by 2X in the x-direction.
    rotatePen.ScaleTransform(2, 1)

    ' Draw a rectangle with rotatePen.
    e.Graphics.DrawRectangle(rotatePen, 10, 10, 100, 100)

    ' Rotate rotatePen 90 degrees clockwise.
    rotatePen.RotateTransform(90, MatrixOrder.Append)

    ' Draw a second rectangle with rotatePen.
    e.Graphics.DrawRectangle(rotatePen, 120, 10, 100, 100)
End Sub

注解

由于笔的形状是圆形的,因此旋转没有任何可见效果,除非笔在 x 轴或 y 轴方向缩放。

适用于

RotateTransform(Single)

Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs

按指定角度旋转局部几何转换。 此方法将旋转追加到转换之前。

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

参数

angle
Single

旋转角度。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建 Pen

  • 使用笔绘制矩形。

  • 在 x 轴方向将笔缩放 2 次。

  • 顺时针旋转笔 90 度。

  • 绘制第二个矩形来演示差异。

public:
   void RotateTransform_Example1( PaintEventArgs^ e )
   {
      
      // Create a Pen object.
      Pen^ rotatePen = gcnew Pen( Color::Black,5.0f );
      
      // Draw a rectangle with rotatePen.
      e->Graphics->DrawRectangle( rotatePen, 10, 10, 100, 100 );
      
      // Scale rotatePen by 2X in the x-direction.
      rotatePen->ScaleTransform( 2, 1 );
      
      // Rotate rotatePen 90 degrees clockwise.
      rotatePen->RotateTransform( 90 );
      
      // Draw a second rectangle with rotatePen.
      e->Graphics->DrawRectangle( rotatePen, 140, 10, 100, 100 );
   }
public void RotateTransform_Example1(PaintEventArgs e)
{
             
    // Create a Pen object.
    Pen rotatePen = new Pen(Color.Black, 5);
             
    // Draw a rectangle with rotatePen.
    e.Graphics.DrawRectangle(rotatePen, 10, 10, 100, 100);
             
    // Scale rotatePen by 2X in the x-direction.
    rotatePen.ScaleTransform(2, 1);
             
    // Rotate rotatePen 90 degrees clockwise.
    rotatePen.RotateTransform(90);
             
    // Draw a second rectangle with rotatePen.
    e.Graphics.DrawRectangle(rotatePen, 140, 10, 100, 100);
}
Public Sub RotateTransform_Example1(ByVal e As PaintEventArgs)

    ' Create a Pen object.
    Dim rotatePen As New Pen(Color.Black, 5)

    ' Draw a rectangle with rotatePen.
    e.Graphics.DrawRectangle(rotatePen, 10, 10, 100, 100)

    ' Scale rotatePen by 2X in the x-direction.
    rotatePen.ScaleTransform(2, 1)

    ' Rotate rotatePen 90 degrees clockwise.
    rotatePen.RotateTransform(90)

    ' Draw a second rectangle with rotatePen.
    e.Graphics.DrawRectangle(rotatePen, 140, 10, 100, 100)
End Sub

注解

由于笔的形状是圆形的,因此旋转没有任何可见效果,除非笔在 x 轴或 y 轴方向缩放。

适用于