GraphicsPath.GetBounds Método
Definição
Retorna um retângulo que circunda esse GraphicsPath.Returns a rectangle that bounds this GraphicsPath.
Sobrecargas
| GetBounds(Matrix) |
Retorna um retângulo que delimita este GraphicsPath quando este caminho é transformado pelo Matrix especificado.Returns a rectangle that bounds this GraphicsPath when this path is transformed by the specified Matrix. |
| GetBounds(Matrix, Pen) |
Retorna um retângulo que delimita este GraphicsPath quando o caminho atual é transformado pelo Matrix especificado e desenhado com a Pen especificada.Returns a rectangle that bounds this GraphicsPath when the current path is transformed by the specified Matrix and drawn with the specified Pen. |
| GetBounds() |
Retorna um retângulo que circunda esse GraphicsPath.Returns a rectangle that bounds this GraphicsPath. |
GetBounds(Matrix)
Retorna um retângulo que delimita este GraphicsPath quando este caminho é transformado pelo Matrix especificado.Returns a rectangle that bounds this GraphicsPath when this path is transformed by the specified Matrix.
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
O Matrix que especifica uma transformação a ser aplicada a esse caminho antes do retângulo delimitador ser calculado.The Matrix that specifies a transformation to be applied to this path before the bounding rectangle is calculated. Esse caminho não é transformado permanentemente; a transformação é usada somente durante o processo de cálculo do retângulo delimitador.This path is not permanently transformed; the transformation is used only during the process of calculating the bounding rectangle.
Retornos
Um RectangleF que representa um retângulo que circunda esse GraphicsPath.A RectangleF that represents a rectangle that bounds this GraphicsPath.
Exemplos
Para ver um exemplo, consulte GetBounds().For an example, see GetBounds().
Comentários
O tamanho do retângulo delimitador retornado é influenciado pelo tipo de limites de extremidade, largura da caneta e limite de Mitre da caneta e, portanto, produz um "ajuste flexível" ao caminho limitado.The size of the returned bounding rectangle is influenced by the type of end caps, pen width, and pen miter limit, and therefore produces a "loose fit" to the bounded path. A fórmula aproximada é: o retângulo delimitador inicial é achatado pela largura da caneta e esse resultado é multiplicado pelo limite de Mitre, além de uma margem adicional para permitir extremidades.The approximate formula is: the initial bounding rectangle is inflated by pen width, and this result is multiplied by the miter limit, plus some additional margin to allow for end caps.
Aplica-se a
GetBounds(Matrix, Pen)
Retorna um retângulo que delimita este GraphicsPath quando o caminho atual é transformado pelo Matrix especificado e desenhado com a Pen especificada.Returns a rectangle that bounds this GraphicsPath when the current path is transformed by the specified Matrix and drawn with the specified 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);
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
O Matrix que especifica uma transformação a ser aplicada a esse caminho antes do retângulo delimitador ser calculado.The Matrix that specifies a transformation to be applied to this path before the bounding rectangle is calculated. Esse caminho não é transformado permanentemente; a transformação é usada somente durante o processo de cálculo do retângulo delimitador.This path is not permanently transformed; the transformation is used only during the process of calculating the bounding rectangle.
- pen
- Pen
A Pen com a qual desenhar o GraphicsPath.The Pen with which to draw the GraphicsPath.
Retornos
Um RectangleF que representa um retângulo que circunda esse GraphicsPath.A RectangleF that represents a rectangle that bounds this GraphicsPath.
Exemplos
Para ver um exemplo, consulte GetBounds().For an example, see GetBounds().
Comentários
O tamanho do retângulo delimitador retornado é influenciado pelo tipo de limites de extremidade, largura da caneta e limite de Mitre da caneta e, portanto, produz um "ajuste flexível" ao caminho limitado.The size of the returned bounding rectangle is influenced by the type of end caps, pen width, and pen miter limit, and therefore produces a "loose fit" to the bounded path. A fórmula aproximada é: o retângulo delimitador inicial é achatado pela largura da caneta e esse resultado é multiplicado pelo limite de Mitre, além de uma margem adicional para permitir extremidades.The approximate formula is: the initial bounding rectangle is inflated by pen width, and this result is multiplied by the miter limit, plus some additional margin to allow for end caps.
Aplica-se a
GetBounds()
Retorna um retângulo que circunda esse GraphicsPath.Returns a rectangle that bounds this GraphicsPath.
public:
System::Drawing::RectangleF GetBounds();
public System.Drawing.RectangleF GetBounds ();
member this.GetBounds : unit -> System.Drawing.RectangleF
Public Function GetBounds () As RectangleF
Retornos
Um RectangleF que representa um retângulo que circunda esse GraphicsPath.A RectangleF that represents a rectangle that bounds this GraphicsPath.
Exemplos
O exemplo de código a seguir foi projetado para uso com Windows Forms, e ele requer PaintEventArgs e um OnPaint objeto de evento.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. O código executa as seguintes ações:The code performs the following actions:
Cria um caminho de gráficos.Creates a graphics path.
Adiciona uma elipse (círculo) a ela e a desenha na tela.Adds an ellipse (circle) to it and draws it to the screen.
Recupera o retângulo delimitador do círculo com uma chamada para GetBounds e desenha o retângulo na tela.Retrieves the bounding rectangle for the circle with a call to GetBounds and draws the rectangle to the screen.
Cria um segundo caminho de gráfico.Creates a second graphics path.
Adiciona um círculo e amplia o caminho para uma largura de 10.Adds a circle and widens the path to a width of 10.
Desenha o caminho para a tela.Draws the path to the screen.
Recupera o retângulo delimitador para o segundo círculo.Retrieves the bounding rectangle for the second circle.
Desenha o retângulo delimitador na tela.Draws the bounding rectangle to the screen.
Exibe o tamanho do retângulo em uma caixa de diálogo.Displays the rectangle size in a dialog box.
Observe que o retângulo delimitador à direita é maior (para considerar a largura extra da linha).Notice that the bounding rectangle on the right is larger (to account for the extra width of the line).
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
Comentários
O tamanho do retângulo delimitador retornado é influenciado pelo tipo de limites de extremidade, largura da caneta e limite de Mitre da caneta e, portanto, produz um "ajuste flexível" ao caminho limitado.The size of the returned bounding rectangle is influenced by the type of end caps, pen width, and pen miter limit, and therefore produces a "loose fit" to the bounded path. A fórmula aproximada é: o retângulo delimitador inicial é achatado pela largura da caneta e esse resultado é multiplicado pelo limite de Mitre, além de uma margem adicional para permitir extremidades.The approximate formula is: the initial bounding rectangle is inflated by pen width, and this result is multiplied by the miter limit, plus some additional margin to allow for end caps.