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);

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值