GraphicsPath.GetBounds Método

Definición

Devuelve un rectángulo que delimita este trazado GraphicsPath.

Sobrecargas

GetBounds()

Devuelve un rectángulo que delimita este trazado GraphicsPath.

GetBounds(Matrix)

Devuelve un rectángulo que delimita este trazado GraphicsPath cuando se transforma por la matriz Matrix especificada.

GetBounds(Matrix, Pen)

Devuelve un rectángulo que delimita este trazado GraphicsPath cuando el actual trazado se transforma por la matriz Matrix especificada y se dibuja con el Pen indicado.

GetBounds()

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Devuelve un rectángulo que delimita este trazado GraphicsPath.

public:
 System::Drawing::RectangleF GetBounds();
public System.Drawing.RectangleF GetBounds ();
member this.GetBounds : unit -> System.Drawing.RectangleF
Public Function GetBounds () As RectangleF

Devoluciones

RectangleF que representa un rectángulo que delimita este trazado GraphicsPath.

Ejemplos

El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, un OnPaint objeto de evento. El código realiza las siguientes acciones:

  • Crea una ruta de acceso de gráficos.

  • Agrega una elipse (círculo) a ella y la dibuja en la pantalla.

  • Recupera el rectángulo delimitador del círculo con una llamada a GetBounds y dibuja el rectángulo en la pantalla.

  • Crea una segunda ruta de acceso de gráficos.

  • Agrega un círculo y amplía la ruta de acceso a un ancho de 10.

  • Dibuja la ruta de acceso a la pantalla.

  • Recupera el rectángulo delimitador del segundo círculo.

  • Dibuja el rectángulo delimitador en la pantalla.

  • Muestra el tamaño del rectángulo en un cuadro de diálogo.

Observe que el rectángulo delimitador de la derecha es mayor (para tener en cuenta el ancho adicional de la línea).

public:
   void GetBoundsExample( PaintEventArgs^ e )
   {
      // Create path number 1 and a Pen for drawing.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Pen^ pathPen = gcnew Pen( Color::Black,1.0f );

      // Add an Ellipse to the path and Draw it (circle in start
      // position).
      myPath->AddEllipse( 20, 20, 100, 100 );
      e->Graphics->DrawPath( pathPen, myPath );

      // Get the path bounds for Path number 1 and draw them.
      RectangleF boundRect = myPath->GetBounds();
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red,1.0f ), boundRect.X, boundRect.Y, boundRect.Height, boundRect.Width );

      // Create a second graphics path and a wider Pen.
      GraphicsPath^ myPath2 = gcnew GraphicsPath;
      Pen^ pathPen2 = gcnew Pen( Color::Black,10.0f );

      // Create a new ellipse with a width of 10.
      myPath2->AddEllipse( 150, 20, 100, 100 );
      myPath2->Widen( pathPen2 );
      e->Graphics->FillPath( Brushes::Black, myPath2 );

      // Get the second path bounds.
      RectangleF boundRect2 = myPath2->GetBounds();

      // Draw the bounding rectangle.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red,1.0f ), boundRect2.X, boundRect2.Y, boundRect2.Height, boundRect2.Width );

      // Display the rectangle size.
      MessageBox::Show( boundRect2.ToString() );
   }
public void GetBoundsExample(PaintEventArgs e)
{
             
    // Create path number 1 and a Pen for drawing.
    GraphicsPath myPath = new GraphicsPath();
    Pen pathPen = new Pen(Color.Black, 1);
             
    // Add an Ellipse to the path and Draw it (circle in start
             
    // position).
    myPath.AddEllipse(20, 20, 100, 100);
    e.Graphics.DrawPath(pathPen, myPath);
             
    // Get the path bounds for Path number 1 and draw them.
    RectangleF boundRect = myPath.GetBounds();
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
        boundRect.X,
        boundRect.Y,
        boundRect.Height,
        boundRect.Width);
             
    // Create a second graphics path and a wider Pen.
    GraphicsPath myPath2 = new GraphicsPath();
    Pen pathPen2 = new Pen(Color.Black, 10);
             
    // Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100);
    myPath2.Widen(pathPen2);
    e.Graphics.FillPath(Brushes.Black, myPath2);
             
    // Get the second path bounds.
    RectangleF boundRect2 = myPath2.GetBounds();
             
    // Draw the bounding rectangle.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
        boundRect2.X,
        boundRect2.Y,
        boundRect2.Height,
        boundRect2.Width);
             
    // Display the rectangle size.
    MessageBox.Show(boundRect2.ToString());
}
Public Sub GetBoundsExample(ByVal e As PaintEventArgs)

    ' Create path number 1 and a Pen for drawing.
    Dim myPath As New GraphicsPath
    Dim pathPen As New Pen(Color.Black, 1)

    ' Add an Ellipse to the path and Draw it (circle in start

    ' position).
    myPath.AddEllipse(20, 20, 100, 100)
    e.Graphics.DrawPath(pathPen, myPath)

    ' Get the path bounds for Path number 1 and draw them.
    Dim boundRect As RectangleF = myPath.GetBounds()
    e.Graphics.DrawRectangle(New Pen(Color.Red, 1), boundRect.X, _
    boundRect.Y, boundRect.Height, boundRect.Width)

    ' Create a second graphics path and a wider Pen.
    Dim myPath2 As New GraphicsPath
    Dim pathPen2 As New Pen(Color.Black, 10)

    ' Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100)
    myPath2.Widen(pathPen2)
    e.Graphics.FillPath(Brushes.Black, myPath2)

    ' Get the second path bounds.
    Dim boundRect2 As RectangleF = myPath2.GetBounds()

    ' Show the bounds in a message box.
    e.Graphics.DrawString("Rectangle2 Bounds: " + _
    boundRect2.ToString(), New Font("Arial", 8), Brushes.Black, _
    20, 150)

    ' Draw the bounding rectangle.
    e.Graphics.DrawRectangle(New Pen(Color.Red, 1), boundRect2.X, _
    boundRect2.Y, boundRect2.Height, boundRect2.Width)
End Sub

Comentarios

El tamaño del rectángulo delimitador devuelto se ve afectado por el tipo de límites finales, el ancho del lápiz y el límite del miter del lápiz, y, por lo tanto, genera un "ajuste flexible" a la ruta de acceso delimitada. La fórmula aproximada es: el rectángulo delimitador inicial se infla por ancho de lápiz y este resultado se multiplica por el límite de miter, además de algún margen adicional para permitir los límites finales.

Se aplica a

GetBounds(Matrix)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Devuelve un rectángulo que delimita este trazado GraphicsPath cuando se transforma por la matriz Matrix especificada.

public:
 System::Drawing::RectangleF GetBounds(System::Drawing::Drawing2D::Matrix ^ matrix);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix matrix);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix? matrix);
member this.GetBounds : System.Drawing.Drawing2D.Matrix -> System.Drawing.RectangleF
Public Function GetBounds (matrix As Matrix) As RectangleF

Parámetros

matrix
Matrix

Matrix que especifica la transformación que se va a aplicar a este trazado antes de que se calcule el rectángulo delimitador. Este trazado no se transforma de manera permanente, se usa sólo durante el proceso de cálculo del rectángulo delimitador.

Devoluciones

RectangleF que representa un rectángulo que delimita este trazado GraphicsPath.

Ejemplos

Para obtener un ejemplo, consulte GetBounds().

Comentarios

El tamaño del rectángulo delimitador devuelto se ve afectado por el tipo de límites finales, el ancho del lápiz y el límite del miter del lápiz, y, por lo tanto, genera un "ajuste flexible" a la ruta de acceso delimitada. La fórmula aproximada es: el rectángulo delimitador inicial se infla por ancho de lápiz y este resultado se multiplica por el límite de miter, además de algún margen adicional para permitir los límites finales.

Se aplica a

GetBounds(Matrix, Pen)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Devuelve un rectángulo que delimita este trazado GraphicsPath cuando el actual trazado se transforma por la matriz Matrix especificada y se dibuja con el Pen indicado.

public:
 System::Drawing::RectangleF GetBounds(System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Pen ^ pen);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Pen pen);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Pen? pen);
member this.GetBounds : System.Drawing.Drawing2D.Matrix * System.Drawing.Pen -> System.Drawing.RectangleF
Public Function GetBounds (matrix As Matrix, pen As Pen) As RectangleF

Parámetros

matrix
Matrix

Matrix que especifica la transformación que se va a aplicar a este trazado antes de que se calcule el rectángulo delimitador. Este trazado no se transforma de manera permanente, se usa sólo durante el proceso de cálculo del rectángulo delimitador.

pen
Pen

Pen con el que se va a dibujar el trazado GraphicsPath.

Devoluciones

RectangleF que representa un rectángulo que delimita este trazado GraphicsPath.

Ejemplos

Para obtener un ejemplo, consulte GetBounds().

Comentarios

El tamaño del rectángulo delimitador devuelto se ve afectado por el tipo de límites finales, el ancho del lápiz y el límite del miter del lápiz, y, por lo tanto, genera un "ajuste flexible" a la ruta de acceso delimitada. La fórmula aproximada es: el rectángulo delimitador inicial se infla por ancho de lápiz y este resultado se multiplica por el límite de miter, además de algún margen adicional para permitir los límites finales.

Se aplica a