Region.Xor 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将此 Region 对象更新为其自身与指定 GraphicsPath 对象的并集减去这两者的交集。
重载
Xor(GraphicsPath) |
将此 Region 更新为其自身与指定 GraphicsPath 的并集减去这两者的交集。 |
Xor(Rectangle) | |
Xor(RectangleF) |
将此 Region 更新为其自身与指定 RectangleF 结构的并集减去这两者的交集。 |
Xor(Region) |
Xor(GraphicsPath)
- Source:
- Region.cs
- Source:
- Region.cs
- Source:
- 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
要与此 GraphicsPath 进行 Xor 的 Region。
例外
path
为 null
。
示例
有关代码示例,请参阅 Xor(RectangleF) 和 Complement(GraphicsPath) 方法。
适用于
Xor(Rectangle)
- Source:
- Region.cs
- Source:
- Region.cs
- Source:
- Region.cs
public:
void Xor(System::Drawing::Rectangle rect);
public void Xor (System.Drawing.Rectangle rect);
member this.Xor : System.Drawing.Rectangle -> unit
Public Sub Xor (rect As Rectangle)
参数
示例
有关代码示例,请参阅 Xor(RectangleF) 方法。
适用于
Xor(RectangleF)
- Source:
- Region.cs
- Source:
- Region.cs
- Source:
- 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
要与此 RectangleF 进行 Xor(GraphicsPath) 的 Region 结构。
示例
下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse
,这是事件处理程序的参数Paint。 此代码执行以下操作:
创建第一个矩形并将其绘制到黑色屏幕。
创建第二个矩形,并将其绘制到红色屏幕。
使用第一个矩形创建区域。
Xor获取与
complementRect
组合时的区域myRegion
。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)
- Source:
- Region.cs
- Source:
- Region.cs
- Source:
- 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) 方法。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈