Matrix.Rotate 方法

定义

对此 Matrix 沿原点顺时针旋转指定角度。

重载

Rotate(Single)

预先计算此 Matrix,沿原点并按指定角度顺时针旋转。

Rotate(Single, MatrixOrder)

按照 angle 参数中指定的顺时针旋转量,对此 Matrix 沿原点(X 和 Y 坐标为零处)旋转。

Rotate(Single)

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

按照 angle 参数中指定的顺时针旋转量,对此 Matrix 沿原点(X 和 Y 坐标为零处)旋转。

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 窗体 一起使用,它需要 PaintEventArgse事件Paint对象。 此代码执行以下操作:

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

  • 创建矩阵并将其旋转 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

适用于