A region is a portion of the display area of an output device. You can construct a region from a rectangle or a path. You can also create complex regions by combining existing regions.
The following illustration shows two regions: one constructed from a rectangle, and the other constructed from an ellipse.
The Region class provides the following methods for combining regions: Intersect , Union , Xor , Exclude , and Complement.
The intersection of two regions is the set of all points belonging to both regions. The following illustration shows the intersection (violet color).
The following code example shows how to draw the intersection of two regions:
The union is the set of all points belonging to one or the other or both regions. The following illustration shows the union.
The following code example demonstrates how to draw the union of two regions:
The complement of a region is the set of all points that are not in the region. The following illustration shows the complement (violet color).
The following code example demonstrates how to draw the complement of a region:
Xor is a process to produce a region that contains all points that belong to one region or the other, but not both. The following illustration show the Xor region (violet color).
The following code example demonstrates how to draw the Xor of region:
Exclude is a process to produces a region that contains all points in the first region that are not in the second region. The following illustration shows the exclude region (violet color).
The following code example demonstrates how to exclude a region: