Region.Intersect Region.Intersect Region.Intersect Region.Intersect Method

Definition

Updates this Region to the intersection of itself with the specified Region.

Overloads

Intersect(GraphicsPath) Intersect(GraphicsPath) Intersect(GraphicsPath) Intersect(GraphicsPath)

Updates this Region to the intersection of itself with the specified GraphicsPath.

Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle)

Updates this Region to the intersection of itself with the specified Rectangle structure.

Intersect(RectangleF) Intersect(RectangleF) Intersect(RectangleF) Intersect(RectangleF)

Updates this Region to the intersection of itself with the specified RectangleF structure.

Intersect(Region) Intersect(Region) Intersect(Region)

Updates this Region to the intersection of itself with the specified Region.

Intersect(GraphicsPath) Intersect(GraphicsPath) Intersect(GraphicsPath) Intersect(GraphicsPath)

Updates this Region to the intersection of itself with the specified GraphicsPath.

public:
 void Intersect(System::Drawing::Drawing2D::GraphicsPath ^ path);
public void Intersect (System.Drawing.Drawing2D.GraphicsPath path);
member this.Intersect : System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub Intersect (path As GraphicsPath)

Parameters

Examples

For code examples, see the RectangleF.Intersect(RectangleF) and Complement(GraphicsPath) methods.

Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle) Intersect(Rectangle)

Updates this Region to the intersection of itself with the specified Rectangle structure.

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

Parameters

rect
Rectangle Rectangle Rectangle Rectangle

The Rectangle structure to intersect with this Region.

Examples

For a code example, see the Intersect(RectangleF) method.

Intersect(RectangleF) Intersect(RectangleF) Intersect(RectangleF) Intersect(RectangleF)

Updates this Region to the intersection of itself with 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)

Parameters

rect
RectangleF RectangleF RectangleF RectangleF

The RectangleF structure to intersect with this Region.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates the first rectangle and draws it to the screen in black.

  • Creates the second rectangle and draws it to the screen in red.

  • Creates a region from the first rectangle.

  • Gets the area of intersection for the region when combined with the second rectangle.

  • Fills the area of intersection with blue and draws it to the screen.

Notice that only the overlapped area for the region and rectangle is blue.

public:
   void Intersect_RectF_Example( PaintEventArgs^ e )
   {
      // Create the first rectangle and draw it to the screen in black.
      Rectangle regionRect = Rectangle(20,20,100,100);
      e->Graphics->DrawRectangle( Pens::Black, regionRect );

      // create the second rectangle and draw it to the screen in red.
      RectangleF complementRect = RectangleF(90,30,100,100);
      e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( complementRect ) );

      // Create a region using the first rectangle.
      System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );

      // Get the area of intersection for myRegion when combined with
      // complementRect.
      myRegion->Intersect( complementRect );

      // Fill the intersection area of myRegion with blue.
      SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
      e->Graphics->FillRegion( myBrush, myRegion );
   }
public void Intersect_RectF_Example(PaintEventArgs e)
{
             
    // Create the first rectangle and draw it to the screen in black.
    Rectangle regionRect = new Rectangle(20, 20, 100, 100);
    e.Graphics.DrawRectangle(Pens.Black, regionRect);
             
    // create the second rectangle and draw it to the screen in red.
    RectangleF complementRect = new RectangleF(90, 30, 100, 100);
    e.Graphics.DrawRectangle(Pens.Red,
        Rectangle.Round(complementRect));
             
    // Create a region using the first rectangle.
    Region myRegion = new Region(regionRect);
             
    // Get the area of intersection for myRegion when combined with
             
    // complementRect.
    myRegion.Intersect(complementRect);
             
    // Fill the intersection area of myRegion with blue.
    SolidBrush myBrush = new SolidBrush(Color.Blue);
    e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub Intersect_RectF_Example(ByVal e As PaintEventArgs)

    ' Create the first rectangle and draw it to the screen in black.
    Dim regionRect As New Rectangle(20, 20, 100, 100)
    e.Graphics.DrawRectangle(Pens.Black, regionRect)

    ' create the second rectangle and draw it to the screen in red.
    Dim complementRect As New RectangleF(90, 30, 100, 100)
    e.Graphics.DrawRectangle(Pens.Red, _
    Rectangle.Round(complementRect))

    ' Create a region using the first rectangle.
    Dim myRegion As New [Region](regionRect)

    ' Get the area of intersection for myRegion when combined with
    ' complementRect.
    myRegion.Intersect(complementRect)

    ' Fill the intersection area of myRegion with blue.
    Dim myBrush As New SolidBrush(Color.Blue)
    e.Graphics.FillRegion(myBrush, myRegion)
End Sub

Intersect(Region) Intersect(Region) Intersect(Region)

Updates this Region to the intersection of itself with the specified Region.

public:
 void Intersect(System::Drawing::Region ^ region);
public void Intersect (System.Drawing.Region region);
member this.Intersect : System.Drawing.Region -> unit

Parameters

region
Region Region Region Region

The Region to intersect with this Region.

Examples

For code examples, see the Intersect(RectangleF) and Complement(GraphicsPath) method.

Applies to