#include <bn_fixed_size.h>
template<int Precision>
fixed_size_t class
Defines the size of a two-dimensional object using fixed point precision.
Constructors, destructors, conversion operators
- fixed_size_t() defaulted constexpr
- Default constructor.
-
fixed_size_t(fixed_
t<Precision> width, fixed_ t<Precision> height) constexpr - Constructor.
- fixed_size_t(const size& size) constexpr
- Constructor.
Public functions
-
auto width() const -> fixed_
t<Precision> constexpr - Returns the width.
-
void set_width(fixed_
t<Precision> width) constexpr - Sets the width.
-
auto height() const -> fixed_
t<Precision> constexpr - Returns the height.
-
void set_height(fixed_
t<Precision> height) constexpr - Sets the height.
-
auto multiplication(int value) const -> fixed_
size_ t constexpr - Returns the multiplication of this size by the given integer value.
-
auto multiplication(fixed_
t<Precision> value) const -> fixed_ size_ t constexpr - Returns the multiplication of this size by the given fixed point value, using half precision to try to avoid overflow.
-
auto safe_multiplication(int value) const -> fixed_
size_ t constexpr - Returns the multiplication of this size by the given integer value.
-
auto safe_multiplication(fixed_
t<Precision> value) const -> fixed_ size_ t constexpr - Returns the multiplication of this size by the given fixed point value, casting them to int64_t to try to avoid overflow.
-
auto unsafe_multiplication(int value) const -> fixed_
size_ t constexpr - Returns the multiplication of this size by the given integer value.
-
auto unsafe_multiplication(fixed_
t<Precision> value) const -> fixed_ size_ t constexpr - Returns the multiplication of this size by the given fixed point value without trying to avoid overflow.
-
auto division(int value) const -> fixed_
size_ t constexpr - Returns the division of this size by the given integer value.
-
auto division(fixed_
t<Precision> value) const -> fixed_ size_ t constexpr - Returns the division of this size by the given fixed point value, using half precision to try to avoid overflow.
-
auto safe_division(int value) const -> fixed_
size_ t constexpr - Returns the division of this value by the given integer value.
-
auto safe_division(fixed_
t<Precision> value) const -> fixed_ size_ t constexpr - Returns the division of this size by the given fixed point value, casting them to int64_t to try to avoid overflow.
-
auto unsafe_division(int value) const -> fixed_
size_ t constexpr - Returns the division of this value by the given integer value.
-
auto unsafe_division(fixed_
t<Precision> value) const -> fixed_ size_ t constexpr - Returns the division of this size by the given fixed point value without trying to avoid overflow.
-
auto operator+=(const fixed_
size_ t& other) -> fixed_ size_ t& constexpr - Adds the given fixed_
size_ t to this one. -
auto operator-=(const fixed_
size_ t& other) -> fixed_ size_ t& constexpr - Subtracts the given fixed_
size_ t to this one. -
auto operator*=(int value) -> fixed_
size_ t& constexpr - Multiplies both width and height by the given factor.
-
auto operator*=(fixed_
t<Precision> value) -> fixed_ size_ t& constexpr - Multiplies both width and height by the given factor.
-
auto operator/=(int value) -> fixed_
size_ t& constexpr - Divides both width and height by the given divisor.
-
auto operator/=(fixed_
t<Precision> value) -> fixed_ size_ t& constexpr - Divides both width and height by the given divisor.
Friends
-
auto operator+(const fixed_
size_ t& a, const fixed_ size_ t& b) -> fixed_ size_ t constexpr - Returns the sum of a and b.
-
auto operator-(const fixed_
size_ t& a, const fixed_ size_ t& b) -> fixed_ size_ t constexpr - Returns b subtracted from a.
-
auto operator*(const fixed_
size_ t& a, int b) -> fixed_ size_ t constexpr - Returns a multiplied by b.
-
auto operator*(const fixed_
size_ t& a, fixed_ t<Precision> b) -> fixed_ size_ t constexpr - Returns a multiplied by b.
-
auto operator/(const fixed_
size_ t& a, int b) -> fixed_ size_ t constexpr - Returns a divided by b.
-
auto operator/(const fixed_
size_ t& a, fixed_ t<Precision> b) -> fixed_ size_ t constexpr - Returns a divided by b.
-
auto operator==(const fixed_
size_ t& a, const fixed_ size_ t& b) -> bool defaulted constexpr - Default equal operator.
Function documentation
template<int Precision>
bn:: fixed_size_t<Precision>:: fixed_size_t(fixed_ t<Precision> width,
fixed_ t<Precision> height) constexpr
Constructor.
Parameters | |
---|---|
width | Valid width (>= 0). |
height | Valid height (>= 0). |
template<int Precision>
bn:: fixed_size_t<Precision>:: fixed_size_t(const size& size) constexpr
Constructor.
Parameters | |
---|---|
size | Integer size. |
template<int Precision>
void bn:: fixed_size_t<Precision>:: set_height(fixed_ t<Precision> height) constexpr
Sets the height.
Parameters | |
---|---|
height | Valid height (>= 0). |
template<int Precision>
fixed_ size_ t& bn:: fixed_size_t<Precision>:: operator+=(const fixed_ size_ t& other) constexpr
Adds the given fixed_
Parameters | |
---|---|
other | fixed_ |
Returns | Reference to this. |
template<int Precision>
fixed_ size_ t& bn:: fixed_size_t<Precision>:: operator-=(const fixed_ size_ t& other) constexpr
Subtracts the given fixed_
Parameters | |
---|---|
other | fixed_ |
Returns | Reference to this. |
template<int Precision>
fixed_ size_ t& bn:: fixed_size_t<Precision>:: operator*=(int value) constexpr
Multiplies both width and height by the given factor.
Parameters | |
---|---|
value | Valid integer multiplication factor (>= 0). |
Returns | Reference to this. |
template<int Precision>
fixed_ size_ t& bn:: fixed_size_t<Precision>:: operator*=(fixed_ t<Precision> value) constexpr
Multiplies both width and height by the given factor.
Parameters | |
---|---|
value | Valid fixed point multiplication factor (>= 0). |
Returns | Reference to this. |
template<int Precision>
fixed_ size_ t& bn:: fixed_size_t<Precision>:: operator/=(int value) constexpr
Divides both width and height by the given divisor.
Parameters | |
---|---|
value | Valid integer divisor (> 0). |
Returns | Reference to this. |
template<int Precision>
fixed_ size_ t& bn:: fixed_size_t<Precision>:: operator/=(fixed_ t<Precision> value) constexpr
Divides both width and height by the given divisor.
Parameters | |
---|---|
value | Valid fixed point divisor (> 0). |
Returns | Reference to this. |