Struct Rect2f
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
A rectangle with float type coordinates in 2D space
[Serializable]
[SuppressMessage("Design", "CA1051: Do not declare visible instance fields")]
public record struct Rect2f : IEquatable<Rect2f>
- Implements
- Inherited Members
Constructors
Rect2f(Point2f, Size2f)
Constructor
public Rect2f(Point2f location, Size2f size)
Parameters
Rect2f(float, float, float, float)
A rectangle with float type coordinates in 2D space
public Rect2f(float X, float Y, float Width, float Height)
Parameters
XfloatThe x-coordinate of the upper-left corner of the rectangle.
YfloatThe y-coordinate of the upper-left corner of the rectangle.
WidthfloatThe width of the rectangle.
HeightfloatThe height of the rectangle.
Fields
Height
The height of the rectangle.
public float Height
Field Value
Width
The width of the rectangle.
public float Width
Field Value
X
The x-coordinate of the upper-left corner of the rectangle.
public float X
Field Value
Y
The y-coordinate of the upper-left corner of the rectangle.
public float Y
Field Value
Properties
Bottom
Gets the y-coordinate that is the sum of the Y and Height property values of this Rect2f structure.
public readonly float Bottom { get; }
Property Value
BottomRight
Coordinate of the right-most rectangle corner [Point2f(X+Width, Y+Height)]
public readonly Point2f BottomRight { get; }
Property Value
Left
Gets the x-coordinate of the left edge of this Rect2f structure.
public float Left { readonly get; set; }
Property Value
Location
Coordinate of the left-most rectangle corner [Point2f(X, Y)]
public Point2f Location { readonly get; set; }
Property Value
Right
Gets the x-coordinate that is the sum of X and Width property values of this Rect2f structure.
public readonly float Right { get; }
Property Value
Size
Size of the rectangle [CvSize(Width, Height)]
public Size2f Size { readonly get; set; }
Property Value
Top
Gets the y-coordinate of the top edge of this Rect2f structure.
public float Top { readonly get; set; }
Property Value
TopLeft
Coordinate of the left-most rectangle corner [Point2f(X, Y)]
public readonly Point2f TopLeft { get; }
Property Value
Methods
Add(Point2f)
Shifts rectangle by a certain offset
public readonly Rect2f Add(Point2f pt)
Parameters
ptPoint2f
Returns
Add(Size2f)
Expands or shrinks rectangle by a certain amount
public readonly Rect2f Add(Size2f size)
Parameters
sizeSize2f
Returns
Contains(Point2f)
Determines if the specified point is contained within the rectangular region defined by this Rectangle.
public readonly bool Contains(Point2f pt)
Parameters
ptPoint2fpoint
Returns
Contains(Rect2f)
Determines if the specified rectangle is contained within the rectangular region defined by this Rectangle.
public readonly bool Contains(Rect2f rect)
Parameters
rectRect2frectangle
Returns
Contains(float, float)
Determines if the specified point is contained within the rectangular region defined by this Rectangle.
public readonly bool Contains(float x, float y)
Parameters
Returns
FromLTRB(float, float, float, float)
public static Rect2f FromLTRB(float left, float top, float right, float bottom)
Parameters
Returns
Inflate(Rect, int, int)
Creates and returns an inflated copy of the specified Rect2f 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(Size2f)
Inflates this Rect by the specified amount.
public void Inflate(Size2f size)
Parameters
sizeSize2fThe amount to inflate this rectangle.
Inflate(float, float)
Inflates this Rect by the specified amount.
public void Inflate(float width, float height)
Parameters
widthfloatThe amount to inflate this Rectangle horizontally.
heightfloatThe amount to inflate this Rectangle vertically.
Intersect(Rect2f)
Determines the Rect2f structure that represents the intersection of two rectangles.
public readonly Rect2f Intersect(Rect2f rect)
Parameters
rectRect2fA rectangle to intersect.
Returns
Intersect(Rect2f, Rect2f)
Determines the Rect2f structure that represents the intersection of two rectangles.
public static Rect2f Intersect(Rect2f a, Rect2f b)
Parameters
Returns
IntersectsWith(Rect2f)
Determines if this rectangle intersects with rect.
public readonly bool IntersectsWith(Rect2f rect)
Parameters
rectRect2fRectangle
Returns
Subtract(Point2f)
Shifts rectangle by a certain offset
public readonly Rect2f Subtract(Point2f pt)
Parameters
ptPoint2f
Returns
Subtract(Size2f)
Expands or shrinks rectangle by a certain amount
public readonly Rect2f Subtract(Size2f size)
Parameters
sizeSize2f
Returns
Union(Rect2f)
Gets a Rect2f structure that contains the union of two Rect2f structures.
public readonly Rect2f Union(Rect2f rect)
Parameters
rectRect2fA rectangle to union.
Returns
Union(Rect2f, Rect2f)
Gets a Rect2f structure that contains the union of two Rect2f structures.
public static Rect2f Union(Rect2f a, Rect2f b)
Parameters
Returns
Operators
operator +(Rect2f, Point2f)
Shifts rectangle by a certain offset
public static Rect2f operator +(Rect2f rect, Point2f pt)
Parameters
Returns
operator +(Rect2f, Size2f)
Expands or shrinks rectangle by a certain amount
public static Rect2f operator +(Rect2f rect, Size2f size)
Parameters
Returns
operator &(Rect2f, Rect2f)
Determines the Rect2f structure that represents the intersection of two rectangles.
[SuppressMessage("Microsoft.Design", "CA2225: Operator overloads have named alternates")]
public static Rect2f operator &(Rect2f a, Rect2f b)
Parameters
Returns
operator |(Rect2f, Rect2f)
Gets a Rect2f structure that contains the union of two Rect2f structures.
[SuppressMessage("Microsoft.Design", "CA2225: Operator overloads have named alternates")]
public static Rect2f operator |(Rect2f a, Rect2f b)
Parameters
Returns
operator -(Rect2f, Point2f)
Shifts rectangle by a certain offset
public static Rect2f operator -(Rect2f rect, Point2f pt)
Parameters
Returns
operator -(Rect2f, Size2f)
Expands or shrinks rectangle by a certain amount
public static Rect2f operator -(Rect2f rect, Size2f size)