Rectangle コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した位置とサイズで、Rectangle クラスの新しいインスタンスを初期化します。
オーバーロード
Rectangle(Point, Size) |
指定した位置とサイズで、Rectangle クラスの新しいインスタンスを初期化します。 |
Rectangle(Int32, Int32, Int32, Int32) |
指定した位置とサイズで、Rectangle クラスの新しいインスタンスを初期化します。 |
Rectangle(Point, Size)
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
指定した位置とサイズで、Rectangle クラスの新しいインスタンスを初期化します。
public:
Rectangle(System::Drawing::Point ___location, System::Drawing::Size size);
public Rectangle (System.Drawing.Point ___location, System.Drawing.Size size);
new System.Drawing.Rectangle : System.Drawing.Point * System.Drawing.Size -> System.Drawing.Rectangle
Public Sub New (___location As Point, size As Size)
パラメーター
適用対象
Rectangle(Int32, Int32, Int32, Int32)
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
- ソース:
- Rectangle.cs
指定した位置とサイズで、Rectangle クラスの新しいインスタンスを初期化します。
public:
Rectangle(int x, int y, int width, int height);
public Rectangle (int x, int y, int width, int height);
new System.Drawing.Rectangle : int * int * int * int -> System.Drawing.Rectangle
Public Sub New (x As Integer, y As Integer, width As Integer, height As Integer)
パラメーター
- x
- Int32
四角形の左上隅の x 座標。
- y
- Int32
四角形の左上隅の y 座標。
- width
- Int32
四角形の幅。
- height
- Int32
四角形の高さ。
例
次のコード例は、、Intersect、IsEmpty、および の各メンバーをRectangleIntersectsWith示しています。 この例は、Windows フォームで使用する必要があります。 フォームにこのコードを貼り付け、フォームのPaintイベントを処理するときに このメソッドを呼び出し、 を としてPaintEventArgs渡しますe
。
private:
void InstanceRectangleIntersection( PaintEventArgs^ e )
{
Rectangle rectangle1 = Rectangle(50,50,200,100);
Rectangle rectangle2 = Rectangle(70,20,100,200);
e->Graphics->DrawRectangle( Pens::Black, rectangle1 );
e->Graphics->DrawRectangle( Pens::Red, rectangle2 );
if ( rectangle1.IntersectsWith( rectangle2 ) )
{
rectangle1.Intersect( rectangle2 );
if ( !rectangle1.IsEmpty )
{
e->Graphics->FillRectangle( Brushes::Green, rectangle1 );
}
}
}
private void InstanceRectangleIntersection(PaintEventArgs e)
{
Rectangle rectangle1 = new Rectangle(50, 50, 200, 100);
Rectangle rectangle2 = new Rectangle(70, 20, 100, 200);
e.Graphics.DrawRectangle(Pens.Black, rectangle1);
e.Graphics.DrawRectangle(Pens.Red, rectangle2);
if (rectangle1.IntersectsWith(rectangle2))
{
rectangle1.Intersect(rectangle2);
if (!rectangle1.IsEmpty)
{
e.Graphics.FillRectangle(Brushes.Green, rectangle1);
}
}
}
Private Sub InstanceRectangleIntersection( _
ByVal e As PaintEventArgs)
Dim rectangle1 As New Rectangle(50, 50, 200, 100)
Dim rectangle2 As New Rectangle(70, 20, 100, 200)
e.Graphics.DrawRectangle(Pens.Black, rectangle1)
e.Graphics.DrawRectangle(Pens.Red, rectangle2)
If (rectangle1.IntersectsWith(rectangle2)) Then
rectangle1.Intersect(rectangle2)
If Not (rectangle1.IsEmpty) Then
e.Graphics.FillRectangle(Brushes.Green, rectangle1)
End If
End If
End Sub