Partilhar via


Rectangle.Inflate Método

Definição

Amplia uma estrutura de Rectangle pela quantidade especificada.

Sobrecargas

Inflate(Size)

Amplia esse Rectangle pelo valor especificado.

Inflate(Int32, Int32)

Amplia esse Rectangle pelo valor especificado.

Inflate(Rectangle, Int32, Int32)

Cria e retorna uma cópia ampliada da estrutura de Rectangle especificada. A cópia é ampliada pela quantidade especificada. A estrutura de Rectangle original permanece não modificada.

Inflate(Size)

Origem:
Rectangle.cs
Origem:
Rectangle.cs
Origem:
Rectangle.cs

Amplia esse Rectangle pelo valor especificado.

public:
 void Inflate(System::Drawing::Size size);
public void Inflate (System.Drawing.Size size);
member this.Inflate : System.Drawing.Size -> unit
Public Sub Inflate (size As Size)

Parâmetros

size
Size

A quantidade para inflar esse retângulo.

Exemplos

O exemplo a seguir foi projetado para uso com o Windows Forms e requer PaintEventArgse, que é um parâmetro do manipulador de eventos Paint. O código cria um Rectangle e o amplia em 50 unidades em ambos os eixos. O retângulo é desenhado para tela antes da inflação (preto) e após a inflação (vermelho).

public:
   void RectangleInflateTest2( PaintEventArgs^ e )
   {
      // Create a rectangle.
      Rectangle rect = Rectangle(100,100,50,50);

      // Draw the uninflated rectangle to screen.
      e->Graphics->DrawRectangle( Pens::Black, rect );

      // Set up the inflate size.
      System::Drawing::Size inflateSize = System::Drawing::Size( 50, 50 );

      // Call Inflate.
      rect.Inflate( inflateSize );

      // Draw the inflated rectangle to screen.
      e->Graphics->DrawRectangle( Pens::Red, rect );
   }
public void RectangleInflateTest2(PaintEventArgs e)
{
             
    // Create a rectangle.
    Rectangle rect = new Rectangle(100, 100, 50, 50);
             
    // Draw the uninflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Black, rect);
             
    // Set up the inflate size.
    Size inflateSize = new Size(50, 50);
             
    // Call Inflate.
    rect.Inflate(inflateSize);
             
    // Draw the inflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Red, rect);
}
Public Sub RectangleInflateTest2(ByVal e As PaintEventArgs)

    ' Create a rectangle.
    Dim rect As New Rectangle(100, 100, 50, 50)

    ' Draw the uninflated rect to screen.
    e.Graphics.DrawRectangle(Pens.Black, rect)

    ' Set up the inflate size.
    Dim inflateSize As New Size(50, 50)

    ' Call Inflate.
    rect.Inflate(inflateSize)

    ' Draw the inflated rect to screen.
    e.Graphics.DrawRectangle(Pens.Red, rect)
End Sub

Comentários

Esse método amplia esse retângulo, não uma cópia dele. O retângulo é ampliado em ambas as direções ao longo de um eixo. Por exemplo, se um retângulo de 50 por 50 for ampliado em 50 no eixo x, o retângulo resultante terá 150 unidades de comprimento (os 50 originais, os 50 na direção de menos e os 50 na direção de adição) mantendo o centro geométrico do retângulo.

Aplica-se a

Inflate(Int32, Int32)

Origem:
Rectangle.cs
Origem:
Rectangle.cs
Origem:
Rectangle.cs

Amplia esse Rectangle pelo valor especificado.

public:
 void Inflate(int width, int height);
public void Inflate (int width, int height);
member this.Inflate : int * int -> unit
Public Sub Inflate (width As Integer, height As Integer)

Parâmetros

width
Int32

O valor para inflar esse Rectangle horizontalmente.

height
Int32

O valor para inflar esse Rectangle verticalmente.

Exemplos

O exemplo a seguir cria uma estrutura Rectangle e a amplia em 100 unidades na direção do eixo x:

public:
   void RectangleInflateTest3( PaintEventArgs^ e )
   {
      // Create a rectangle.
      Rectangle rect = Rectangle(100,100,50,50);

      // Draw the uninflated rectangle to screen.
      e->Graphics->DrawRectangle( Pens::Black, rect );

      // Call Inflate.
      rect.Inflate( 50, 50 );

      // Draw the inflated rectangle to screen.
      e->Graphics->DrawRectangle( Pens::Red, rect );
   }
public void RectangleInflateTest3(PaintEventArgs e)
{
             
    // Create a rectangle.
    Rectangle rect = new Rectangle(100, 100, 50, 50);
             
    // Draw the uninflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Black, rect);
             
    // Call Inflate.
    rect.Inflate(50, 50);
             
    // Draw the inflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Red, rect);
}
Public Sub RectangleInflateTest3(ByVal e As PaintEventArgs)

    ' Create a rectangle.
    Dim rect As New Rectangle(100, 100, 50, 50)

    ' Draw the uninflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Black, rect)

    ' Call Inflate.
    rect.Inflate(50, 50)

    ' Draw the inflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Red, rect)
End Sub

Comentários

Esse método amplia esse retângulo, não uma cópia dele. O retângulo é ampliado em ambas as direções ao longo de um eixo. Por exemplo, se um retângulo de 50 por 50 for ampliado em 50 no eixo x, o retângulo resultante terá 150 unidades de comprimento (os 50 originais, os 50 na direção de menos e os 50 na direção de adição) mantendo o centro geométrico do retângulo.

Se x ou y for negativo, a estrutura Rectangle será esvaziada na direção correspondente.

Aplica-se a

Inflate(Rectangle, Int32, Int32)

Origem:
Rectangle.cs
Origem:
Rectangle.cs
Origem:
Rectangle.cs

Cria e retorna uma cópia ampliada da estrutura de Rectangle especificada. A cópia é ampliada pela quantidade especificada. A estrutura de Rectangle original permanece não modificada.

public:
 static System::Drawing::Rectangle Inflate(System::Drawing::Rectangle rect, int x, int y);
public static System.Drawing.Rectangle Inflate (System.Drawing.Rectangle rect, int x, int y);
static member Inflate : System.Drawing.Rectangle * int * int -> System.Drawing.Rectangle
Public Shared Function Inflate (rect As Rectangle, x As Integer, y As Integer) As Rectangle

Parâmetros

rect
Rectangle

O Rectangle com o qual começar. Este retângulo não foi modificado.

x
Int32

O valor para inflar esse Rectangle horizontalmente.

y
Int32

O valor para inflar esse Rectangle verticalmente.

Retornos

O Rectangleampliado.

Exemplos

O exemplo a seguir foi projetado para uso com o Windows Forms e requer PaintEventArgse, que é um parâmetro do manipulador de eventos Paint. O código cria um Rectangle e o amplia em 50 unidades em ambos os eixos. Observe que o retângulo resultante (vermelho) é de 150 unidades em ambos os eixos.

public:
   void RectangleInflateTest( PaintEventArgs^ e )
   {
      // Create a rectangle.
      Rectangle rect = Rectangle(100,100,50,50);

      // Draw the uninflated rectangle to screen.
      e->Graphics->DrawRectangle( Pens::Black, rect );

      // Call Inflate.
      Rectangle rect2 = Rectangle::Inflate( rect, 50, 50 );

      // Draw the inflated rectangle to screen.
      e->Graphics->DrawRectangle( Pens::Red, rect2 );
   }
public void RectangleInflateTest(PaintEventArgs e)
{
             
    // Create a rectangle.
    Rectangle rect = new Rectangle(100, 100, 50, 50);
             
    // Draw the uninflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Black, rect);
             
    // Call Inflate.
    Rectangle rect2 = Rectangle.Inflate(rect, 50, 50);
             
    // Draw the inflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Red, rect2);
}
Public Sub RectangleInflateTest(ByVal e As PaintEventArgs)

    ' Create a rectangle.
    Dim rect As New Rectangle(100, 100, 50, 50)

    ' Draw the uninflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Black, rect)

    ' Call Inflate.
    Dim rect2 As Rectangle = Rectangle.Inflate(rect, 50, 50)

    ' Draw the inflated rectangle to screen.
    e.Graphics.DrawRectangle(Pens.Red, rect2)
End Sub

Comentários

Esse método faz uma cópia de rect, amplia a cópia e retorna a cópia ampliada. O retângulo é ampliado em ambas as direções ao longo de um eixo. Por exemplo, se um retângulo de 50 por 50 for ampliado em 50 no eixo x, o retângulo resultante terá 150 unidades de comprimento (os 50 originais, os 50 na direção de menos e os 50 na direção de adição) mantendo o centro geométrico do retângulo.

Aplica-se a