Gorgon Game Engine
basic_Bounds< T_ > Class Template Reference

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_Boundsoperator&= (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_Boundsoperator*= (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_Boundsoperator*= (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_Boundsoperator+= (const basic_Point< T_ > &p)
 Offsets this bounds objects by the given coordinates. More...
 
basic_Boundsoperator+= (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_Boundsoperator-= (const basic_Point< T_ > &p)
 Offsets this bounds objects by the given coordinates. More...
 
basic_Boundsoperator-= (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_Boundsoperator/= (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_Boundsoperator/= (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_Boundsoperator|= (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...
 

Detailed Description

template<class T_>
class Gorgon::Geometry::basic_Bounds< T_ >

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.

Member Typedef Documentation

◆ BaseType

typedef T_ BaseType

Base type of the bounds elements.

Constructor & Destructor Documentation

◆ basic_Bounds() [1/8]

Default constructor, does not zero initialize object.

◆ basic_Bounds() [2/8]

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() [3/8]

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() [4/8]

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() [5/8]

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() [6/8]

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().

◆ basic_Bounds() [7/8]

basic_Bounds ( const basic_Bounds< O_ > &  r)
explicit

Conversion constructor that creates bounds from another type.

◆ basic_Bounds() [8/8]

basic_Bounds ( const std::string &  str)
explicit

Member Function Documentation

◆ BottomLeft()

basic_Point<T_> BottomLeft ( ) const

Returns bottom left corner.

References basic_Bounds< T_ >::Bottom, and basic_Bounds< T_ >::Left.

◆ BottomRight()

basic_Point<T_> BottomRight ( ) const

Returns bottom right corner.

References basic_Bounds< T_ >::Bottom, and basic_Bounds< T_ >::Right.

◆ Center()

◆ GetSize()

basic_Size<T_> GetSize ( ) const

Returns the size of the bounds object.

References basic_Bounds< T_ >::Height(), and basic_Bounds< T_ >::Width().

◆ Height()

T_ Height ( ) const

Calculates and returns the height of the bounds.

References basic_Bounds< T_ >::Bottom, and basic_Bounds< T_ >::Top.

◆ Move() [1/2]

◆ Move() [2/2]

void Move ( const T_ &  x,
const T_ &  y 
)

◆ Normalize()

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.

◆ operator std::string()

◆ operator!=()

bool operator!= ( const basic_Bounds< T_ > &  other)

Compares two bounds objects.

References basic_Bounds< T_ >::operator==().

◆ 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.

◆ operator&=()

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.

◆ operator*() [1/2]

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.

◆ operator*() [2/2]

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.

◆ operator*=() [1/2]

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.

◆ operator*=() [2/2]

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.

◆ operator+() [1/2]

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.

◆ operator+() [2/2]

basic_Bounds operator+ ( const basic_Size< T_ > &  s) const

◆ operator+=() [1/2]

basic_Bounds& operator+= ( const basic_Point< T_ > &  p)

◆ operator+=() [2/2]

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.

◆ operator-() [1/2]

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.

◆ operator-() [2/2]

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.

◆ operator-=() [1/2]

basic_Bounds& operator-= ( const basic_Point< T_ > &  p)

◆ operator-=() [2/2]

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.

◆ operator/() [1/2]

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.

◆ operator/() [2/2]

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.

◆ operator/=() [1/2]

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.

◆ operator/=() [2/2]

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.

◆ operator==()

bool operator== ( const basic_Bounds< T_ > &  other) const

◆ operator|()

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.

◆ operator|=()

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.

◆ Resize()

◆ SetHeight()

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.

◆ SetWidth()

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.

◆ TopLeft()

basic_Point<T_> TopLeft ( ) const

Returns top left corner.

References basic_Bounds< T_ >::Left, and basic_Bounds< T_ >::Top.

◆ TopRight()

basic_Point<T_> TopRight ( ) const

Returns top right corner.

References basic_Bounds< T_ >::Right, and basic_Bounds< T_ >::Top.

◆ Width()

T_ Width ( ) const

Calculates and returns the width of the bounds.

References basic_Bounds< T_ >::Left, and basic_Bounds< T_ >::Right.

Member Data Documentation

◆ Bottom

T_ Bottom

Bottom-most boundary.

◆ Left

T_ Left

Left-most boundary.

◆ Right

T_ Right

Right-most boundary.

◆ Top

T_ Top

Top-most boundary.


The documentation for this class was generated from the following file: