Gorgon Game Engine
basic_Rectangle< T_ > Class Template Reference

Represents a rectangle in a 2D space. More...

Public Types

typedef T_ BaseType
 Base type of the rectangle elements. More...
 

Public Member Functions

 basic_Rectangle ()
 Default constructor, does not initialize stored values. More...
 
template<class O_ >
 basic_Rectangle (const basic_Bounds< O_ > &bounds)
 Converting constructor from bounds. More...
 
 basic_Rectangle (const basic_Point< T_ > &position, const basic_Size< T_ > &size)
 Filling constructor using values for top left corner and size. More...
 
 basic_Rectangle (const basic_Point< T_ > &position, T_ width, T_ height)
 Filling constructor using values for top left corner and size. More...
 
 basic_Rectangle (const basic_Point< T_ > &topleft, const basic_Point< T_ > &bottomright)
 Filling constructor using values for top left and bottom right corners. More...
 
template<class O_ >
 basic_Rectangle (const basic_Rectangle< O_ > &rect)
 Converting constructor from a different typed rectangle. More...
 
 basic_Rectangle (const std::string &str)
 Conversion from string. More...
 
 basic_Rectangle (const T_ &left, const T_ &top, const basic_Size< T_ > &size)
 Filling constructor using values for top left corner and size. More...
 
 basic_Rectangle (const T_ &left, const T_ &top, const T_ &width, const T_ &height)
 Filling constructor using values for top left corner and size. More...
 
T_ Bottom () const
 Calculates and returns the bottommost coordinate. More...
 
basic_Point< T_ > BottomLeft () const
 Returns the bottom left coordinates of the rectangle. More...
 
basic_Point< T_ > BottomRight () const
 Returns the bottom right coordinates of the rectangle. More...
 
basic_Point< T_ > Center () const
 Returns the center point of the rectangle. More...
 
basic_Size< T_ > GetSize () const
 Returns the size of the rectangle. More...
 
void Move (const basic_Point< T_ > &p)
 Changes the position of the rectangle. More...
 
void Move (const T_ &x, const T_ &y)
 Changes the position of the rectangle. More...
 
template<class O_ >
 operator basic_Bounds< O_ > () const
 Conversion to bounds. More...
 
 operator std::string () const
 Conversion to string. More...
 
bool operator!= (const basic_Rectangle &r) const
 Compares two rectangles. More...
 
template<class O_ >
basic_Rectangle operator* (const basic_Size< O_ > &amount) const
 Scales this rectangle with the given size. More...
 
template<class O_ >
basic_Rectangle operator* (const O_ &amount) const
 Scales this rectangle with the given value. More...
 
template<class O_ >
basic_Rectangleoperator*= (const basic_Size< O_ > &amount)
 Scales this rectangle with the given size. More...
 
template<class O_ >
basic_Rectangleoperator*= (const O_ &amount)
 Scales this rectangle with the given value. More...
 
basic_Rectangle operator+ (const basic_Point< T_ > &amount) const
 Adds a point to this rectangle, effectively translating it. More...
 
basic_Rectangle operator+ (const basic_Size< T_ > &amount) const
 Adds a size to this rectangle, resizing it. More...
 
basic_Rectangleoperator+= (const basic_Point< T_ > &amount)
 Adds a point to this rectangle, effectively translating it. More...
 
basic_Rectangleoperator+= (const basic_Size< T_ > &amount)
 Adds a size to this rectangle, resizing it. More...
 
basic_Rectangle operator- (const basic_Point< T_ > &amount) const
 Subtracts a point from this rectangle, effectively translating it. More...
 
basic_Rectangle operator- (const basic_Size< T_ > &amount) const
 Subtracts a size from this rectangle, resizing it. More...
 
basic_Rectangleoperator-= (const basic_Point< T_ > &amount)
 Subtracts a point to this rectangle, effectively translating it. More...
 
basic_Rectangleoperator-= (const basic_Size< T_ > &amount)
 Subtracts a size from this rectangle, resizing it. More...
 
template<class O_ >
basic_Rectangle operator/ (const basic_Size< O_ > &amount) const
 Scales this rectangle with the given size. More...
 
template<class O_ >
basic_Rectangle operator/ (const O_ &amount) const
 Scales this rectangle with the given value. More...
 
template<class O_ >
basic_Rectangleoperator/= (const basic_Size< O_ > &amount)
 Scales this rectangle with the given size. More...
 
template<class O_ >
basic_Rectangleoperator/= (const O_ &amount)
 Scales this rectangle with the given value. More...
 
bool operator== (const basic_Rectangle &r) const
 Compares two rectangles. More...
 
void Resize (const basic_Size< T_ > &s)
 Resizes the rectangle. More...
 
void Resize (const T_ &w, const T_ &h)
 Resizes the rectangle. More...
 
T_ Right () const
 Calculates and returns the rightmost coordinate. More...
 
void SetBottom (const T_ &bottom)
 Moves the rectangle by changing its bottommost coordinate. More...
 
void SetRight (const T_ &right)
 Moves the rectangle by changing its rightmost coordinate. More...
 
basic_Point< T_ > TopLeft () const
 Returns the top left coordinates of the rectangle. More...
 
basic_Point< T_ > TopRight () const
 Returns the top right coordinates of the rectangle. More...
 

Static Public Member Functions

static basic_Rectangle Parse (std::string s)
 Properly parses a rectangle, throwing errors when necessary. More...
 

Public Attributes

T_ Height
 Height of the rectangle. More...
 
T_ Width
 Width of the rectangle. More...
 
T_ X
 X coordinate of the top left corner of this rectangle. More...
 
T_ Y
 Y coordinate of the top left corner of this rectangle. More...
 

Detailed Description

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

Represents a rectangle in a 2D space.

Top left corner and the size is stored.

Member Typedef Documentation

◆ BaseType

typedef T_ BaseType

Base type of the rectangle elements.

Constructor & Destructor Documentation

◆ basic_Rectangle() [1/9]

Default constructor, does not initialize stored values.

◆ basic_Rectangle() [2/9]

basic_Rectangle ( const T_ &  left,
const T_ &  top,
const T_ &  width,
const T_ &  height 
)

Filling constructor using values for top left corner and size.

◆ basic_Rectangle() [3/9]

basic_Rectangle ( const basic_Point< T_ > &  position,
const basic_Size< T_ > &  size 
)

Filling constructor using values for top left corner and size.

◆ basic_Rectangle() [4/9]

basic_Rectangle ( const T_ &  left,
const T_ &  top,
const basic_Size< T_ > &  size 
)

Filling constructor using values for top left corner and size.

◆ basic_Rectangle() [5/9]

basic_Rectangle ( const basic_Point< T_ > &  position,
T_  width,
T_  height 
)

Filling constructor using values for top left corner and size.

◆ basic_Rectangle() [6/9]

basic_Rectangle ( const basic_Point< T_ > &  topleft,
const basic_Point< T_ > &  bottomright 
)

Filling constructor using values for top left and bottom right corners.

◆ basic_Rectangle() [7/9]

basic_Rectangle ( const basic_Rectangle< O_ > &  rect)

Converting constructor from a different typed rectangle.

◆ basic_Rectangle() [8/9]

basic_Rectangle ( const basic_Bounds< O_ > &  bounds)

Converting constructor from bounds.

◆ basic_Rectangle() [9/9]

basic_Rectangle ( const std::string &  str)
explicit

Member Function Documentation

◆ Bottom()

T_ Bottom ( ) const

Calculates and returns the bottommost coordinate.

References basic_Rectangle< T_ >::Height, and basic_Rectangle< T_ >::Y.

◆ BottomLeft()

basic_Point<T_> BottomLeft ( ) const

Returns the bottom left coordinates of the rectangle.

References basic_Rectangle< T_ >::Height, basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

◆ BottomRight()

basic_Point<T_> BottomRight ( ) const

Returns the bottom right coordinates of the rectangle.

References basic_Rectangle< T_ >::Height, basic_Rectangle< T_ >::Width, basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

◆ Center()

basic_Point<T_> Center ( ) const

◆ GetSize()

basic_Size<T_> GetSize ( ) const

Returns the size of the rectangle.

References basic_Rectangle< T_ >::Height, and basic_Rectangle< T_ >::Width.

◆ Move() [1/2]

void Move ( const basic_Point< T_ > &  p)

Changes the position of the rectangle.

References basic_Point< T_ >::X, basic_Rectangle< T_ >::X, basic_Point< T_ >::Y, and basic_Rectangle< T_ >::Y.

◆ Move() [2/2]

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

Changes the position of the rectangle.

References basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

◆ operator basic_Bounds< O_ >()

operator basic_Bounds< O_ > ( ) const

◆ operator std::string()

operator std::string ( ) const
explicit

◆ operator!=()

bool operator!= ( const basic_Rectangle< T_ > &  r) const

◆ operator*() [1/2]

basic_Rectangle operator* ( const basic_Size< O_ > &  amount) const

Scales this rectangle with the given size.

Origin of this operation is top left point of the rectangle.

References basic_Rectangle< T_ >::Height, basic_Size< T_ >::Height, basic_Rectangle< T_ >::Width, basic_Size< T_ >::Width, basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

◆ operator*() [2/2]

basic_Rectangle operator* ( const O_ &  amount) const

Scales this rectangle with the given value.

Origin of this operation is top left point of the rectangle.

References basic_Rectangle< T_ >::Height, basic_Rectangle< T_ >::Width, basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

◆ operator*=() [1/2]

basic_Rectangle& operator*= ( const basic_Size< O_ > &  amount)

Scales this rectangle with the given size.

Origin of this operation is top left point of the rectangle.

References basic_Rectangle< T_ >::Height, basic_Size< T_ >::Height, basic_Rectangle< T_ >::Width, and basic_Size< T_ >::Width.

◆ operator*=() [2/2]

basic_Rectangle& operator*= ( const O_ &  amount)

Scales this rectangle with the given value.

Origin of this operation is top left point of the rectangle.

References basic_Rectangle< T_ >::Height, and basic_Rectangle< T_ >::Width.

◆ operator+() [1/2]

basic_Rectangle operator+ ( const basic_Point< T_ > &  amount) const

◆ operator+() [2/2]

◆ operator+=() [1/2]

basic_Rectangle& operator+= ( const basic_Point< T_ > &  amount)

Adds a point to this rectangle, effectively translating it.

References basic_Point< T_ >::X, basic_Rectangle< T_ >::X, basic_Point< T_ >::Y, and basic_Rectangle< T_ >::Y.

◆ operator+=() [2/2]

basic_Rectangle& operator+= ( const basic_Size< T_ > &  amount)

◆ operator-() [1/2]

basic_Rectangle operator- ( const basic_Point< T_ > &  amount) const

◆ operator-() [2/2]

basic_Rectangle operator- ( const basic_Size< T_ > &  amount) const

◆ operator-=() [1/2]

basic_Rectangle& operator-= ( const basic_Point< T_ > &  amount)

Subtracts a point to this rectangle, effectively translating it.

References basic_Point< T_ >::X, basic_Rectangle< T_ >::X, basic_Point< T_ >::Y, and basic_Rectangle< T_ >::Y.

◆ operator-=() [2/2]

basic_Rectangle& operator-= ( const basic_Size< T_ > &  amount)

Subtracts a size from this rectangle, resizing it.

References basic_Rectangle< T_ >::Height, basic_Size< T_ >::Height, basic_Rectangle< T_ >::Width, and basic_Size< T_ >::Width.

◆ operator/() [1/2]

basic_Rectangle operator/ ( const basic_Size< O_ > &  amount) const

Scales this rectangle with the given size.

Origin of this operation is top left point of the rectangle.

References basic_Rectangle< T_ >::Height, basic_Size< T_ >::Height, basic_Rectangle< T_ >::Width, basic_Size< T_ >::Width, basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

◆ operator/() [2/2]

basic_Rectangle operator/ ( const O_ &  amount) const

Scales this rectangle with the given value.

Origin of this operation is top left point of the rectangle.

References basic_Rectangle< T_ >::Height, basic_Rectangle< T_ >::Width, basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

◆ operator/=() [1/2]

basic_Rectangle& operator/= ( const basic_Size< O_ > &  amount)

Scales this rectangle with the given size.

Origin of this operation is top left point of the rectangle.

References basic_Rectangle< T_ >::Height, basic_Size< T_ >::Height, basic_Rectangle< T_ >::Width, and basic_Size< T_ >::Width.

◆ operator/=() [2/2]

basic_Rectangle& operator/= ( const O_ &  amount)

Scales this rectangle with the given value.

Origin of this operation is top left point of the rectangle.

References basic_Rectangle< T_ >::Height, and basic_Rectangle< T_ >::Width.

◆ operator==()

bool operator== ( const basic_Rectangle< T_ > &  r) const

◆ Parse()

static basic_Rectangle Parse ( std::string  s)
static

Properly parses a rectangle, throwing errors when necessary.

TODO Needs to be fixed

References basic_Rectangle< T_ >::Height, and basic_Rectangle< T_ >::Width.

◆ Resize() [1/2]

void Resize ( const basic_Size< T_ > &  s)

◆ Resize() [2/2]

void Resize ( const T_ &  w,
const T_ &  h 
)

Resizes the rectangle.

References basic_Rectangle< T_ >::Height, and basic_Rectangle< T_ >::Width.

◆ Right()

T_ Right ( ) const

Calculates and returns the rightmost coordinate.

References basic_Rectangle< T_ >::Width, and basic_Rectangle< T_ >::X.

◆ SetBottom()

void SetBottom ( const T_ &  bottom)

Moves the rectangle by changing its bottommost coordinate.

References basic_Rectangle< T_ >::Height, and basic_Rectangle< T_ >::Y.

◆ SetRight()

void SetRight ( const T_ &  right)

Moves the rectangle by changing its rightmost coordinate.

References basic_Rectangle< T_ >::Width, and basic_Rectangle< T_ >::X.

◆ TopLeft()

basic_Point<T_> TopLeft ( ) const

Returns the top left coordinates of the rectangle.

References basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

◆ TopRight()

basic_Point<T_> TopRight ( ) const

Returns the top right coordinates of the rectangle.

References basic_Rectangle< T_ >::Width, basic_Rectangle< T_ >::X, and basic_Rectangle< T_ >::Y.

Member Data Documentation

◆ Height

T_ Height

Height of the rectangle.

◆ Width

T_ Width

Width of the rectangle.

◆ X

T_ X

X coordinate of the top left corner of this rectangle.

◆ Y

T_ Y

Y coordinate of the top left corner of this rectangle.


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