次の方法で共有


RectangleF.Inflate メソッド (SizeF)

この RectangleF を指定の量だけ膨らませます。

Overloads Public Sub Inflate( _
   ByVal size As SizeF _)
[C#]
public void Inflate(SizeFsize);
[C++]
public: void Inflate(SizeFsize);
[JScript]
public function Inflate(
   size : SizeF);

パラメータ

  • size
    この四角形の膨張量。

戻り値

このメソッドは値を返しません。

使用例

[Visual Basic, C#] この例は、Windows フォームでの使用を意図してデザインされており、OnPaint のイベント オブジェクトである PaintEventArgs e が必要です。このコードでは、 RectangleF を作成し、画面に黒で描画します。描画するには Rectangle に変換する必要があります。そのため、このコードでは、 RectangleF を膨らませ、再度 Rectangle に変換したのち画面に赤で描画します。元の (黒の) 四角形は x 軸の両方向に 100 ポイントずつ拡張されます。

 
Public Sub RectangleFInflateExample(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
        
[C#] 
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);
}
        

このメソッドは、コピーではなくこの四角形を膨らませます。軸に沿った膨張には、2 つの方向 (マイナスの方向とプラスの方向) があります。たとえば、50 × 50 の四角形を x 軸方向に 50 膨らませると、長さが 150 単位 (元の 50、負の方向に 50、正の方向に 50) の四角形になります。四角形の幾何学中心は元のままです。

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

RectangleF 構造体 | RectangleF メンバ | System.Drawing 名前空間 | RectangleF.Inflate オーバーロードの一覧