Freigeben über


PathGradientBrush.RotateTransform Methode

Definition

Weist der lokalen geometrischen Transformation eine Drehung im Uhrzeigersinn mit dem angegebenen Drehwinkel zu.

Überlädt

RotateTransform(Single)

Dreht die lokale geometrische Transformation um den angegebenen Betrag. Diese Methode stellt der Transformation die Rotation voran.

RotateTransform(Single, MatrixOrder)

Dreht die lokale geometrische Transformation um den angegebenen Betrag in der angegebenen Reihenfolge.

RotateTransform(Single)

Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs

Dreht die lokale geometrische Transformation um den angegebenen Betrag. Diese Methode stellt der Transformation die Rotation voran.

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

Parameter

angle
Single

Der Drehwinkel.

Beispiele

Ein Beispiel finden Sie unter RotateTransform.

Gilt für:

RotateTransform(Single, MatrixOrder)

Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs
Quelle:
PathGradientBrush.cs

Dreht die lokale geometrische Transformation um den angegebenen Betrag in der angegebenen Reihenfolge.

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)

Parameter

angle
Single

Der Drehwinkel.

order
MatrixOrder

Eine MatrixOrder, die angibt, ob die Rotationsmatrix vorangestellt oder angefügt werden soll.

Beispiele

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgse, ein OnPaint Ereignisobjekt. Der Code führt die folgenden Aktionen aus:

  • Erstellt einen Grafikpfad und fügt diesem ein Rechteck hinzu.

  • Erstellt eine PathGradientBrush aus den Pfadpunkten (in diesem Beispiel bilden die Punkte ein Rechteck, aber es kann sich in den meisten Fällen um eine beliebige Form handeln).

  • Legt die Mittlere Farbe auf Rot und die umgebende Farbe auf Blau fest.

  • Zeichnet vor PathGradientBrush dem Anwenden der Drehtransformation auf den Bildschirm.

  • Wendet die Drehtransformation mithilfe RotateTransform der -Methode auf den Pinsel an.

  • Zeichnet den gedrehten Pinsel (Rechteck) auf den Bildschirm.

Beachten Sie, dass das untere Rechteck im Vergleich zum vor der Übersetzung gezeichneten Rechteck um 45 Grad gedreht wird.

public:
   void RotateTransformExample( PaintEventArgs^ e )
   {
      // Create a graphics path and add an ellipse.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Rectangle rect = Rectangle(100,20,100,50);
      myPath->AddRectangle( rect );

      // Get the path's array of points.
      array<PointF>^myPathPointArray = myPath->PathPoints;

      // Create a path gradient brush.
      PathGradientBrush^ myPGBrush = gcnew PathGradientBrush( myPathPointArray );

      // Set the color span.
      myPGBrush->CenterColor = Color::Red;
      array<Color>^ mySurroundColor = {Color::Blue};
      myPGBrush->SurroundColors = mySurroundColor;

      // Draw the brush to the screen prior to transformation.
      e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 200 );

      // Apply the rotate transform to the brush.
      myPGBrush->RotateTransform( 45, MatrixOrder::Append );

      // Draw the brush to the screen again after applying the
      // transform.
      e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 300 );
   }
public void RotateTransformExample(PaintEventArgs e)
{
             
    // Create a graphics path and add an ellipse.
    GraphicsPath myPath = new GraphicsPath();
    Rectangle rect = new Rectangle(100, 20, 100, 50);
    myPath.AddRectangle(rect);
             
    // Get the path's array of points.
    PointF[] myPathPointArray = myPath.PathPoints;
             
    // Create a path gradient brush.
    PathGradientBrush myPGBrush = new
        PathGradientBrush(myPathPointArray);
             
    // Set the color span.
    myPGBrush.CenterColor = Color.Red;
    Color[] mySurroundColor = {Color.Blue};
    myPGBrush.SurroundColors = mySurroundColor;
             
    // Draw the brush to the screen prior to transformation.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
             
    // Apply the rotate transform to the brush.
    myPGBrush.RotateTransform(45, MatrixOrder.Append);
             
    // Draw the brush to the screen again after applying the
    // transform.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300);
}
Public Sub RotateTransformExample(ByVal e As PaintEventArgs)

    ' Create a graphics path and add a rectangle.
    Dim myPath As New GraphicsPath
    Dim rect As New Rectangle(100, 20, 100, 50)
    myPath.AddRectangle(rect)

    ' Get the path's array of points.
    Dim myPathPointArray As PointF() = myPath.PathPoints

    ' Create a path gradient brush.
    Dim myPGBrush As New PathGradientBrush(myPathPointArray)

    ' Set the color span.
    myPGBrush.CenterColor = Color.Red
    Dim mySurroundColor As Color() = {Color.Blue}
    myPGBrush.SurroundColors = mySurroundColor

    ' Draw the brush to the screen prior to transformation.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)

    ' Apply the rotate transform to the brush.
    myPGBrush.RotateTransform(45, MatrixOrder.Append)

    ' Draw the brush to the screen again after applying the
    ' transform.
    e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300)
End Sub

Gilt für: