Matrix.Rotate 方法

定义

将指定角度的顺时针旋转应用于此 Matrix

重载

Rotate(Single)

前面 Matrix 顺时针旋转,围绕原点和指定角度。

Rotate(Single, MatrixOrder)

在此 Matrix的原点(零 x 和 y 坐标)周围应用 angle 参数中指定的量顺时针旋转。

Rotate(Single)

Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs

前面 Matrix 顺时针旋转,围绕原点和指定角度。

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

参数

angle
Single

旋转的角度(以度为单位)。

示例

有关示例,请参阅 Rotate(Single, MatrixOrder)

适用于

Rotate(Single, MatrixOrder)

Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs

在此 Matrix的原点(零 x 和 y 坐标)周围应用 angle 参数中指定的量顺时针旋转。

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

参数

angle
Single

旋转的角度(范围),以度为单位。

order
MatrixOrder

一个 MatrixOrder,指定旋转应用于此 Matrix的顺序(追加或追加)。

示例

下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgsePaint 事件对象。 该代码执行以下操作:

  • 在应用旋转转换(蓝色矩形)之前,将矩形绘制到屏幕。

  • 创建矩阵并将其旋转 45 度。

  • 将此矩阵转换应用于矩形。

  • 将转换后的矩形绘制到屏幕(红色矩形)。

请注意,红色矩形已围绕 0,0 屏幕坐标旋转。

public:
   void RotateExample( PaintEventArgs^ e )
   {
      Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
      Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );

      // Draw the rectangle to the screen before applying the transform.
      e->Graphics->DrawRectangle( myPen, 150, 50, 200, 100 );

      // Create a matrix and rotate it 45 degrees.
      Matrix^ myMatrix = gcnew Matrix;
      myMatrix->Rotate( 45, MatrixOrder::Append );

      // Draw the rectangle to the screen again after applying the
      // transform.
      e->Graphics->Transform = myMatrix;
      e->Graphics->DrawRectangle( myPen2, 150, 50, 200, 100 );
   }
public void RotateExample(PaintEventArgs e)
{
    Pen myPen = new Pen(Color.Blue, 1);
    Pen myPen2 = new Pen(Color.Red, 1);
             
    // Draw the rectangle to the screen before applying the transform.
    e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100);
             
    // Create a matrix and rotate it 45 degrees.
    Matrix myMatrix = new Matrix();
    myMatrix.Rotate(45, MatrixOrder.Append);
             
    // Draw the rectangle to the screen again after applying the
             
    // transform.
    e.Graphics.Transform = myMatrix;
    e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100);
}
Public Sub RotateExample(ByVal e As PaintEventArgs)
    Dim myPen As New Pen(Color.Blue, 1)
    Dim myPen2 As New Pen(Color.Red, 1)

    ' Draw the rectangle to the screen before applying the transform.
    e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100)

    ' Create a matrix and rotate it 45 degrees.
    Dim myMatrix As New Matrix
    myMatrix.Rotate(45, MatrixOrder.Append)

    ' Draw the rectangle to the screen again after applying the
    ' transform.
    e.Graphics.Transform = myMatrix
    e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100)
End Sub

适用于