![]() |
Gorgon Game Engine
|
This class represents boundaries of 2D objects. More...
Public Types | |
typedef T_ | BaseType |
Base type of the bounds elements. More... | |
Public Member Functions | |
basic_Bounds () | |
Default constructor, does not zero initialize object. More... | |
template<class O_ > | |
basic_Bounds (const basic_Bounds< O_ > &r) | |
Conversion constructor that creates bounds from another type. More... | |
basic_Bounds (const basic_Point< T_ > &topleft, const basic_Point< T_ > &bottomright) | |
Constructs minimum bounds that includes the given points. More... | |
basic_Bounds (const basic_Point< T_ > &topleft, const basic_Size< T_ > &size) | |
Constructs bounds from the given coordinates and size. More... | |
basic_Bounds (const basic_Point< T_ > &topleft, const T_ &width, const T_ &height) | |
Constructs bounds from the given coordinates and size. More... | |
basic_Bounds (const std::string &str) | |
basic_Bounds (const T_ &left, const T_ &top, const basic_Size< T_ > &size) | |
Constructs bounds from the given coordinates and size. More... | |
basic_Bounds (const T_ &left, const T_ &top, const T_ &right, const T_ &bottom) | |
Constructor that allows coordinates to be specified individually. More... | |
basic_Point< T_ > | BottomLeft () const |
Returns bottom left corner. More... | |
basic_Point< T_ > | BottomRight () const |
Returns bottom right corner. More... | |
basic_Point< T_ > | Center () const |
Returns center of bounds. More... | |
basic_Size< T_ > | GetSize () const |
Returns the size of the bounds object. More... | |
T_ | Height () const |
Calculates and returns the height of the bounds. More... | |
void | Move (const basic_Point< T_ > &p) |
Changes the position of the bounds. More... | |
void | Move (const T_ &x, const T_ &y) |
Changes the position of the bounds. More... | |
void | Normalize () |
Normalizes bounds object so that Left and Right and Top and Bottom are ordered properly. More... | |
operator std::string () const | |
bool | operator!= (const basic_Bounds &other) |
Compares two bounds objects. More... | |
basic_Bounds | operator& (const basic_Bounds &r) const |
Performs intersect operation. More... | |
basic_Bounds & | operator&= (const basic_Bounds &b) const |
Performs intersect operation. More... | |
template<class O_ > | |
basic_Bounds | operator* (const basic_Size< O_ > &s) |
Creates a new bounds object that is the scaled version of this bounds by the given size. More... | |
template<class O_ > | |
basic_Bounds | operator* (const O_ &s) |
Creates a new bounds object that is the scale version of this bounds by the given size. More... | |
template<class O_ > | |
basic_Bounds & | operator*= (const basic_Size< O_ > &s) |
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}. More... | |
template<class O_ > | |
basic_Bounds & | operator*= (const O_ &s) |
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}. More... | |
basic_Bounds | operator+ (const basic_Point< T_ > &p) const |
Creates a new bounds object that is the offset of this bounds by the given point. More... | |
basic_Bounds | operator+ (const basic_Size< T_ > &s) const |
Creates a new bounds object that is larger by given size. More... | |
basic_Bounds & | operator+= (const basic_Point< T_ > &p) |
Offsets this bounds objects by the given coordinates. More... | |
basic_Bounds & | operator+= (const basic_Size< T_ > &s) |
Make this bounds larger by the given size. More... | |
basic_Bounds | operator- (const basic_Point< T_ > &p) const |
Creates a new bounds object that is the offset of this bounds by the given point. More... | |
basic_Bounds | operator- (const basic_Size< T_ > &s) const |
Creates a new bounds object that is smaller by given size the given point. More... | |
basic_Bounds & | operator-= (const basic_Point< T_ > &p) |
Offsets this bounds objects by the given coordinates. More... | |
basic_Bounds & | operator-= (const basic_Size< T_ > &s) |
Make this bounds smaller by the given size. More... | |
template<class O_ > | |
basic_Bounds | operator/ (const basic_Size< O_ > &s) |
Creates a new bounds object that is the scale version of this bounds by the given size. More... | |
template<class O_ > | |
basic_Bounds | operator/ (const O_ &s) |
Creates a new bounds object that is the scale version of this bounds by the given size. More... | |
template<class O_ > | |
basic_Bounds & | operator/= (const basic_Size< O_ > &s) |
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}. More... | |
template<class O_ > | |
basic_Bounds & | operator/= (const O_ &s) |
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}. More... | |
bool | operator== (const basic_Bounds &other) const |
Compares two bounds objects. More... | |
basic_Bounds | operator| (const basic_Bounds &r) const |
Performs union operation. More... | |
basic_Bounds & | operator|= (const basic_Bounds &b) const |
Performs union operation. More... | |
void | Resize (const basic_Size< T_ > &size) |
void | SetHeight (const T_ &height) |
Changes the height of the bounds, anchor is the topleft. More... | |
void | SetWidth (const T_ &width) |
Changes the width of the bounds, anchor is the topleft. More... | |
basic_Point< T_ > | TopLeft () const |
Returns top left corner. More... | |
basic_Point< T_ > | TopRight () const |
Returns top right corner. More... | |
T_ | Width () const |
Calculates and returns the width of the bounds. More... | |
Public Attributes | |
T_ | Bottom |
Bottom-most boundary. More... | |
T_ | Left |
Left-most boundary. More... | |
T_ | Right |
Right-most boundary. More... | |
T_ | Top |
Top-most boundary. More... | |
This class represents boundaries of 2D objects.
A bounds object contains the starting boundary but not the ending boundary. Therefore, a bounds that has a Width() of 100 and Left of 0, has Right value as 100, not 99.
A Bounds object that has Left<Right and Top<Bottom is called normalized. Bounds should be normalized for its methods to work properly. Constructors normalizes input values, most methods leave bounds in normal state.
typedef T_ BaseType |
Base type of the bounds elements.
basic_Bounds | ( | ) |
Default constructor, does not zero initialize object.
basic_Bounds | ( | const T_ & | left, |
const T_ & | top, | ||
const T_ & | right, | ||
const T_ & | bottom | ||
) |
Constructor that allows coordinates to be specified individually.
Performs normalization therefore, left could be larger than right or top could be larger than bottom.
References basic_Bounds< T_ >::Normalize().
basic_Bounds | ( | const basic_Point< T_ > & | topleft, |
const basic_Point< T_ > & | bottomright | ||
) |
Constructs minimum bounds that includes the given points.
References basic_Bounds< T_ >::Normalize().
basic_Bounds | ( | const basic_Point< T_ > & | topleft, |
const basic_Size< T_ > & | size | ||
) |
Constructs bounds from the given coordinates and size.
References basic_Bounds< T_ >::Normalize().
basic_Bounds | ( | const T_ & | left, |
const T_ & | top, | ||
const basic_Size< T_ > & | size | ||
) |
Constructs bounds from the given coordinates and size.
References basic_Bounds< T_ >::Normalize().
basic_Bounds | ( | const basic_Point< T_ > & | topleft, |
const T_ & | width, | ||
const T_ & | height | ||
) |
Constructs bounds from the given coordinates and size.
References basic_Bounds< T_ >::Normalize().
|
explicit |
Conversion constructor that creates bounds from another type.
|
explicit |
basic_Point<T_> BottomLeft | ( | ) | const |
Returns bottom left corner.
References basic_Bounds< T_ >::Bottom, and basic_Bounds< T_ >::Left.
basic_Point<T_> BottomRight | ( | ) | const |
Returns bottom right corner.
References basic_Bounds< T_ >::Bottom, and basic_Bounds< T_ >::Right.
basic_Point<T_> Center | ( | ) | const |
Returns center of bounds.
References basic_Bounds< T_ >::Height(), basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Top, and basic_Bounds< T_ >::Width().
basic_Size<T_> GetSize | ( | ) | const |
Returns the size of the bounds object.
References basic_Bounds< T_ >::Height(), and basic_Bounds< T_ >::Width().
T_ Height | ( | ) | const |
Calculates and returns the height of the bounds.
References basic_Bounds< T_ >::Bottom, and basic_Bounds< T_ >::Top.
void Move | ( | const basic_Point< T_ > & | p | ) |
Changes the position of the bounds.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, basic_Point< T_ >::X, and basic_Point< T_ >::Y.
void Move | ( | const T_ & | x, |
const T_ & | y | ||
) |
Changes the position of the bounds.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
void Normalize | ( | ) |
Normalizes bounds object so that Left and Right and Top and Bottom are ordered properly.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, Gorgon::swap(), Gorgon::Geometry::swap(), and basic_Bounds< T_ >::Top.
|
explicit |
bool operator!= | ( | const basic_Bounds< T_ > & | other | ) |
Compares two bounds objects.
References basic_Bounds< T_ >::operator==().
basic_Bounds operator& | ( | const basic_Bounds< T_ > & | r | ) | const |
Performs intersect operation.
Returns a bounds that contains the region that this bounds and the given bounds covers. If they do not interact, an empty bounds <0-0, 0-0> is returned.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
basic_Bounds& operator&= | ( | const basic_Bounds< T_ > & | b | ) | const |
Performs intersect operation.
Returns a bounds that contains the region that this bounds and the given bounds covers. If they do not interact, an empty bounds <0-0, 0-0> is returned.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
basic_Bounds operator* | ( | const basic_Size< O_ > & | s | ) |
Creates a new bounds object that is the scaled version of this bounds by the given size.
Origin of the operation is {0, 0}
References basic_Bounds< T_ >::Bottom, basic_Size< T_ >::Height, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, and basic_Size< T_ >::Width.
basic_Bounds operator* | ( | const O_ & | s | ) |
Creates a new bounds object that is the scale version of this bounds by the given size.
Origin of the operation is {0, 0}
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
basic_Bounds& operator*= | ( | const basic_Size< O_ > & | s | ) |
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}.
References basic_Bounds< T_ >::Bottom, basic_Size< T_ >::Height, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, and basic_Size< T_ >::Width.
basic_Bounds& operator*= | ( | const O_ & | s | ) |
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
basic_Bounds operator+ | ( | const basic_Point< T_ > & | p | ) | const |
Creates a new bounds object that is the offset of this bounds by the given point.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, basic_Point< T_ >::X, and basic_Point< T_ >::Y.
basic_Bounds operator+ | ( | const basic_Size< T_ > & | s | ) | const |
Creates a new bounds object that is larger by given size.
References basic_Bounds< T_ >::Bottom, basic_Size< T_ >::Height, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, and basic_Size< T_ >::Width.
basic_Bounds& operator+= | ( | const basic_Point< T_ > & | p | ) |
Offsets this bounds objects by the given coordinates.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, basic_Point< T_ >::X, and basic_Point< T_ >::Y.
basic_Bounds& operator+= | ( | const basic_Size< T_ > & | s | ) |
Make this bounds larger by the given size.
References basic_Bounds< T_ >::Bottom, basic_Size< T_ >::Height, basic_Bounds< T_ >::Right, and basic_Size< T_ >::Width.
basic_Bounds operator- | ( | const basic_Point< T_ > & | p | ) | const |
Creates a new bounds object that is the offset of this bounds by the given point.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, basic_Point< T_ >::X, and basic_Point< T_ >::Y.
basic_Bounds operator- | ( | const basic_Size< T_ > & | s | ) | const |
Creates a new bounds object that is smaller by given size the given point.
References basic_Bounds< T_ >::Bottom, basic_Size< T_ >::Height, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, and basic_Size< T_ >::Width.
basic_Bounds& operator-= | ( | const basic_Point< T_ > & | p | ) |
Offsets this bounds objects by the given coordinates.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, basic_Point< T_ >::X, and basic_Point< T_ >::Y.
basic_Bounds& operator-= | ( | const basic_Size< T_ > & | s | ) |
Make this bounds smaller by the given size.
References basic_Bounds< T_ >::Bottom, basic_Size< T_ >::Height, basic_Bounds< T_ >::Right, and basic_Size< T_ >::Width.
basic_Bounds operator/ | ( | const basic_Size< O_ > & | s | ) |
Creates a new bounds object that is the scale version of this bounds by the given size.
Origin of the operation is {0, 0}
References basic_Bounds< T_ >::Bottom, basic_Size< T_ >::Height, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, and basic_Size< T_ >::Width.
basic_Bounds operator/ | ( | const O_ & | s | ) |
Creates a new bounds object that is the scale version of this bounds by the given size.
Origin of the operation is {0, 0}
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
basic_Bounds& operator/= | ( | const basic_Size< O_ > & | s | ) |
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}.
References basic_Bounds< T_ >::Bottom, basic_Size< T_ >::Height, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, and basic_Size< T_ >::Width.
basic_Bounds& operator/= | ( | const O_ & | s | ) |
Resizes this bounds objects by the given size. Origin of the operation is {0, 0}.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
bool operator== | ( | const basic_Bounds< T_ > & | other | ) | const |
Compares two bounds objects.
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
basic_Bounds operator| | ( | const basic_Bounds< T_ > & | r | ) | const |
Performs union operation.
Returns a bounds that contains this bounds object as well as the given bounds
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
basic_Bounds& operator|= | ( | const basic_Bounds< T_ > & | b | ) | const |
Performs union operation.
Returns a bounds that contains this bounds object as well as the given bounds
References basic_Bounds< T_ >::Bottom, basic_Bounds< T_ >::Left, basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
void Resize | ( | const basic_Size< T_ > & | size | ) |
void SetHeight | ( | const T_ & | height | ) |
Changes the height of the bounds, anchor is the topleft.
References basic_Bounds< T_ >::Bottom, and basic_Bounds< T_ >::Top.
void SetWidth | ( | const T_ & | width | ) |
Changes the width of the bounds, anchor is the topleft.
References basic_Bounds< T_ >::Left, and basic_Bounds< T_ >::Right.
basic_Point<T_> TopLeft | ( | ) | const |
Returns top left corner.
References basic_Bounds< T_ >::Left, and basic_Bounds< T_ >::Top.
basic_Point<T_> TopRight | ( | ) | const |
Returns top right corner.
References basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.
T_ Width | ( | ) | const |
Calculates and returns the width of the bounds.
References basic_Bounds< T_ >::Left, and basic_Bounds< T_ >::Right.
T_ Bottom |
Bottom-most boundary.
T_ Left |
Left-most boundary.
T_ Right |
Right-most boundary.
T_ Top |
Top-most boundary.