Graphics.RotateTransform Metodo

Definizione

Applica la rotazione specificata alla matrice di trasformazione di questo Graphicsoggetto .

Overload

Nome Descrizione
RotateTransform(Single)

Applica la rotazione specificata alla matrice di trasformazione di questo Graphicsoggetto .

RotateTransform(Single, MatrixOrder)

Applica la rotazione specificata alla matrice di trasformazione di questo Graphics oggetto nell'ordine specificato.

RotateTransform(Single)

Applica la rotazione specificata alla matrice di trasformazione di questo Graphicsoggetto .

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

Parametri

angle
Single

Angolo di rotazione in gradi.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:

  • Converte la matrice di trasformazione globale del form Windows dal vettore (100, 0).

  • Ruota la trasformazione del mondo in base a un angolo di 30 gradi, anteponendo la matrice di rotazione alla matrice di trasformazione globale.

  • Disegna un'ellisse ruotata e tradotta con una penna blu.

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

Commenti

L'operazione di rotazione consiste nel moltiplicare la matrice di trasformazione per una matrice i cui elementi sono derivati dal angle parametro . Questo metodo applica la rotazione anteponendo la rotazione alla matrice di trasformazione.

Si applica a

RotateTransform(Single, MatrixOrder)

Applica la rotazione specificata alla matrice di trasformazione di questo Graphics oggetto nell'ordine specificato.

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)

Parametri

angle
Single

Angolo di rotazione in gradi.

order
MatrixOrder

Membro dell'enumerazione MatrixOrder che specifica se la rotazione viene aggiunta o anteporta alla trasformazione matrice.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del gestore eventi Paint. Il codice esegue le azioni seguenti:

  • Converte la matrice di trasformazione globale del form Windows dal vettore (100, 0).

  • Ruota la trasformazione globale in base a un angolo di 30 gradi, aggiungendo la matrice di rotazione alla matrice di trasformazione globale con Append.

  • Disegna un'ellisse tradotta ruotata con una penna blu.

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

Commenti

L'operazione di rotazione consiste nel moltiplicare la matrice di trasformazione per una matrice i cui elementi sono derivati dal angle parametro . Questo metodo antepone o aggiunge la matrice di trasformazione dell'oggetto Graphics dalla matrice di rotazione in base al order parametro .

Si applica a