![]() |
Gorgon Game Engine
|
This class represents a 2D geometric size. More...
Public Types | |
| typedef T_ | BaseType |
| Base type of the size elements. More... | |
Public Member Functions | |
| basic_Size () | |
| Default constructor. More... | |
| basic_Size (const basic_Point< T_ > &point) | |
| Converts a point to size object. More... | |
| template<class O_ > | |
| basic_Size (const basic_Size< O_ > &size) | |
| Converting constructor. More... | |
| basic_Size (const std::string &str) | |
| Conversion from string. More... | |
| basic_Size (const T_ &s) | |
| Filling constructor. More... | |
| basic_Size (const T_ &w, const T_ &h) | |
| Filling constructor. More... | |
| T_ | Area () const |
| Returns the exact area of the rectangle has the size of this object. More... | |
| T_ | Cells () const |
| Returns the number of fully encompassed cells. More... | |
| bool | IsValid () const |
| Returns whether the size is valid, i.e. both dimensions are positive. More... | |
| operator basic_Point< T_ > () const | |
| Converts this size object to a point. More... | |
| operator std::string () const | |
| Converts this object to string. More... | |
| bool | operator!= (const basic_Size &size) const |
| Compares two size objects. More... | |
| template<class _S > | |
| basic_Size | operator*= (_S size) |
| Multiplies this size object with the given factor. More... | |
| template<class O_ > | |
| basic_Size | operator+ (const basic_Size< O_ > &size) const |
| Adds two size objects. More... | |
| template<class O_ > | |
| basic_Size & | operator+= (const basic_Size< O_ > &size) |
| Adds the given size object to this size. More... | |
| basic_Size | operator- () const |
| Negation operator. More... | |
| template<class O_ > | |
| basic_Size | operator- (const basic_Size< O_ > &size) const |
| Subtracts two size objects. More... | |
| template<class O_ > | |
| basic_Size & | operator-= (const basic_Size< O_ > &size) |
| Subtracts the given size object from this size. More... | |
| template<class _S > | |
| basic_Size | operator/= (_S size) |
| Divides this size object to the given factor. More... | |
| template<class O_ > | |
| basic_Size & | operator= (const basic_Point< O_ > &point) |
| Converting assignment operator. More... | |
| template<class O_ > | |
| basic_Size & | operator= (const basic_Size< O_ > &size) |
| Converting assignment operator. More... | |
| bool | operator== (const basic_Size &size) const |
| Compares two size objects. More... | |
Static Public Member Functions | |
| static basic_Size | Max () |
| Returns the maximum representable size. More... | |
| static basic_Size | Parse (const std::string &str) |
| Properly parses given string into a size. More... | |
Public Attributes | |
| T_ | Height |
| Height of this size object. More... | |
| T_ | Width |
| Width of this size object. More... | |
This class represents a 2D geometric size.
Although negative size is meaningless, this class allows all operations over negative sizes.
| typedef T_ BaseType |
Base type of the size elements.
| basic_Size | ( | ) |
Default constructor.
This constructor does not zero initialize the object.
|
explicit |
Filling constructor.
This variant assigns the given value to both dimensions, effectively creating a square.
| basic_Size | ( | const T_ & | w, |
| const T_ & | h | ||
| ) |
Filling constructor.
| basic_Size | ( | const basic_Size< O_ > & | size | ) |
Converting constructor.
Converts a different typed size object to this type.
|
explicit |
Converts a point to size object.
The size a point represents is the size of the rectangle that starts from origin to the given point.
|
explicit |
Conversion from string.
| T_ Area | ( | ) | const |
Returns the exact area of the rectangle has the size of this object.
| T_ Cells | ( | ) | const |
Returns the number of fully encompassed cells.
For instance, a 3.2x2.2 size object has 6 cells.
| bool IsValid | ( | ) | const |
Returns whether the size is valid, i.e. both dimensions are positive.
|
static |
Returns the maximum representable size.
This function requires T_ to be standard arithmetic type
|
explicit |
Converts this size object to a point.
Conversion is performed in a manner that the resultant point is the far corner of a rectangle that is placed at origin and the size of this object.
References basic_Size< T_ >::Height, and basic_Size< T_ >::Width.
|
explicit |
Converts this object to string.
| bool operator!= | ( | const basic_Size< T_ > & | size | ) | const |
Compares two size objects.
| basic_Size operator*= | ( | _S | size | ) |
Multiplies this size object with the given factor.
| basic_Size operator+ | ( | const basic_Size< O_ > & | size | ) | const |
Adds two size objects.
| basic_Size& operator+= | ( | const basic_Size< O_ > & | size | ) |
Adds the given size object to this size.
| basic_Size operator- | ( | ) | const |
Negation operator.
| basic_Size operator- | ( | const basic_Size< O_ > & | size | ) | const |
Subtracts two size objects.
| basic_Size& operator-= | ( | const basic_Size< O_ > & | size | ) |
Subtracts the given size object from this size.
| basic_Size operator/= | ( | _S | size | ) |
Divides this size object to the given factor.
| basic_Size& operator= | ( | const basic_Point< O_ > & | point | ) |
Converting assignment operator.
The size a point represents is the size of the rectangle that starts from origin to the given point.
| basic_Size& operator= | ( | const basic_Size< O_ > & | size | ) |
Converting assignment operator.
| bool operator== | ( | const basic_Size< T_ > & | size | ) | const |
Compares two size objects.
|
static |
Properly parses given string into a size.
Throws errors if the size is not well formed. Works only on types that can be parsed using strtod. Following error codes are reported by this parse function:
| T_ Height |
Height of this size object.
| T_ Width |
Width of this size object.