Region.Xor 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將此 Region 物件更新為等位,減去本身與指定之 GraphicsPath 物件的交集。
多載
Xor(GraphicsPath) |
將此 Region 更新為等位減去本身與指定之 GraphicsPath的交集。 |
Xor(Rectangle) | |
Xor(RectangleF) |
將此 Region 更新為聯集減去本身與指定之 RectangleF 結構的交集。 |
Xor(Region) |
Xor(GraphicsPath)
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
將此 Region 更新為等位減去本身與指定之 GraphicsPath的交集。
public:
void Xor(System::Drawing::Drawing2D::GraphicsPath ^ path);
public void Xor (System.Drawing.Drawing2D.GraphicsPath path);
member this.Xor : System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub Xor (path As GraphicsPath)
參數
- path
- GraphicsPath
要使用此 RegionXor 的 GraphicsPath。
例外狀況
path
null
。
範例
如需程式代碼範例,請參閱 Xor(RectangleF) 和 Complement(GraphicsPath) 方法。
適用於
Xor(Rectangle)
Xor(RectangleF)
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
將此 Region 更新為聯集減去本身與指定之 RectangleF 結構的交集。
public:
void Xor(System::Drawing::RectangleF rect);
public void Xor (System.Drawing.RectangleF rect);
member this.Xor : System.Drawing.RectangleF -> unit
Public Sub Xor (rect As RectangleF)
參數
- rect
- RectangleF
範例
下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse
,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:
建立第一個矩形,並將它繪製到黑色的畫面。
建立第二個矩形,並以紅色將它繪製到畫面。
使用第一個矩形建立區域。
當與
complementRect
結合時,取得myRegion
Xor 區域。以藍色填滿 Xor 區域,並將其繪製到螢幕。
請注意,這兩個矩形會填滿藍色,但重疊的區域除外。
void XorExample( 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 xorRect = RectangleF(90,30,100,100);
e->Graphics->DrawRectangle( Pens::Red, Rectangle::Round( xorRect ) );
// Create a region using the first rectangle.
System::Drawing::Region^ myRegion = gcnew System::Drawing::Region( regionRect );
// Get the area of overlap for myRegion when combined with
// complementRect.
myRegion->Xor( xorRect );
// Fill the Xor area of myRegion with blue.
SolidBrush^ myBrush = gcnew SolidBrush( Color::Blue );
e->Graphics->FillRegion( myBrush, myRegion );
}
public void XorExample(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 xorRect = new RectangleF(90, 30, 100, 100);
e.Graphics.DrawRectangle(Pens.Red,
Rectangle.Round(xorRect));
// Create a region using the first rectangle.
Region myRegion = new Region(regionRect);
// Get the area of overlap for myRegion when combined with
// complementRect.
myRegion.Xor(xorRect);
// Fill the Xor area of myRegion with blue.
SolidBrush myBrush = new SolidBrush(Color.Blue);
e.Graphics.FillRegion(myBrush, myRegion);
}
Public Sub XorExample(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 xorRect As New RectangleF(90, 30, 100, 100)
e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(xorRect))
' Create a region using the first rectangle.
Dim myRegion As New [Region](regionRect)
' Get the area of overlap for myRegion when combined with
' complementRect.
myRegion.Xor(xorRect)
' Fill the intersection area of myRegion with blue.
Dim myBrush As New SolidBrush(Color.Blue)
e.Graphics.FillRegion(myBrush, myRegion)
End Sub
適用於
Xor(Region)
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
- 來源:
- Region.cs
public:
void Xor(System::Drawing::Region ^ region);
public void Xor (System.Drawing.Region region);
member this.Xor : System.Drawing.Region -> unit
Public Sub Xor (region As Region)
參數
例外狀況
region
null
。
範例
如需程式代碼範例,請參閱 Xor(RectangleF) 和 Complement(GraphicsPath) 方法。