fixed_rect class
#include <bn_fixed_rect.h>
Defines a two-dimensional rectangle using fixed point precision.
Contents
Constructors, destructors, conversion operators
- fixed_rect() defaulted constexpr
- Default constructor.
-
fixed_rect(const fixed_
point& position, const fixed_ size& dimensions) constexpr - Constructor.
- fixed_rect(fixed x, fixed y, fixed width, fixed height) constexpr
- Constructor.
- fixed_rect(const rect& rect) constexpr
- Constructor.
Public functions
-
auto position() const -> const fixed_
point& constexpr - Returns the position of the center point of the rectangle.
-
void set_position(const fixed_
point& position) constexpr - Sets the position of the center point of the rectangle.
- void set_position(fixed x, fixed y) constexpr
- Sets the position of the center point of the rectangle.
-
auto dimensions() const -> const fixed_
size& constexpr - Returns the size of the rectangle.
-
void set_dimensions(const fixed_
size& dimensions) constexpr - Sets the size of the rectangle.
- void set_dimensions(fixed width, fixed height) constexpr
- Sets the size of the rectangle.
- auto x() const -> fixed constexpr
- Returns the horizontal position of the center point of the rectangle.
- void set_x(fixed x) constexpr
- Sets the horizontal position of the center point of the rectangle.
- auto y() const -> fixed constexpr
- Returns the vertical position of the center point of the rectangle.
- void set_y(fixed y) constexpr
- Sets the vertical position of the center point of the rectangle.
- auto width() const -> fixed constexpr
- Returns the width of the rectangle.
- void set_width(fixed width) constexpr
- Sets the width of the rectangle.
- auto height() const -> fixed constexpr
- Returns the height of the rectangle.
- void set_height(fixed height) constexpr
- Sets the height of the rectangle.
- auto top() const -> fixed constexpr
- Returns the position of the top boundary of the rectangle.
- auto left() const -> fixed constexpr
- Returns the position of the left boundary of the rectangle.
- auto bottom() const -> fixed constexpr
- Returns the position of the bottom boundary of the rectangle.
- auto right() const -> fixed constexpr
- Returns the position of the right boundary of the rectangle.
-
auto top_left() const -> fixed_
point constexpr - Returns the position of the top-left corner of the rectangle.
-
auto top_right() const -> fixed_
point constexpr - Returns the position of the top-right corner of the rectangle.
-
auto bottom_left() const -> fixed_
point constexpr - Returns the position of the bottom-left corner of the rectangle.
-
auto bottom_right() const -> fixed_
point constexpr - Returns the position of the bottom-right corner of the rectangle.
-
auto contains(const fixed_
point& point) const -> bool constexpr - Indicates if the given point is inside the rectangle or not.
-
auto intersects(const fixed_
rect& other) const -> bool constexpr - Indicates if this rectangle intersects with the given one or not.
-
auto multiplication(int value) const -> fixed_
rect constexpr - Returns the multiplication of this rect by the given integer value.
-
auto multiplication(fixed value) const -> fixed_
rect constexpr - Returns the multiplication of this rect by the given fixed point value, using half precision to try to avoid overflow.
-
auto safe_multiplication(int value) const -> fixed_
rect constexpr - Returns the multiplication of this rect by the given integer value.
-
auto safe_multiplication(fixed value) const -> fixed_
rect constexpr - Returns the multiplication of this rect by the given fixed point value, casting them to int64_t to try to avoid overflow.
-
auto unsafe_multiplication(int value) const -> fixed_
rect constexpr - Returns the multiplication of this rect by the given integer value.
-
auto unsafe_multiplication(fixed value) const -> fixed_
rect constexpr - Returns the multiplication of this rect by the given fixed point value without trying to avoid overflow.
-
auto division(int value) const -> fixed_
rect constexpr - Returns the division of this rect by the given integer value.
-
auto division(fixed value) const -> fixed_
rect constexpr - Returns the division of this rect by the given fixed point value, using half precision to try to avoid overflow.
-
auto safe_division(int value) const -> fixed_
rect constexpr - Returns the division of this value by the given integer value.
-
auto safe_division(fixed value) const -> fixed_
rect constexpr - Returns the division of this rect by the given fixed point value, casting them to int64_t to try to avoid overflow.
-
auto unsafe_division(int value) const -> fixed_
rect constexpr - Returns the division of this value by the given integer value.
-
auto unsafe_division(fixed value) const -> fixed_
rect constexpr - Returns the division of this rect by the given fixed point value without trying to avoid overflow.
-
auto operator*=(int value) -> fixed_
rect& constexpr - Multiplies both width and height of the rectangle by the given factor.
-
auto operator*=(unsigned value) -> fixed_
rect& constexpr - Multiplies both width and height of the rectangle by the given factor.
-
auto operator*=(fixed value) -> fixed_
rect& constexpr - Multiplies both width and height of the rectangle by the given factor.
-
auto operator/=(int value) -> fixed_
rect& constexpr - Divides both width and height of the rectangle by the given divisor.
-
auto operator/=(unsigned value) -> fixed_
rect& constexpr - Divides both width and height of the rectangle by the given divisor.
-
auto operator/=(fixed value) -> fixed_
rect& constexpr - Divides both width and height of the rectangle by the given divisor.
Friends
-
auto operator*(const fixed_
rect& a, int b) -> friend fixed_ rect constexpr - Returns a multiplied by b.
-
auto operator*(const fixed_
rect& a, unsigned b) -> friend fixed_ rect constexpr - Returns a multiplied by b.
-
auto operator*(const fixed_
rect& a, fixed b) -> friend fixed_ rect constexpr - Returns a multiplied by b.
-
auto operator/(const fixed_
rect& a, int b) -> friend fixed_ rect constexpr - Returns a divided by b.
-
auto operator/(const fixed_
rect& a, unsigned b) -> friend fixed_ rect constexpr - Returns a divided by b.
-
auto operator/(const fixed_
rect& a, fixed b) -> friend fixed_ rect constexpr - Returns a divided by b.
-
auto operator==(const fixed_
rect& a, const fixed_ rect& b) -> friend bool defaulted constexpr - Default equal operator.
Function documentation
bn:: fixed_rect:: fixed_rect(const fixed_ point& position,
const fixed_ size& dimensions) constexpr
Constructor.
| Parameters | |
|---|---|
| position | Position of the center point of the rectangle. |
| dimensions | Size of the rectangle. |
bn:: fixed_rect:: fixed_rect(fixed x,
fixed y,
fixed width,
fixed height) constexpr
Constructor.
| Parameters | |
|---|---|
| x | Horizontal position of the center point of the rectangle. |
| y | Vertical position of the center point of the rectangle. |
| width | Valid width of the rectangle (>= 0). |
| height | Valid height of the rectangle (>= 0). |
bn:: fixed_rect:: fixed_rect(const rect& rect) constexpr
Constructor.
| Parameters | |
|---|---|
| rect | Integer rectangle. |
void bn:: fixed_rect:: set_position(fixed x,
fixed y) constexpr
Sets the position of the center point of the rectangle.
| Parameters | |
|---|---|
| x | Horizontal position of the center point of the rectangle. |
| y | Vertical position of the center point of the rectangle. |
void bn:: fixed_rect:: set_dimensions(fixed width,
fixed height) constexpr
Sets the size of the rectangle.
| Parameters | |
|---|---|
| width | Valid width of the rectangle (>= 0). |
| height | Valid height of the rectangle (>= 0). |
void bn:: fixed_rect:: set_height(fixed height) constexpr
Sets the height of the rectangle.
| Parameters | |
|---|---|
| height | Valid height (>= 0). |
bool bn:: fixed_rect:: contains(const fixed_ point& point) const constexpr
Indicates if the given point is inside the rectangle or not.
If the point is in the edge of the rectangle, it returns false.
bool bn:: fixed_rect:: intersects(const fixed_ rect& other) const constexpr
Indicates if this rectangle intersects with the given one or not.
Two rectangles intersect if there is at least one point that is within both rectangles.
fixed_ rect& bn:: fixed_rect:: operator*=(int value) constexpr
Multiplies both width and height of the rectangle by the given factor.
| Parameters | |
|---|---|
| value | Valid integer multiplication factor (>= 0). |
| Returns | Reference to this. |
fixed_ rect& bn:: fixed_rect:: operator*=(unsigned value) constexpr
Multiplies both width and height of the rectangle by the given factor.
| Parameters | |
|---|---|
| value | Unsigned integer multiplication factor. |
| Returns | Reference to this. |
fixed_ rect& bn:: fixed_rect:: operator*=(fixed value) constexpr
Multiplies both width and height of the rectangle by the given factor.
| Parameters | |
|---|---|
| value | Valid fixed point multiplication factor (>= 0). |
| Returns | Reference to this. |
fixed_ rect& bn:: fixed_rect:: operator/=(int value) constexpr
Divides both width and height of the rectangle by the given divisor.
| Parameters | |
|---|---|
| value | Valid integer divisor (> 0). |
| Returns | Reference to this. |
fixed_ rect& bn:: fixed_rect:: operator/=(unsigned value) constexpr
Divides both width and height of the rectangle by the given divisor.
| Parameters | |
|---|---|
| value | Valid unsigned integer divisor (> 0). |
| Returns | Reference to this. |
fixed_ rect& bn:: fixed_rect:: operator/=(fixed value) constexpr
Divides both width and height of the rectangle by the given divisor.
| Parameters | |
|---|---|
| value | Valid fixed point divisor (> 0). |
| Returns | Reference to this. |