Rectangle.Inflate 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
根據指定的數量來放大 Rectangle 結構。
多載
Inflate(Size) |
根據指定的數量來放大這個 Rectangle。 |
Inflate(Int32, Int32) |
根據指定的數量來放大這個 Rectangle。 |
Inflate(Rectangle, Int32, Int32) |
建立並傳回指定之 Rectangle 結構的放大複本。 複本會以指定的數量來放大。 原始的 Rectangle 結構則維持不修改。 |
Inflate(Size)
- 來源:
- Rectangle.cs
- 來源:
- Rectangle.cs
- 來源:
- 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 Forms 使用,而且需要 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
備註
這個方法會放大這個矩形,而不是它的複本。 矩形會沿著軸雙向放大。 例如,如果 x 軸中的 50 x 50 矩形放大 50,則結果矩形將會是 150 單位長, (原始的 50、減號方向為 50,而加號方向為 50) 維護矩形幾何中心。
適用於
Inflate(Int32, Int32)
- 來源:
- Rectangle.cs
- 來源:
- Rectangle.cs
- 來源:
- 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
備註
這個方法會放大這個矩形,而不是它的複本。 矩形會沿著軸雙向放大。 例如,如果 x 軸中的 50 x 50 矩形放大 50,則結果矩形將會是 150 單位長, (原始的 50、減號方向為 50,而加號方向為 50) 維護矩形幾何中心。
x
如果 或 y
為負數,結構Rectangle會以對應的方向變大。
適用於
Inflate(Rectangle, Int32, Int32)
- 來源:
- Rectangle.cs
- 來源:
- Rectangle.cs
- 來源:
- 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 Forms 使用,而且需要 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
複本、放大複本,然後傳回放大的複本。 矩形會沿著軸雙向放大。 例如,如果 x 軸中的 50 x 50 矩形放大 50,則結果矩形將會是 150 單位長, (原始的 50、減號方向為 50,而加號方向為 50) 維護矩形幾何中心。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應