GraphicsPath.Transform(Matrix) Methode

Definition

Weist diesem GraphicsPath eine Transformationsmatrix zu.

public:
 void Transform(System::Drawing::Drawing2D::Matrix ^ matrix);
public void Transform (System.Drawing.Drawing2D.Matrix matrix);
member this.Transform : System.Drawing.Drawing2D.Matrix -> unit
Public Sub Transform (matrix As Matrix)

Parameter

matrix
Matrix

Eine Matrix, die die zuzuweisende Transformation darstellt.

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 Pfad und fügt dem Pfad eine Ellipse hinzu.

  • Zeichnet den Pfad zum Bildschirm.

  • Erstellt eine Transformationsmatrix, um den Pfad von 100 Einheiten in x-Achse-Richtung zu übersetzen.

  • Zeichnet den transformierten Pfad zum Bildschirm.

Beachten Sie, dass die ursprüngliche Ellipse schwarz und die transformierte Ellipse rot gezeichnet ist.

private:
   void TransformExample( PaintEventArgs^ e )
   {
      // Create a path and add and ellipse.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->AddEllipse( 0, 0, 100, 200 );

      // Draw the starting position to screen.
      e->Graphics->DrawPath( Pens::Black, myPath );

      // Move the ellipse 100 points to the right.
      Matrix^ translateMatrix = gcnew Matrix;
      translateMatrix->Translate( 100, 0 );
      myPath->Transform(translateMatrix);

      // Draw the transformed ellipse to the screen.
      e->Graphics->DrawPath( gcnew Pen( Color::Red,2.0f ), myPath );
   }
private void TransformExample(PaintEventArgs e)
{
             
    // Create a path and add and ellipse.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddEllipse(0, 0, 100, 200);
             
    // Draw the starting position to screen.
    e.Graphics.DrawPath(Pens.Black, myPath);
             
    // Move the ellipse 100 points to the right.
    Matrix translateMatrix = new Matrix();
    translateMatrix.Translate(100, 0);
    myPath.Transform(translateMatrix);
             
    // Draw the transformed ellipse to the screen.
    e.Graphics.DrawPath(new Pen(Color.Red, 2), myPath);
}
Public Sub TransformExample(ByVal e As PaintEventArgs)

    ' Create a path and add and ellipse.
    Dim myPath As New GraphicsPath
    myPath.AddEllipse(0, 0, 100, 200)

    ' Draw the starting position to screen.
    e.Graphics.DrawPath(Pens.Black, myPath)

    ' Move the ellipse 100 points to the right.
    Dim translateMatrix As New Matrix
    translateMatrix.Translate(100, 0)
    myPath.Transform(translateMatrix)

    ' Draw the transformed ellipse to the screen.
    e.Graphics.DrawPath(New Pen(Color.Red, 2), myPath)
End Sub

Hinweise

Die Transformation kann skalieren, übersetzen, rotieren oder verzerren GraphicsPath.

Gilt für: