Compartilhar via


Matrix.Rotate Método

Definição

Aplica uma rotação no sentido horário do ângulo especificado sobre a origem a este Matrix.

Sobrecargas

Rotate(Single)

Preceda a isso Matrix uma rotação no sentido horário ao redor da origem e pelo ângulo especificado.

Rotate(Single, MatrixOrder)

Aplica uma rotação no sentido horário de um valor especificado no parâmetro angle, em torno da origem (coordenadas x e y zero) para esse Matrix.

Rotate(Single)

Origem:
Matrix.cs
Origem:
Matrix.cs
Origem:
Matrix.cs

Preceda a isso Matrix uma rotação no sentido horário ao redor da origem e pelo ângulo especificado.

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

Parâmetros

angle
Single

O ângulo de rotação, em graus.

Exemplos

Para ver um exemplo, consulte Rotate(Single, MatrixOrder).

Aplica-se a

Rotate(Single, MatrixOrder)

Origem:
Matrix.cs
Origem:
Matrix.cs
Origem:
Matrix.cs

Aplica uma rotação no sentido horário de um valor especificado no parâmetro angle, em torno da origem (coordenadas x e y zero) para esse Matrix.

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)

Parâmetros

angle
Single

O ângulo (extensão) de rotação, em graus.

order
MatrixOrder

Um MatrixOrder que especifica a ordem (suceder ou preceder) em que a rotação é aplicada a este Matrix.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, um Paint objeto de evento. O código executa as seguintes ações:

  • Desenha um retângulo na tela antes de aplicar uma transformação de rotação (o retângulo azul).

  • Cria uma matriz e gira-a 45 graus.

  • Aplica essa transformação de matriz ao retângulo.

  • Desenha o retângulo transformado para a tela (o retângulo vermelho).

Observe que o retângulo vermelho foi girado em torno das coordenadas de tela 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

Aplica-se a