RectangleF.Inflate Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Enlarges this RectangleF by the specified amount.
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. |
- 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
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- 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
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- 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
.NET 9 and other versions
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: