Редагувати

Поділитися через


RectangleF.Inflate Method

Definition

Enlarges this RectangleF by the specified amount.

Overloads

Inflate(SizeF)

Enlarges this RectangleF by the specified amount.

Inflate(Single, Single)

Enlarges this RectangleF structure by the specified amount.

Inflate(RectangleF, Single, Single)

Creates and returns an enlarged copy of the specified RectangleF structure. The copy is enlarged by the specified amount and the original rectangle remains unmodified.

Inflate(SizeF)

Source:
RectangleF.cs
Source:
RectangleF.cs
Source:
RectangleF.cs

Enlarges this RectangleF by the specified amount.

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

Parameters

size
SizeF

The amount to inflate this rectangle.

Examples

This example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code creates a RectangleF and draws it to the screen in black. Notice that it has to be converted to a Rectangle for drawing purposes. Then the code enlarges the RectangleF, again converts it to a Rectangle, and draws it to the screen in red. Notice that the original (black) rectangle is expanded in both directions along the x-axis by 100 points.

public:
   void RectangleFInflateExample( PaintEventArgs^ e )
   {
      // Create a RectangleF structure.
      RectangleF myRectF = RectangleF(100,20,100,100);

      // Draw myRect to the screen.
      Rectangle myRect = Rectangle::Truncate( myRectF );
      e->Graphics->DrawRectangle( Pens::Black, myRect );

      // Create a Size structure.
      SizeF inflateSize = SizeF(100,0);

      // Inflate myRect.
      myRectF.Inflate( inflateSize );

      // Draw the inflated rectangle to the screen.
      myRect = Rectangle::Truncate( myRectF );
      e->Graphics->DrawRectangle( Pens::Red, myRect );
   }
public void RectangleFInflateExample(PaintEventArgs e)
{
             
    // Create a RectangleF structure.
    RectangleF myRectF = new RectangleF(100, 20, 100, 100);
             
    // Draw myRect to the screen.
    Rectangle myRect = Rectangle.Truncate(myRectF);
    e.Graphics.DrawRectangle(Pens.Black, myRect);
             
    // Create a Size structure.
    SizeF inflateSize = new SizeF(100, 0);
             
    // Inflate myRect.
    myRectF.Inflate(inflateSize);
             
    // Draw the inflated rectangle to the screen.
    myRect = Rectangle.Truncate(myRectF);
    e.Graphics.DrawRectangle(Pens.Red, myRect);
}
Public Sub RectangleFInflateExample(ByVal e As PaintEventArgs)

    ' Create a RectangleF structure.
    Dim myRectF As New RectangleF(100, 20, 100, 100)

    ' Draw myRect to the screen.
    Dim myRect As Rectangle = Rectangle.Truncate(myRectF)
    e.Graphics.DrawRectangle(Pens.Black, myRect)

    ' Create a Size structure.
    Dim inflateSize As New SizeF(100, 0)

    ' Inflate myRect.
    myRectF.Inflate(inflateSize)

    ' Draw the inflated rectangle to the screen.
    myRect = Rectangle.Truncate(myRectF)
    e.Graphics.DrawRectangle(Pens.Red, myRect)
End Sub

Remarks

This method enlarges this rectangle, not a copy of it. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is inflated by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center.

See also

Applies to

Inflate(Single, Single)

Source:
RectangleF.cs
Source:
RectangleF.cs
Source:
RectangleF.cs

Enlarges this RectangleF structure by the specified amount.

public:
 void Inflate(float x, float y);
public void Inflate (float x, float y);
member this.Inflate : single * single -> unit
Public Sub Inflate (x As Single, y As Single)

Parameters

x
Single

The amount to inflate this RectangleF structure horizontally.

y
Single

The amount to inflate this RectangleF structure vertically.

Remarks

This method enlarges this rectangle, not a copy of it. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is inflated by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center.

If either x or y is negative, the RectangleF is deflated in the corresponding direction.

Applies to

Inflate(RectangleF, Single, Single)

Source:
RectangleF.cs
Source:
RectangleF.cs
Source:
RectangleF.cs

Creates and returns an enlarged copy of the specified RectangleF structure. The copy is enlarged by the specified amount and the original rectangle remains unmodified.

public:
 static System::Drawing::RectangleF Inflate(System::Drawing::RectangleF rect, float x, float y);
public static System.Drawing.RectangleF Inflate (System.Drawing.RectangleF rect, float x, float y);
static member Inflate : System.Drawing.RectangleF * single * single -> System.Drawing.RectangleF
Public Shared Function Inflate (rect As RectangleF, x As Single, y As Single) As RectangleF

Parameters

rect
RectangleF

The RectangleF to be copied. This rectangle is not modified.

x
Single

The amount to enlarge the copy of the rectangle horizontally.

y
Single

The amount to enlarge the copy of the rectangle vertically.

Returns

The enlarged RectangleF.

Remarks

This method makes a copy of rect, enlarges the copy, and then returns the enlarged copy. The rectangle is enlarged in both directions along an axis. For example, if a 50 by 50 rectangle is inflated by 50 in the x-axis, the resultant rectangle will be 150 units long (the original 50, the 50 in the minus direction, and the 50 in the plus direction) maintaining the rectangle's geometric center.

Applies to