Struct Rect

Struct Documentation

struct Rect

Rect structure

x,y coordinates together with width and height that define a rectangle. Can be either normalized [0,1] or absolute representation.

Public Functions

Rect() = default
inline Rect(float x, float y, float width, float height)
inline Rect(float x, float y, float width, float height, bool normalized)
inline Rect(const Rect &r)
inline Rect(const Point2f &org, const Size2f &sz)
inline Rect(const Point2f &org, const Size2f &sz, bool normalized)
inline Rect(const Point2f &pt1, const Point2f &pt2)
inline Rect(const Point2f &pt1, const Point2f &pt2, bool normalized)
Rect &operator=(const Rect &r) = default
Rect &operator=(Rect &&r) = default
inline Point2f topLeft() const

The top-left corner.

inline Point2f bottomRight() const

The bottom-right corner

inline Size2f size() const

Size (width, height) of the rectangle

inline float area() const

Area (width*height) of the rectangle

inline bool empty() const

True if rectangle is empty.

inline bool contains(const Point2f &pt) const

Checks whether the rectangle contains the point.

inline bool isNormalized() const

Whether rectangle is normalized (coordinates in [0,1] range) or not.

inline Rect denormalize(int destWidth, int destHeight) const

Denormalize rectangle.

Parameters:
  • destWidth – Destination frame width.

  • destHeight – Destination frame height.

inline Rect normalize(int srcWidth, int srcHeight) const

Normalize rectangle.

Parameters:
  • srcWidth – Source frame width.

  • srcHeight – Source frame height.

Public Members

float x = 0.0f
float y = 0.0f
float width = 0.0f
float height = 0.0f
bool normalized = false
bool hasNormalized = false