Rectangle.Inflate 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将 Rectangle 结构放大指定量。
重载
Inflate(Size) |
将此 Rectangle 放大指定量。 |
Inflate(Int32, Int32) |
将此 Rectangle 放大指定量。 |
Inflate(Rectangle, Int32, Int32) |
Inflate(Size)
- Source:
- Rectangle.cs
- Source:
- Rectangle.cs
- Source:
- Rectangle.cs
将此 Rectangle 放大指定量。
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)
参数
- size
- Size
此矩形的放大量。
示例
以下示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse
,这是事件处理程序的参数Paint。 该代码创建 ,并在两个 Rectangle 轴上将其放大 50 个单位。 矩形绘制到屏幕之前,膨胀 (黑色) 和通货膨胀 (红色) 。
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
注解
此方法放大此矩形,而不是它的副本。 矩形沿轴向两个方向放大。 例如,如果一个 50 x 50 矩形在 x 轴中放大 50,则生成的矩形长 (原始 50 单位,50 个单位在负方向,加号方向的 50 个单位) 保持矩形的几何中心。
适用于
Inflate(Int32, Int32)
- Source:
- Rectangle.cs
- Source:
- Rectangle.cs
- Source:
- Rectangle.cs
将此 Rectangle 放大指定量。
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)
参数
示例
以下示例创建一个 Rectangle 结构,并在 x 轴方向上将其放大 100 个单位:
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
注解
此方法放大此矩形,而不是它的副本。 矩形沿轴向两个方向放大。 例如,如果一个 50 x 50 矩形在 x 轴中放大 50,则生成的矩形长 (原始 50 单位,50 个单位在负方向,加号方向的 50 个单位) 保持矩形的几何中心。
x
如果 或 y
为负值,则Rectangle结构在相应的方向上放气。
适用于
Inflate(Rectangle, Int32, Int32)
- Source:
- Rectangle.cs
- Source:
- Rectangle.cs
- Source:
- Rectangle.cs
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
参数
返回
放大的 Rectangle。
示例
以下示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse
,这是事件处理程序的参数Paint。 该代码创建 ,并在两个 Rectangle 轴上将其放大 50 个单位。 请注意,生成的矩形 (红色) 两个轴均为 150 个单位。
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
注解
此方法创建 rect
的副本,放大副本,然后返回放大后的副本。 矩形沿轴向两个方向放大。 例如,如果一个 50 x 50 矩形在 x 轴中放大 50,则生成的矩形长 (原始 50 单位,50 个单位在负方向,加号方向的 50 个单位) 保持矩形的几何中心。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈