Struct Rect
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Stores a set of four integers that represent the location and size of a rectangle
[Serializable]
public record struct Rect : IEquatable<Rect>
- Implements
- Inherited Members
Constructors
Rect(Point, Size)
Initializes a new instance of the Rectangle class with the specified location and size.
public Rect(Point location, Size size)
Parameters
locationPointA Point that represents the upper-left corner of the rectangular region.
sizeSizeA Size that represents the width and height of the rectangular region.
Rect(int, int, int, int)
Stores a set of four integers that represent the location and size of a rectangle
public Rect(int X, int Y, int Width, int Height)
Parameters
XintThe x-coordinate of the upper-left corner of the rectangle.
YintThe y-coordinate of the upper-left corner of the rectangle.
WidthintThe width of the rectangle.
HeightintThe height of the rectangle.
Fields
Height
The height of the rectangle.
public int Height
Field Value
Width
The width of the rectangle.
public int Width
Field Value
X
The x-coordinate of the upper-left corner of the rectangle.
public int X
Field Value
Y
The y-coordinate of the upper-left corner of the rectangle.
public int Y
Field Value
Properties
Bottom
Gets the y-coordinate that is the sum of the Y and Height property values of this Rect structure.
public int Bottom { get; }
Property Value
BottomRight
Coordinate of the right-most rectangle corner [Point(X+Width, Y+Height)]
public Point BottomRight { get; }
Property Value
Left
Gets the x-coordinate of the left edge of this Rect structure.
public int Left { get; set; }
Property Value
Location
Coordinate of the left-most rectangle corner [Point(X, Y)]
public Point Location { get; set; }
Property Value
Right
Gets the x-coordinate that is the sum of X and Width property values of this Rect structure.
public int Right { get; }
Property Value
Size
Size of the rectangle [CvSize(Width, Height)]
public Size Size { get; set; }
Property Value
Top
Gets the y-coordinate of the top edge of this Rect structure.
public int Top { readonly get; set; }
Property Value
TopLeft
Coordinate of the left-most rectangle corner [Point(X, Y)]
public Point TopLeft { get; }
Property Value
Methods
Add(Point)
Shifts rectangle by a certain offset
public readonly Rect Add(Point pt)
Parameters
ptPoint
Returns
Add(Size)
Expands or shrinks rectangle by a certain amount
public readonly Rect Add(Size size)
Parameters
sizeSize
Returns
Contains(Point)
Determines if the specified point is contained within the rectangular region defined by this Rectangle.
public readonly bool Contains(Point pt)
Parameters
ptPointpoint
Returns
Contains(Rect)
Determines if the specified rectangle is contained within the rectangular region defined by this Rectangle.
public readonly bool Contains(Rect rect)
Parameters
rectRectrectangle
Returns
Contains(int, int)
Determines if the specified point is contained within the rectangular region defined by this Rectangle.
public readonly bool Contains(int x, int y)
Parameters
Returns
FromLTRB(int, int, int, int)
Creates a Rectangle structure with the specified edge locations.
public static Rect FromLTRB(int left, int top, int right, int bottom)
Parameters
leftintThe x-coordinate of the upper-left corner of this Rectangle structure.
topintThe y-coordinate of the upper-left corner of this Rectangle structure.
rightintThe x-coordinate of the lower-right corner of this Rectangle structure.
bottomintThe y-coordinate of the lower-right corner of this Rectangle structure.
Returns
Inflate(Rect, int, int)
Creates and returns an inflated copy of the specified Rect structure.
public static Rect Inflate(Rect rect, int x, int y)
Parameters
rectRectThe Rectangle with which to start. This rectangle is not modified.
xintThe amount to inflate this Rectangle horizontally.
yintThe amount to inflate this Rectangle vertically.
Returns
Inflate(Size)
Inflates this Rect by the specified amount.
public void Inflate(Size size)
Parameters
sizeSizeThe amount to inflate this rectangle.
Inflate(int, int)
Inflates this Rect by the specified amount.
public void Inflate(int width, int height)
Parameters
widthintThe amount to inflate this Rectangle horizontally.
heightintThe amount to inflate this Rectangle vertically.
Intersect(Rect)
Determines the Rect structure that represents the intersection of two rectangles.
public readonly Rect Intersect(Rect rect)
Parameters
rectRectA rectangle to intersect.
Returns
Intersect(Rect, Rect)
Determines the Rect structure that represents the intersection of two rectangles.
public static Rect Intersect(Rect a, Rect b)
Parameters
Returns
IntersectsWith(Rect)
Determines if this rectangle intersects with rect.
public readonly bool IntersectsWith(Rect rect)
Parameters
rectRectRectangle
Returns
Subtract(Point)
Shifts rectangle by a certain offset
public readonly Rect Subtract(Point pt)
Parameters
ptPoint
Returns
Subtract(Size)
Expands or shrinks rectangle by a certain amount
public readonly Rect Subtract(Size size)
Parameters
sizeSize
Returns
Union(Rect)
Gets a Rect structure that contains the union of two Rect structures.
public readonly Rect Union(Rect rect)
Parameters
rectRectA rectangle to union.
Returns
Union(Rect, Rect)
Gets a Rect structure that contains the union of two Rect structures.
public static Rect Union(Rect a, Rect b)
Parameters
Returns
Operators
operator +(Rect, Point)
Shifts rectangle by a certain offset
public static Rect operator +(Rect rect, Point pt)
Parameters
Returns
operator +(Rect, Size)
Expands or shrinks rectangle by a certain amount
public static Rect operator +(Rect rect, Size size)
Parameters
Returns
operator &(Rect, Rect)
Determines the Rect structure that represents the intersection of two rectangles.
[SuppressMessage("Microsoft.Design", "CA2225: Operator overloads have named alternates")]
public static Rect operator &(Rect a, Rect b)
Parameters
Returns
operator |(Rect, Rect)
Gets a Rect structure that contains the union of two Rect structures.
[SuppressMessage("Microsoft.Design", "CA2225: Operator overloads have named alternates")]
public static Rect operator |(Rect a, Rect b)
Parameters
Returns
operator -(Rect, Point)
Shifts rectangle by a certain offset
public static Rect operator -(Rect rect, Point pt)
Parameters
Returns
operator -(Rect, Size)
Expands or shrinks rectangle by a certain amount
public static Rect operator -(Rect rect, Size size)