共用方式為


Region.Intersect 方法

定義

將此 Region 更新為本身與指定之 Region交集。

多載

Intersect(GraphicsPath)

將此 Region 更新為本身與指定之 GraphicsPath交集。

Intersect(Rectangle)

將此 Region 更新為本身與指定之 Rectangle 結構的交集。

Intersect(RectangleF)

將此 Region 更新為本身與指定之 RectangleF 結構的交集。

Intersect(Region)

將此 Region 更新為本身與指定之 Region交集。

Intersect(GraphicsPath)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
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)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
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)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
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 Forms 使用而設計,而且需要 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)

來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
Region.cs
來源:
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) 方法.

適用於