Matrix.Rotate Metoda

Definicja

Stosuje obrót zgodnie z ruchem wskazówek zegara dla określonego kąta o pochodzeniu do tego Matrixobiektu .

Przeciążenia

Rotate(Single)

Przed tym Matrix obrót zgodnie z ruchem wskazówek zegara, wokół punktu początkowego i przez określony kąt.

Rotate(Single, MatrixOrder)

Stosuje obrót zgodnie z ruchem wskazówek zegara określonej w parametrze angle , wokół źródła (zero x i y współrzędnych) dla tego Matrixparametru .

Rotate(Single)

Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs

Przed tym Matrix obrót zgodnie z ruchem wskazówek zegara, wokół punktu początkowego i przez określony kąt.

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

Parametry

angle
Single

Kąt obrotu w stopniach.

Przykłady

Aby zapoznać się z przykładem, zobacz Rotate(Single, MatrixOrder).

Dotyczy

Rotate(Single, MatrixOrder)

Źródło:
Matrix.cs
Źródło:
Matrix.cs
Źródło:
Matrix.cs

Stosuje obrót zgodnie z ruchem wskazówek zegara określonej w parametrze angle , wokół źródła (zero x i y współrzędnych) dla tego Matrixparametru .

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)

Parametry

angle
Single

Kąt (zakres) obrotu w stopniach.

order
MatrixOrder

Element MatrixOrder określający kolejność (dołączanie lub wstępnego) w której jest stosowana rotacja do tego Matrixelementu .

Przykłady

Poniższy przykład kodu jest przeznaczony do użytku z Windows Forms i wymaga PaintEventArgseobiektu Paint zdarzenia . Kod wykonuje następujące akcje:

  • Rysuje prostokąt na ekranie przed zastosowaniem przekształcenia obrotu (niebieski prostokąt).

  • Tworzy macierz i obraca ją o 45 stopni.

  • Stosuje tę transformację macierzy do prostokąta.

  • Rysuje przekształcony prostokąt na ekran (czerwony prostokąt).

Zwróć uwagę, że czerwony prostokąt został obrócony wokół współrzędnych ekranu 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

Dotyczy