Region.Transform(Matrix) Método

Definición

Transforma esta Region mediante la Matrix especificada.

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)

Parámetros

matrix
Matrix

Matrix mediante la cual se va a transformar esta Region.

Excepciones

matrix es null.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, que es un parámetro del Paint controlador de eventos. El código realiza las siguientes acciones:

  • Crea un rectángulo y lo dibuja en la pantalla en azul.

  • Crea una región a partir del rectángulo.

  • Crea una matriz de transformación y la establece en 45 grados.

  • Aplica la transformación a la región.

  • Rellena la región transformada con rojo y dibuja la región transformada en la pantalla en rojo.

Observe que el rectángulo rojo gira 45 grados desde el rectángulo original, que se muestra en azul.

public:
   void TransformExample( PaintEventArgs^ e )
   {
      
      // Create the first rectangle and draw it to the screen in blue.
      Rectangle regionRect = Rectangle(100,50,100,100);
      e->Graphics->DrawRectangle( Pens::Blue, regionRect );
      
      // Create a region using the first rectangle.
      System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );
      
      // Create a transform matrix and set it to have a 45 degree
      // rotation.
      Matrix^ transformMatrix = gcnew Matrix;
      transformMatrix->RotateAt( 45, Point(100,50) );
      
      // Apply the transform to the region.
      myRegion->Transform(transformMatrix);
      
      // Fill the transformed region with red and draw it to the screen
      // in red.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Red );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void TransformExample(PaintEventArgs e)
{
             
    // Create the first rectangle and draw it to the screen in blue.
    Rectangle regionRect = new Rectangle(100, 50, 100, 100);
    e.Graphics.DrawRectangle(Pens.Blue, regionRect);
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Create a transform matrix and set it to have a 45 degree
             
    // rotation.
    Matrix transformMatrix = new Matrix();
    transformMatrix.RotateAt(45, new Point(100, 50));
             
    // Apply the transform to the region.
    myRegion.Transform(transformMatrix);
             
    // Fill the transformed region with red and draw it to the screen
             
    // in red.
    SolidBrush myBrush = new SolidBrush(Color.Red);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub TransformExample(ByVal e As PaintEventArgs)

    ' Create the first rectangle and draw it to the screen in blue.
    Dim regionRect As New Rectangle(100, 50, 100, 100)
    e.Graphics.DrawRectangle(Pens.Blue, regionRect)

    ' Create a region using the first rectangle.
    Dim myRegion As New [Region](regionRect)

    ' Create a transform matrix and set it to have a 45 degree
    ' rotation.
    Dim transformMatrix As New Matrix
    transformMatrix.RotateAt(45, New PointF(100, 50))

    ' Apply the transform to the region.
    myRegion.Transform(transformMatrix)

    ' Fill the transformed region with red and draw it to the
    ' screen in red.
    Dim myBrush As New SolidBrush(Color.Red)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

Se aplica a