Region.Intersect 方法

定义

将此 Region 更新为自身与指定 Region的交集。

重载

Intersect(GraphicsPath)

将此 Region 更新为自身与指定 GraphicsPath的交集。

Intersect(Rectangle)

将此 Region 更新为自身与指定 Rectangle 结构的交集。

Intersect(RectangleF)

将此 Region 更新为自身与指定 RectangleF 结构的交集。

Intersect(Region)

将此 Region 更新为自身与指定 Region的交集。

Intersect(GraphicsPath)

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

将此 Region 更新为自身与指定 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)

参数

path
GraphicsPath

要与此 Region相交的 GraphicsPath

示例

有关代码示例,请参阅 RectangleF.Intersect(RectangleF)Complement(GraphicsPath) 方法。

适用于

Intersect(Rectangle)

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

将此 Region 更新为自身与指定 Rectangle 结构的交集。

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)

参数

rect
Rectangle

要与此 Region相交的 Rectangle 结构。

示例

有关代码示例,请参阅 Intersect(RectangleF) 方法。

适用于

Intersect(RectangleF)

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

将此 Region 更新为自身与指定 RectangleF 结构的交集。

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

要与此 Region相交的 RectangleF 结构。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建第一个矩形并将其绘制到黑色屏幕。

  • 创建第二个矩形并将其绘制到红色屏幕。

  • 从第一个矩形创建区域。

  • 获取与第二个矩形组合时区域的交集区域。

  • 用蓝色填充交集区域,并将其绘制到屏幕。

请注意,只有区域和矩形的重叠区域为蓝色。

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)

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

将此 Region 更新为自身与指定 Region的交集。

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

参数

region
Region

要与此 Region相交的 Region

示例

有关代码示例,请参阅 Intersect(RectangleF)Complement(GraphicsPath) 方法.

适用于