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 更新到其本身與指定之 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 更新到其本身與指定之 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 更新到其本身與指定之 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 更新到其本身與指定之 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) 方法.

適用於