Table of Contents

Struct Rect2d

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Stores a set of four double-precision floating-point numbers that represent the location and size of a rectangle

[Serializable]
public record struct Rect2d : IEquatable<Rect2d>
Implements
Inherited Members

Constructors

Rect2d(Point2d, Size2d)

Constructor

public Rect2d(Point2d location, Size2d size)

Parameters

location Point2d
size Size2d

Rect2d(double, double, double, double)

Stores a set of four double-precision floating-point numbers that represent the location and size of a rectangle

public Rect2d(double X, double Y, double Width, double Height)

Parameters

X double

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

Y double

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

Width double

The width of the rectangle.

Height double

The height of the rectangle.

Fields

Height

The height of the rectangle.

public double Height

Field Value

double

Width

The width of the rectangle.

public double Width

Field Value

double

X

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

public double X

Field Value

double

Y

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

public double Y

Field Value

double

Properties

Bottom

Gets the y-coordinate that is the sum of the Y and Height property values of this Rect2d structure.

public readonly double Bottom { get; }

Property Value

double

BottomRight

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

public readonly Point2d BottomRight { get; }

Property Value

Point2d

Left

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

public double Left { readonly get; set; }

Property Value

double

Location

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

public Point2d Location { readonly get; set; }

Property Value

Point2d

Right

Gets the x-coordinate that is the sum of X and Width property values of this Rect2d structure.

public readonly double Right { get; }

Property Value

double

Size

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

public Size2d Size { readonly get; set; }

Property Value

Size2d

Top

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

public double Top { readonly get; set; }

Property Value

double

TopLeft

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

public readonly Point2d TopLeft { get; }

Property Value

Point2d

Methods

Add(Point2d)

Shifts rectangle by a certain offset

public readonly Rect2d Add(Point2d pt)

Parameters

pt Point2d

Returns

Rect2d

Add(Size2d)

Shifts rectangle by a certain offset

public readonly Rect2d Add(Size2d size)

Parameters

size Size2d

Returns

Rect2d

Contains(Point2d)

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

public readonly bool Contains(Point2d pt)

Parameters

pt Point2d

point

Returns

bool

Contains(Rect2d)

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

public readonly bool Contains(Rect2d rect)

Parameters

rect Rect2d

rectangle

Returns

bool

Contains(double, double)

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

public readonly bool Contains(double x, double y)

Parameters

x double

x-coordinate of the point

y double

y-coordinate of the point

Returns

bool

FromLTRB(double, double, double, double)

public static Rect2d FromLTRB(double left, double top, double right, double bottom)

Parameters

left double
top double
right double
bottom double

Returns

Rect2d

Inflate(Rect, int, int)

Creates and returns an inflated copy of the specified Rect2d 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(Size2d)

Inflates this Rect by the specified amount.

public void Inflate(Size2d size)

Parameters

size Size2d

The amount to inflate this rectangle.

Inflate(double, double)

Inflates this Rect by the specified amount.

public void Inflate(double width, double height)

Parameters

width double

The amount to inflate this Rectangle horizontally.

height double

The amount to inflate this Rectangle vertically.

Intersect(Rect2d)

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

public readonly Rect2d Intersect(Rect2d rect)

Parameters

rect Rect2d

A rectangle to intersect.

Returns

Rect2d

Intersect(Rect2d, Rect2d)

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

public static Rect2d Intersect(Rect2d a, Rect2d b)

Parameters

a Rect2d

A rectangle to intersect.

b Rect2d

A rectangle to intersect.

Returns

Rect2d

IntersectsWith(Rect2d)

Determines if this rectangle intersects with rect.

public readonly bool IntersectsWith(Rect2d rect)

Parameters

rect Rect2d

Rectangle

Returns

bool

Subtract(Point2d)

Shifts rectangle by a certain offset

public readonly Rect2d Subtract(Point2d pt)

Parameters

pt Point2d

Returns

Rect2d

Subtract(Size2d)

Shifts rectangle by a certain offset

public readonly Rect2d Subtract(Size2d size)

Parameters

size Size2d

Returns

Rect2d

ToRect()

public readonly Rect ToRect()

Returns

Rect

Union(Rect2d)

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

public readonly Rect2d Union(Rect2d rect)

Parameters

rect Rect2d

A rectangle to union.

Returns

Rect2d

Union(Rect2d, Rect2d)

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

public static Rect2d Union(Rect2d a, Rect2d b)

Parameters

a Rect2d

A rectangle to union.

b Rect2d

A rectangle to union.

Returns

Rect2d

Operators

operator +(Rect2d, Point2d)

Shifts rectangle by a certain offset

public static Rect2d operator +(Rect2d rect, Point2d pt)

Parameters

rect Rect2d
pt Point2d

Returns

Rect2d

operator +(Rect2d, Size2d)

Expands or shrinks rectangle by a certain amount

public static Rect2d operator +(Rect2d rect, Size2d size)

Parameters

rect Rect2d
size Size2d

Returns

Rect2d

operator &(Rect2d, Rect2d)

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

[SuppressMessage("Microsoft.Design", "CA2225: Operator overloads have named alternates")]
public static Rect2d operator &(Rect2d a, Rect2d b)

Parameters

a Rect2d

A rectangle to intersect.

b Rect2d

A rectangle to intersect.

Returns

Rect2d

operator |(Rect2d, Rect2d)

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

[SuppressMessage("Microsoft.Design", "CA2225: Operator overloads have named alternates")]
public static Rect2d operator |(Rect2d a, Rect2d b)

Parameters

a Rect2d

A rectangle to union.

b Rect2d

A rectangle to union.

Returns

Rect2d

operator -(Rect2d, Point2d)

Shifts rectangle by a certain offset

public static Rect2d operator -(Rect2d rect, Point2d pt)

Parameters

rect Rect2d
pt Point2d

Returns

Rect2d

operator -(Rect2d, Size2d)

Expands or shrinks rectangle by a certain amount

public static Rect2d operator -(Rect2d rect, Size2d size)

Parameters

rect Rect2d
size Size2d

Returns

Rect2d