Table of Contents

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 Rect

Inheritance

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

left int

The x-coordinate of the left edge.

top int

The y-coordinate of the top edge.

right int

The x-coordinate of the right edge.

bottom int

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

left uint

The x-coordinate of the left edge.

top uint

The y-coordinate of the top edge.

right uint

The x-coordinate of the right edge.

bottom uint

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

size Size

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

int

Height

Gets the height of the rectangle.

public int Height { get; }

Property Value

int

IsEmpty

Gets a value indicating whether the rectangle is empty (i.e., all coordinates are zero).

public bool IsEmpty { get; }

Property Value

bool

Left

Gets or sets the x-coordinate of the left edge of the rectangle.

public int Left { get; set; }

Property Value

int

Right

Gets or sets the x-coordinate of the right edge of the rectangle.

public int Right { get; set; }

Property Value

int

Top

Gets or sets the y-coordinate of the top edge of the rectangle.

public int Top { get; set; }

Property Value

int

Width

Gets the width of the rectangle.

public int Width { get; }

Property Value

int

Methods

IntersectsWith(Rect)

Returns a value indicating whether the current rectangle intersects with another specified rectangle.

public bool IntersectsWith(Rect rect)

Parameters

rect Rect

The rectangle to check for intersection.

Returns

bool

true if 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

string

A String that represents this instance, showing coordinates and dimensions.

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

a Rect

The first rectangle.

b Rect

The second rectangle.

Returns

Rect

A new VisioForge.Core.Types.Rect that encompasses both input rectangles.