Region::Xor Method (RectangleF)
.NET Framework (current version)
Updates this Region to the union minus the intersection of itself with the specified RectangleF structure.
Assembly: System.Drawing (in System.Drawing.dll)
Parameters
- rect
-
Type:
System.Drawing::RectangleF
The RectangleF structure to Xor with this Region.
The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:
Creates the first rectangle and draws it to the screen in black.
Creates a second rectangle and draws it to the screen in red.
Creates a region using the first rectangle.
Gets the Xor area for myRegion when combined with complementRect.
Fills the Xor area with blue and draws it to the screen.
Notice that both rectangles are filled with blue, except for the area of overlap.
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 ); }
.NET Framework
Available since 1.1
Available since 1.1
Show: