Rose
|
A position in integer (x, y) co-ordinates. More...
#include <Types.h>
Public Member Functions | |
template<typename O > | |
constexpr | Position (O X, O Y) noexcept |
constexpr | Position (const Position &p)=default |
constexpr | Position (Position &&p) noexcept=default |
constexpr Position & | operator= (const Position &p)=default |
constexpr Position & | operator= (Position &&p)=default |
constexpr | Position (T p) noexcept |
template<typename O > | |
constexpr Position | operator+ (const Position< O > &p) const noexcept |
Add two positions together. | |
template<typename O > | |
constexpr Position | operator- (const Position< O > &p) const noexcept |
Subtract position other from this. | |
template<typename O > | |
Position< O > | as () const |
Return this position after converting to type O. More... | |
bool | operator!= (const Position &other) const noexcept |
Inequality operator. | |
bool | operator== (const Position &other) const noexcept |
Equality operator. | |
bool | operator<= (const Position &other) const noexcept |
Less than or Equal to operator. | |
T & | primary (Orientation o) noexcept |
Access the primary component for a given Orientation. | |
T & | secondary (Orientation o) noexcept |
Access the secondary component for the given Orientation. | |
constexpr T | primary (Orientation o) const noexcept |
Return the primary component for a given Orientation. | |
constexpr T | secondary (Orientation o) const noexcept |
Return the secondary component for the given Orientation. | |
constexpr T | rSqr (const Position &other) const noexcept |
Compute the distance squared from this position to another. More... | |
void | swap () noexcept |
Swap the x and y components. | |
constexpr Position< T > | mirrorX () const noexcept |
Mirror Position on X axis. | |
constexpr Position< T > | mirrorY () const noexcept |
Mirror Position on Y axis. | |
constexpr | Position (std::array< int, 2 > value) noexcept |
Constructor initialize to the value of an array. | |
constexpr | Position (int value=0) noexcept |
Default constructor initializes x and y to 0 or to a specified value. | |
constexpr | Position (int x, int y) noexcept |
Constructor initialize to descrete x and y values. | |
constexpr | Position (const Position &)=default |
Copy constructor. | |
constexpr | Position (Position &&)=default |
Move constructor. | |
constexpr Position & | operator= (const Position &)=default |
Copy assignment. | |
constexpr Position & | operator= (Position &&)=default |
Move assignment. | |
constexpr int & | x () |
Reference access to x. | |
constexpr int | x () const noexcept |
Value access to x. | |
constexpr int & | y () |
Reference access to y. | |
constexpr int | y () const noexcept |
Value access to y. | |
int & | primary (Orientation orientation) |
Reference for primary axis value. More... | |
constexpr int | primary (Orientation orientation) const noexcept |
Value for primary axis value. More... | |
int & | secondary (Orientation orientation) |
Reference for secondary axis value. More... | |
constexpr int | secondary (Orientation orientation) const noexcept |
Value for secondary axis value. More... | |
constexpr Position | operator+ (const Position &position) const noexcept |
Addition operator. | |
constexpr Position | operator- (const Position &position) const noexcept |
Subtraction operator. | |
constexpr int | abs () const noexcept |
Compute the square of the scalar distance of a position from the origin. More... | |
Public Attributes | |
T | x {0} |
T | y {0} |
Static Public Attributes | |
static const Position | Zero = Position{} |
A zero position. | |
A position in integer (x, y) co-ordinates.
The position, or relative position of an object on the screen.
For screen objects (0, 0) is the top left corner, x increases to the right, y increases toward the bottom.
|
inlinenoexcept |
Compute the square of the scalar distance of a position from the origin.
This can be used on the difference of two positions to get the square of the scalar distance between the two positions.
Return this position after converting to type O.
O | The type of the returned values. |
|
inline |
Reference for primary axis value.
The primary access differs depending on the orientation
|
inlinenoexcept |
Value for primary axis value.
The primary access differs depending on the orientation
|
inlinenoexcept |
Compute the distance squared from this position to another.
other | The other position. |
|
inline |
Reference for secondary axis value.
The secondary access differs depending on the orientation
|
inlinenoexcept |
Value for secondary axis value.
The secondary access differs depending on the orientation