Region.Intersect Method

Definition

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

Overloads

Intersect(GraphicsPath)

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

Intersect(Rectangle)

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

Intersect(RectangleF)

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

Intersect(Region)

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

Intersect(GraphicsPath)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

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

C#
public void Intersect(System.Drawing.Drawing2D.GraphicsPath path);

Parameters

path
GraphicsPath

The GraphicsPath to intersect with this Region.

Examples

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

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Intersect(Rectangle)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

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

C#
public void Intersect(System.Drawing.Rectangle rect);

Parameters

rect
Rectangle

The Rectangle structure to intersect with this Region.

Examples

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

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Intersect(RectangleF)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

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

C#
public void Intersect(System.Drawing.RectangleF rect);

Parameters

rect
RectangleF

The RectangleF structure to intersect with this Region.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, 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.

C#
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);
}

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Intersect(Region)

Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs
Source:
Region.cs

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

C#
public void Intersect(System.Drawing.Region region);

Parameters

region
Region

The Region to intersect with this Region.

Examples

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

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10