GraphicsPath.Transform(Matrix) Método

Definición

Aplica una matriz de transformación a este trazado GraphicsPath.Applies a transform matrix to this GraphicsPath.

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

Parámetros

matrix
Matrix

Matrix que representa la transformación que se va a aplicar.A Matrix that represents the transformation to apply.

Ejemplos

El siguiente ejemplo de código está diseñado para su uso con Windows Forms y requiere PaintEventArgse, un objeto de evento de OnPaint.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. El código realiza las siguientes acciones:The code performs the following actions:

  • Crea una ruta de acceso y agrega una elipse a la ruta de acceso.Creates a path and adds an ellipse to the path.

  • Dibuja la ruta de acceso a la pantalla.Draws path to the screen.

  • Crea una matriz de transformación para convertir las unidades de trazado 100 en la dirección del eje x.Creates a transform matrix to translate the path 100 units in the x-axis direction.

  • Dibuja la ruta de acceso transformada en la pantalla.Draws the transformed path to the screen.

Observe que la elipse original se dibuja en negro y la elipse transformada se dibuja en rojo.Notice that the original ellipse is drawn in black and the transformed ellipse is drawn in red.

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

Comentarios

La transformación puede escalar, trasladar, girar o sesgar el GraphicsPath.The transformation can scale, translate, rotate, or skew the GraphicsPath.

Se aplica a