RectangleF.Inflate 方法

定義

根據指定的數量來放大這個 RectangleF

多載

Inflate(SizeF)

根據指定的數量來放大這個 RectangleF

Inflate(Single, Single)

根據指定的數量,放大這個 RectangleF 結構。

Inflate(RectangleF, Single, Single)

建立並傳回指定之 RectangleF 結構的放大複本。 這個複本會根據指定的數量放大,原始矩形則保留不變。

Inflate(SizeF)

來源:
RectangleF.cs
來源:
RectangleF.cs
來源:
RectangleF.cs

根據指定的數量來放大這個 RectangleF

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)

參數

size
SizeF

要擴大這個矩形的數量。

範例

此範例的設計目的是要與 Windows Forms 搭配使用,而且需要 PaintEventArgs e 是 OnPaint 事件物件。 程式碼會建立 , RectangleF 並將它繪製到黑色的畫面。 請注意,它必須轉換成 Rectangle ,以供繪圖之用。 然後程式碼會 RectangleF 放大 ,再次將它 Rectangle 轉換成 ,並以紅色將它繪製到畫面。 請注意,原始 (黑色) 矩形會沿著 X 軸的兩個方向展開 100 點。

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

備註

這個方法會放大這個矩形,而不是它的複本。 矩形會沿著軸雙向放大。 例如,如果 50 x 50 矩形在 X 軸中由 50 擴充,則結果矩形將會是 150 單位長 (原始的 50、減號方向的 50,以及加號方向的 50,) 維護矩形的幾何中心。

另請參閱

適用於

Inflate(Single, Single)

來源:
RectangleF.cs
來源:
RectangleF.cs
來源:
RectangleF.cs

根據指定的數量,放大這個 RectangleF 結構。

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)

參數

x
Single

要水平擴大這個 RectangleF 結構的數量。

y
Single

要垂直擴大這個 RectangleF 結構的數量。

備註

這個方法會放大這個矩形,而不是它的複本。 矩形會沿著軸雙向放大。 例如,如果 50 x 50 矩形在 X 軸中由 50 擴充,則結果矩形將會是 150 單位長 (原始的 50、減號方向的 50,以及加號方向的 50,) 維護矩形的幾何中心。

x如果 或 y 為負數,則會 RectangleF 以對應的方向取消擴充 。

適用於

Inflate(RectangleF, Single, Single)

來源:
RectangleF.cs
來源:
RectangleF.cs
來源:
RectangleF.cs

建立並傳回指定之 RectangleF 結構的放大複本。 這個複本會根據指定的數量放大,原始矩形則保留不變。

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

參數

rect
RectangleF

要複製的 RectangleF。 這個矩形不會修改。

x
Single

要水平放大矩形複本的數量。

y
Single

要垂直放大矩形複本的數量。

傳回

放大的 RectangleF

備註

這個方法會複製 、放大複本 rect ,然後傳重播大的複本。 矩形會沿著軸雙向放大。 例如,如果 50 x 50 矩形在 X 軸中由 50 擴充,則結果矩形將會是 150 單位長 (原始的 50、減號方向的 50,以及加號方向的 50,) 維護矩形的幾何中心。

適用於