Name
Region
Synopsis
This class is used to define an arbitrary region on a 2D surface.
This is a resource-based entity (unlike the
Rectangle and Point value
types), and therefore requires careful lifetime management. You
should Dispose() the object when you are finished
with it to release the resources back to the system.
At its simplest, you can construct a Region from a
Rectangle or RectangleF. More
complex regions can be constructed from a
System.Drawing.Drawing2D.GraphicsPath. For interop
with the Win32 HRGN, you can use GetHrgn() and
FromHrgn().
You can then manipulate the region in a variety of ways, including
logical operations with another Region,
System.Drawing.Drawing2D.GraphicsPath, or
Rectangle / RectangleF. It can also be made to
represent no area at all with the MakeEmpty()
method, or the whole of the infinite plane with
MakeInfinite(). You can create the
Complement() (the area of the supplied object
that does not intersect with the Region),
Intersect() two regions, create Union() of two regions (the combined areas of both), and
Xor() two regions (which is equivalent to the
Union( )—Intersect()).
You can also provide a Matrix and
Transform() the region, or simply
Translate() it. This is not an ambient
transformation like the ones provided for a Pen or
Graphics surface—it actually manipulates the
underlying System.Drawing.Drawing2D.RegionData.
There is an Equals() method, which determines
whether two Region objects would be equivalent on
a given Graphics surface, and you can ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access