Class Region
- Namespace
- SixLabors.ImageSharp.Drawing
- Assembly
- SixLabors.ImageSharp.Drawing.dll
Represents an integer region composed from axis-aligned rectangles.
public sealed class Region
- Inheritance
-
Region
- Inherited Members
Remarks
The region stores exact integer coverage using a normalized rect-set model: horizontal Y bands contain sorted X intervals. Region operations preserve the covered area as a union of rectangles; ToPath() exports that area as boundary geometry.
Constructors
Region()
Initializes a new instance of the Region class.
public Region()
Region(Region)
Initializes a new instance of the Region class containing the same area as the specified region.
public Region(Region region)
Parameters
regionRegionThe region to copy.
Region(Rectangle)
Initializes a new instance of the Region class containing the specified rectangle.
public Region(Rectangle rectangle)
Parameters
rectangleRectangleThe rectangle to add to the region.
Properties
Bounds
Gets the bounding rectangle of the region.
public Rectangle Bounds { get; }
Property Value
Remarks
Returns Empty when the region is empty.
IsEmpty
Gets a value indicating whether the region contains no area.
public bool IsEmpty { get; }
Property Value
Rectangles
Gets the non-overlapping rectangles that describe the region.
public IReadOnlyList<Rectangle> Rectangles { get; }
Property Value
Remarks
The rectangles are an exported view of the region area. They preserve the region shape as a rect-set and are not collapsed to Bounds.
Methods
Add(Rectangle)
Adds a rectangle to the region.
public void Add(Rectangle rectangle)
Parameters
rectangleRectangleThe rectangle to add.
Remarks
Rectangles with non-positive width or height do not change the region. The rectangle is unioned with the existing rect-set.
Clear()
Removes all rectangles from the region.
public void Clear()
Contains(Point)
Returns a value indicating whether the region contains the specified point.
public bool Contains(Point point)
Parameters
pointPointThe point to test.
Returns
Contains(int, int)
Returns a value indicating whether the region contains the specified point.
public bool Contains(int x, int y)
Parameters
Returns
Intersect(Region)
Intersects this region with the specified region.
public bool Intersect(Region region)
Parameters
regionRegionThe region to intersect with this region.
Returns
Remarks
The operation intersects every overlapping X interval pair in every overlapping Y band and unions the results. This is the rect-set form of region intersection.
Intersect(Rectangle)
Intersects this region with the specified rectangle.
public bool Intersect(Rectangle rectangle)
Parameters
rectangleRectangleThe rectangle to intersect with this region.
Returns
Remarks
This operation clips the existing rect-set to the rectangle. It does not replace the result with one bounding rectangle.
Intersects(Rectangle)
Returns a value indicating whether the region intersects the specified rectangle.
public bool Intersects(Rectangle rectangle)
Parameters
rectangleRectangleThe rectangle to test.
Returns
ToPath()
Creates a path representing the region.
public IPath ToPath()
Returns
- IPath
The path representing the region.
Remarks
The returned path describes the exact boundary of the region. Complex regions may produce multiple closed figures. Returns ClosedPath when the region is empty.