RectangleF.Intersect メソッド

定義

2 つの四角形の交差部分を表す RectangleF 構造体を決定します。Determines the RectangleF structure that represents the intersection of two rectangles.

オーバーロード

Intersect(RectangleF, RectangleF)

2 つの四角形の交差部分を表す RectangleF 構造体を返します。Returns a RectangleF structure that represents the intersection of two rectangles. 交差部分がない場合は、空の RectangleF が返されます。If there is no intersection, and empty RectangleF is returned.

Intersect(RectangleF)

この RectangleF 構造体をその構造体と指定の RectangleF 構造体の交差部分に置き換えます。Replaces this RectangleF structure with the intersection of itself and the specified RectangleF structure.

Intersect(RectangleF, RectangleF)

2 つの四角形の交差部分を表す RectangleF 構造体を返します。Returns a RectangleF structure that represents the intersection of two rectangles. 交差部分がない場合は、空の RectangleF が返されます。If there is no intersection, and empty RectangleF is returned.

public:
 static System::Drawing::RectangleF Intersect(System::Drawing::RectangleF a, System::Drawing::RectangleF b);
public static System.Drawing.RectangleF Intersect (System.Drawing.RectangleF a, System.Drawing.RectangleF b);
static member Intersect : System.Drawing.RectangleF * System.Drawing.RectangleF -> System.Drawing.RectangleF
Public Shared Function Intersect (a As RectangleF, b As RectangleF) As RectangleF

パラメーター

a
RectangleF

交差する四角形。A rectangle to intersect.

b
RectangleF

交差する四角形。A rectangle to intersect.

戻り値

指定の 2 つの四角形の重複領域サイズを表す 3 番目の RectangleF 構造体。A third RectangleF structure the size of which represents the overlapped area of the two specified rectangles.

この例は、Windows フォームで使用するために設計さPaintEventArgsれてOnPaintおり、イベントオブジェクトを必要eとします。This example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. このコードではRectangleF 、2つのオブジェクトを作成し、黒と赤で画面に描画します。The code creates two RectangleF objects and draws them to the screen in black and red. 描画用にオブジェクトにRectangle変換する必要があることに注意してください。Notice that they have to be converted to Rectangle objects for drawing purposes. 次に、 Intersectメソッドを使用RectangleFして3番目のを作成Rectangleし、それをに変換して、青で画面に描画します。Then the code creates a third RectangleF using the Intersect method, converts it to a Rectangle, and draws it to the screen in blue. 3番目の (青の) 四角形が、他の2つの四角形の重なりの領域であることに注意してください。Notice the third (blue) rectangle is the area of overlap of the other two rectangles:

public:
   void RectangleFIntersectExample( PaintEventArgs^ e )
   {
      // Create two rectangles.
      RectangleF firstRectangleF = RectangleF(0,0,75,50);
      RectangleF secondRectangleF = RectangleF(50,20,50,50);

      // Convert the RectangleF structures to Rectangle structures and draw them to the
      // screen.
      Rectangle firstRect = Rectangle::Truncate( firstRectangleF );
      Rectangle secondRect = Rectangle::Truncate( secondRectangleF );
      e->Graphics->DrawRectangle( Pens::Black, firstRect );
      e->Graphics->DrawRectangle( Pens::Red, secondRect );

      // Get the intersection.
      RectangleF intersectRectangleF = RectangleF::Intersect( firstRectangleF, secondRectangleF );

      // Draw the intersectRectangleF to the screen.
      Rectangle intersectRect = Rectangle::Truncate( intersectRectangleF );
      e->Graphics->DrawRectangle( Pens::Blue, intersectRect );
   }
public void RectangleFIntersectExample(PaintEventArgs e)
{
             
    // Create two rectangles.
    RectangleF firstRectangleF = new RectangleF(0, 0, 75, 50);
    RectangleF secondRectangleF = new RectangleF(50, 20, 50, 50);
             
    // Convert the RectangleF structures to Rectangle structures and draw them to the
             
    // screen.
    Rectangle firstRect = Rectangle.Truncate(firstRectangleF);
    Rectangle secondRect = Rectangle.Truncate(secondRectangleF);
    e.Graphics.DrawRectangle(Pens.Black, firstRect);
    e.Graphics.DrawRectangle(Pens.Red, secondRect);
             
    // Get the intersection.
    RectangleF intersectRectangleF =
        RectangleF.Intersect(firstRectangleF,
        secondRectangleF);
             
    // Draw the intersectRectangleF to the screen.
    Rectangle intersectRect =
        Rectangle.Truncate(intersectRectangleF);
    e.Graphics.DrawRectangle(Pens.Blue, intersectRect);
}
Public Sub RectangleFIntersectExample(ByVal e As PaintEventArgs)

    ' Create two rectangles.
    Dim firstRectangleF As New RectangleF(0, 0, 75, 50)
    Dim secondRectangleF As New RectangleF(50, 20, 50, 50)

    ' Convert the RectangleF structures to Rectangle structures and

    ' draw them to the screen.
    Dim firstRect As Rectangle = Rectangle.Truncate(firstRectangleF)
    Dim secondRect As Rectangle = Rectangle.Truncate(secondRectangleF)
    e.Graphics.DrawRectangle(Pens.Black, firstRect)
    e.Graphics.DrawRectangle(Pens.Red, secondRect)

    ' Get the intersection.
    Dim intersectRectangleF As RectangleF = _
    RectangleF.Intersect(firstRectangleF, secondRectangleF)

    ' Draw the intersectRectangleF to the screen.
    Dim intersectRect As Rectangle = _
    Rectangle.Truncate(intersectRectangleF)
    e.Graphics.DrawRectangle(Pens.Blue, intersectRect)
End Sub

Intersect(RectangleF)

この RectangleF 構造体をその構造体と指定の RectangleF 構造体の交差部分に置き換えます。Replaces this RectangleF structure with the intersection of itself and the specified RectangleF structure.

public:
 void Intersect(System::Drawing::RectangleF rect);
public void Intersect (System.Drawing.RectangleF rect);
member this.Intersect : System.Drawing.RectangleF -> unit
Public Sub Intersect (rect As RectangleF)

パラメーター

rect
RectangleF

交差する四角形。The rectangle to intersect.

適用対象