Rectangle.Inflate

C# Rectangle.Inflate 方法将Rectangle 结构放大指定量

 

命名空间:System.Drawing
程序集:System.Drawing(在 system.drawing.dll 中)

重载列表

Rectangle.Inflate (Size)                           将此 Rectangle放大指定量。

Rectangle.Inflate (Int32, Int32)                将此 Rectangle放大指定量。

Rectangle.Inflate (Rectangle, Int32, Int32) 创建并返回指定 Rectangle结构的放大副本。该副本被放大指定的量。不修改原始 Rectangle结构。

应用:Rectangle.Inflate (Int32, Int32)

参数
width

Rectangle的水平放大量。

height

Rectangle的垂直放大量。

备注

此方法放大此矩形,而不是放大它的副本。沿轴放大是沿两个方向(正方向和负方向)进行的。例如,如果 50 x 50 的矩形沿 x 轴放大 50,则结果矩形的长度为 150 个单位,即原始 50,负方向 50,正方向 50,以保持矩形的几何中心不变。

如果 x 或 y 为负数,则 Rectangle结构沿着相应的方向缩小。

示例1:下面的示例创建一个 Rectangle结构,并沿 x ,y轴方向将其放大 100 个单位:

           // Create a rectangle.
           Rectangle rect = new Rectangle(100, 100, 50, 50);
           Graphics g = CreateGraphics();
           // Draw the uninflated rectangle to screen.
           g.DrawRectangle(Pens.Black, rect);

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

           // Draw the inflated rectangle to screen.
           g.DrawRectangle(Pens.Red, rect);

示例2:下面的示例创建一个 Rectangle结构,并沿 x 轴方向将其缩小 10 个单位,沿 y 轴方向将其放大 10 个单位:

          // Create a rectangle.
           Rectangle rect = new Rectangle(100, 100, 50, 50);
           Graphics g = CreateGraphics();
           // Draw the uninflated rectangle to screen.
           g.DrawRectangle(Pens.Black, rect);

           // Call Inflate.
           rect.Inflate(-10, 10);

           // Draw the inflated rectangle to screen.
           g.DrawRectangle(Pens.Red, rect);

posted @ 2013-05-10 09:56  老高dotnet实践  阅读(823)  评论(0编辑  收藏  举报