This union represents four floating point values or a float point rectangle.
You can find more information in comments below.
union RectF
{
struct
{
float Left;
float Top;
float Right;
float Bottom;
};
struct
{
PointF LeftTop;
PointF RightBottom;
};
float Data[4];
float operator[](const int index) const; // Return element
float &operator[](const int index); // Return element
bool is_valid(const float tolerance = Tolerance) const; // Return whether right border isn't less than left and bottom isn't less than top
bool is_empty(const float tolerance = Tolerance) const; // Return whether right border is same as left and bottom is same as top
bool is_zero(const float tolerance = Tolerance) const; // Return whether either right border is same to left or bottom is same to top
bool has_negative(const float tolerance = Tolerance) const; // Whether there is a negative element
bool has_positive(const float tolerance = Tolerance) const; // Whether there is a positive element
float width() const; // Rectangle width
float height() const; // Rectangle height
void validate(const float tolerance = Tolerance); // Make width and height not negative
};
Following operators are also available.
bool operator==(const Rect &a, const Rect &b); // Check if rects are equal
bool operator!=(const Rect &a, const Rect &b); // Check if rects are not equal
Rect operator+(const Rect &a, const int value); // Add rect and value
Rect operator-(const Rect &a, const int value); // Subtract rect and value
Rect operator/(const Rect &a, const int value); // Divide rect and value
Rect operator*(const Rect &a, const int value); // Multiply rect and value
Rect operator+(const int value, const Rect &a); // Add value and rect
Rect operator-(const int value, const Rect &a); // Subtract value and rect
Rect operator/(const int value, const Rect &a); // Divide value and rect
Rect operator*(const int value, const Rect &a); // Multiply value and rect
Rect &operator+=(Rect &a, const int value); // Add value to rect
Rect &operator-=(Rect &a, const int value); // Subtract value from rect
Rect &operator/=(Rect &a, const int value); // Divide rect on value
Rect &operator*=(Rect &a, const int value); // Multiply rect on value
Rect operator+(const Rect &a, const Rect &b); // Find bounding rect for both rects
Rect operator*(const Rect &a, const Rect &b); // Calculate intersection
Rect &operator+=(Rect &a, const Rect &b); // Find bounding rect for both rects and store it in first one
Rect &operator*=(Rect &a, const Rect &b); // Calculate intersection and store it in first one
Rect operator+(const Rect &a, const Point &shift); // Return moved in shift direction rect
Rect operator-(const Rect &a, const Point &shift); // Return moved in opposite to shift direction rect
RectF operator*(const RectF &a, const PointF &shift); // Return scaled in shift direction rect
Rect &operator+=(Rect &a, const Point &shift); // Move rect in shift direction
Rect &operator-=(Rect &a, const Point &shift); // Move rect in direction opposite to shift
RectF &operator*=(RectF &a, const PointF &shift); // Scale rect in shift direction
std::wostream &operator<<(std::wostream &stream, const RectF &a); // Output as source code
Namespace: | nitisa |
Include: |
Nitisa/Core/Math/RectF.h (For union declaration) Nitisa/Core/Math/RectFUtils.h (For standalone operators) |