Table of Contents

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

location Point2f
size Size2f

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

X float

The x-coordinate of the upper-left corner of the rectangle.

Y float

The y-coordinate of the upper-left corner of the rectangle.

Width float

The width of the rectangle.

Height float

The height of the rectangle.

Fields

Height

The height of the rectangle.

public float Height

Field Value

float

Width

The width of the rectangle.

public float Width

Field Value

float

X

The x-coordinate of the upper-left corner of the rectangle.

public float X

Field Value

float

Y

The y-coordinate of the upper-left corner of the rectangle.

public float Y

Field Value

float

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

float

BottomRight

Coordinate of the right-most rectangle corner [Point2f(X+Width, Y+Height)]

public readonly Point2f BottomRight { get; }

Property Value

Point2f

Left

Gets the x-coordinate of the left edge of this Rect2f structure.

public float Left { readonly get; set; }

Property Value

float

Location

Coordinate of the left-most rectangle corner [Point2f(X, Y)]

public Point2f Location { readonly get; set; }

Property Value

Point2f

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

float

Size

Size of the rectangle [CvSize(Width, Height)]

public Size2f Size { readonly get; set; }

Property Value

Size2f

Top

Gets the y-coordinate of the top edge of this Rect2f structure.

public float Top { readonly get; set; }

Property Value

float

TopLeft

Coordinate of the left-most rectangle corner [Point2f(X, Y)]

public readonly Point2f TopLeft { get; }

Property Value

Point2f

Methods

Add(Point2f)

Shifts rectangle by a certain offset

public readonly Rect2f Add(Point2f pt)

Parameters

pt Point2f

Returns

Rect2f

Add(Size2f)

Expands or shrinks rectangle by a certain amount

public readonly Rect2f Add(Size2f size)

Parameters

size Size2f

Returns

Rect2f

Contains(Point2f)

Determines if the specified point is contained within the rectangular region defined by this Rectangle.

public readonly bool Contains(Point2f pt)

Parameters

pt Point2f

point

Returns

bool

Contains(Rect2f)

Determines if the specified rectangle is contained within the rectangular region defined by this Rectangle.

public readonly bool Contains(Rect2f rect)

Parameters

rect Rect2f

rectangle

Returns

bool

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

x float

x-coordinate of the point

y float

y-coordinate of the point

Returns

bool

FromLTRB(float, float, float, float)

public static Rect2f FromLTRB(float left, float top, float right, float bottom)

Parameters

left float
top float
right float
bottom float

Returns

Rect2f

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

rect Rect

The Rectangle with which to start. This rectangle is not modified.

x int

The amount to inflate this Rectangle horizontally.

y int

The amount to inflate this Rectangle vertically.

Returns

Rect

Inflate(Size2f)

Inflates this Rect by the specified amount.

public void Inflate(Size2f size)

Parameters

size Size2f

The amount to inflate this rectangle.

Inflate(float, float)

Inflates this Rect by the specified amount.

public void Inflate(float width, float height)

Parameters

width float

The amount to inflate this Rectangle horizontally.

height float

The 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

rect Rect2f

A rectangle to intersect.

Returns

Rect2f

Intersect(Rect2f, Rect2f)

Determines the Rect2f structure that represents the intersection of two rectangles.

public static Rect2f Intersect(Rect2f a, Rect2f b)

Parameters

a Rect2f

A rectangle to intersect.

b Rect2f

A rectangle to intersect.

Returns

Rect2f

IntersectsWith(Rect2f)

Determines if this rectangle intersects with rect.

public readonly bool IntersectsWith(Rect2f rect)

Parameters

rect Rect2f

Rectangle

Returns

bool

Subtract(Point2f)

Shifts rectangle by a certain offset

public readonly Rect2f Subtract(Point2f pt)

Parameters

pt Point2f

Returns

Rect2f

Subtract(Size2f)

Expands or shrinks rectangle by a certain amount

public readonly Rect2f Subtract(Size2f size)

Parameters

size Size2f

Returns

Rect2f

Union(Rect2f)

Gets a Rect2f structure that contains the union of two Rect2f structures.

public readonly Rect2f Union(Rect2f rect)

Parameters

rect Rect2f

A rectangle to union.

Returns

Rect2f

Union(Rect2f, Rect2f)

Gets a Rect2f structure that contains the union of two Rect2f structures.

public static Rect2f Union(Rect2f a, Rect2f b)

Parameters

a Rect2f

A rectangle to union.

b Rect2f

A rectangle to union.

Returns

Rect2f

Operators

operator +(Rect2f, Point2f)

Shifts rectangle by a certain offset

public static Rect2f operator +(Rect2f rect, Point2f pt)

Parameters

rect Rect2f
pt Point2f

Returns

Rect2f

operator +(Rect2f, Size2f)

Expands or shrinks rectangle by a certain amount

public static Rect2f operator +(Rect2f rect, Size2f size)

Parameters

rect Rect2f
size Size2f

Returns

Rect2f

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

a Rect2f

A rectangle to intersect.

b Rect2f

A rectangle to intersect.

Returns

Rect2f

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

a Rect2f

A rectangle to union.

b Rect2f

A rectangle to union.

Returns

Rect2f

operator -(Rect2f, Point2f)

Shifts rectangle by a certain offset

public static Rect2f operator -(Rect2f rect, Point2f pt)

Parameters

rect Rect2f
pt Point2f

Returns

Rect2f

operator -(Rect2f, Size2f)

Expands or shrinks rectangle by a certain amount

public static Rect2f operator -(Rect2f rect, Size2f size)

Parameters

rect Rect2f
size Size2f

Returns

Rect2f