Graphics.RotateTransform 方法

定义

将指定旋转应用于此 Graphics 的转换矩阵。

重载

RotateTransform(Single)

将指定旋转应用于此 Graphics 的转换矩阵。

RotateTransform(Single, MatrixOrder)

以指定顺序将指定旋转应用到此 Graphics 的变换矩阵。

RotateTransform(Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

将指定旋转应用于此 Graphics 的转换矩阵。

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一个参数。 此代码执行以下操作:

  • 按向量 (100, 0) 平移 Windows 窗体的世界转换矩阵。

  • 以 30 度的角度旋转世界变换,在旋转矩阵前面追加到世界转换矩阵。

  • 使用蓝色笔绘制旋转的翻译椭圆。

public:
   void RotateTransformAngle( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to translate.
      e->Graphics->TranslateTransform( 100.0F, 0.0F );

      // Then to rotate, prepending rotation matrix.
      e->Graphics->RotateTransform( 30.0F );

      // Draw rotated, translated ellipse to screen.
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), 0, 0, 200, 80 );
   }
private void RotateTransformAngle(PaintEventArgs e)
{

    // Set world transform of graphics object to translate.
    e.Graphics.TranslateTransform(100.0F, 0.0F);

    // Then to rotate, prepending rotation matrix.
    e.Graphics.RotateTransform(30.0F);

    // Draw rotated, translated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}
Private Sub RotateTransformAngle(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to translate.
    e.Graphics.TranslateTransform(100.0F, 0.0F)

    ' Then to rotate, prepending rotation matrix.
    e.Graphics.RotateTransform(30.0F)

    ' Draw rotated, translated ellipse to screen.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub

注解

旋转运算包括将转换矩阵乘以元素派生自 angle 参数的矩阵。 此方法通过将旋转追加到转换矩阵前来应用旋转。

适用于

RotateTransform(Single, MatrixOrder)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

以指定顺序将指定旋转应用到此 Graphics 的变换矩阵。

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一个参数。 此代码执行以下操作:

  • 按向量 (100, 0) 平移 Windows 窗体的世界转换矩阵。

  • 以 30 度的角度旋转世界变换,使用 将旋转矩阵追加到世界转换矩阵 Append

  • 使用蓝色笔绘制已翻译的旋转椭圆。

public:
   void RotateTransformAngleMatrixOrder( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to translate.
      e->Graphics->TranslateTransform( 100.0F, 0.0F );

      // Then to rotate, appending rotation matrix.
      e->Graphics->RotateTransform( 30.0F, MatrixOrder::Append );

      // Draw translated, rotated ellipse to screen.
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), 0, 0, 200, 80 );
   }
private void RotateTransformAngleMatrixOrder(PaintEventArgs e)
{

    // Set world transform of graphics object to translate.
    e.Graphics.TranslateTransform(100.0F, 0.0F);

    // Then to rotate, appending rotation matrix.
    e.Graphics.RotateTransform(30.0F, MatrixOrder.Append);

    // Draw translated, rotated ellipse to screen.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), 0, 0, 200, 80);
}
Private Sub RotateTransformAngleMatrixOrder(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to translate.
    e.Graphics.TranslateTransform(100.0F, 0.0F)

    ' Then to rotate, appending rotation matrix.
    e.Graphics.RotateTransform(30.0F, MatrixOrder.Append)

    ' Draw translated, rotated ellipse to screen.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), 0, 0, 200, 80)
End Sub

注解

旋转运算包括将转换矩阵乘以元素派生自 angle 参数的矩阵。 此方法根据 order 参数通过旋转矩阵追加或追加 的Graphics转换矩阵。

适用于