Class Rect
- Namespace
- VisioForge.Core.Types
- Assembly
- VisioForge.Core.dll
Represents a rectangular area defined by its left, top, right, and bottom coordinates. This class provides properties to access the dimensions and check if the rectangle is empty.
public class RectInheritance
Inherited Members
Extension Methods
Remarks
This class is commonly used to define regions of interest, video frame dimensions, cropping areas, or UI element bounds. It includes constructors for various initialization scenarios and utility properties for width and height. The rectangle is defined by edges (Left, Top, Right, Bottom) rather than position and size, which is common in graphics APIs. Width is calculated as Right - Left, and Height as Bottom - Top. The IsEmpty property returns true only when all coordinates are zero. On Windows platforms, the class provides conversion methods to/from System.Drawing.Rectangle for interoperability. This type is used throughout the framework for specifying video crop regions, overlay positions, or selection areas. Coordinate values are in pixels and represent inclusive boundaries.
Constructors
Rect(int, int, int, int)
Initializes a new instance of the VisioForge.Core.Types.Rect class with specified integer coordinates.
public Rect(int left, int top, int right, int bottom)Parameters
leftint-
The x-coordinate of the left edge.
topint-
The y-coordinate of the top edge.
rightint-
The x-coordinate of the right edge.
bottomint-
The y-coordinate of the bottom edge.
Rect(uint, uint, uint, uint)
Initializes a new instance of the VisioForge.Core.Types.Rect class with specified unsigned integer coordinates. The coordinates are cast to Int32.
public Rect(uint left, uint top, uint right, uint bottom)Parameters
leftuint-
The x-coordinate of the left edge.
topuint-
The y-coordinate of the top edge.
rightuint-
The x-coordinate of the right edge.
bottomuint-
The y-coordinate of the bottom edge.
Rect()
Initializes a new instance of the VisioForge.Core.Types.Rect class with all coordinates set to zero, creating an empty rectangle.
public Rect()Rect(Size)
Initializes a new instance of the VisioForge.Core.Types.Rect class with its top-left corner at (0,0) and dimensions specified by a VisioForge.Core.Types.Size object.
public Rect(Size size)Parameters
sizeSize-
The VisioForge.Core.Types.Size object defining the width and height of the rectangle.
Properties
Bottom
Gets or sets the y-coordinate of the bottom edge of the rectangle.
public int Bottom { get; set; }Property Value
Height
Gets the height of the rectangle.
public int Height { get; }Property Value
IsEmpty
Gets a value indicating whether the rectangle is empty (i.e., all coordinates are zero).
public bool IsEmpty { get; }Property Value
Left
Gets or sets the x-coordinate of the left edge of the rectangle.
public int Left { get; set; }Property Value
Right
Gets or sets the x-coordinate of the right edge of the rectangle.
public int Right { get; set; }Property Value
Top
Gets or sets the y-coordinate of the top edge of the rectangle.
public int Top { get; set; }Property Value
Width
Gets the width of the rectangle.
public int Width { get; }Property Value
Methods
IntersectsWith(Rect)
Returns a value indicating whether the current rectangle intersects with another specified rectangle.
public bool IntersectsWith(Rect rect)Parameters
rectRect-
The rectangle to check for intersection.
Returns
- bool
-
trueif the rectangles intersect; otherwise,false.
ToString()
Returns a string that represents the current VisioForge.Core.Types.Rect instance in a human-readable format.
public override string ToString()Returns
Union(Rect, Rect)
Returns a new VisioForge.Core.Types.Rect that represents the union of two rectangles.
public static Rect Union(Rect a, Rect b)Parameters
Returns
- Rect
-
A new VisioForge.Core.Types.Rect that encompasses both input rectangles.