Region.Intersect 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
Intersect(GraphicsPath) |
將此 Region 更新到其本身與指定之 GraphicsPath 的交集。 |
Intersect(Rectangle) | |
Intersect(RectangleF) |
將此 Region 更新到其本身與指定之 RectangleF 結構的交集。 |
Intersect(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
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)
參數
範例
如需程式代碼範例,請參閱 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
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)
參數
範例
如需程式代碼範例,請參閱 Intersect(RectangleF) 和 Complement(GraphicsPath) 方法.
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應