41 #include "CUMathBase.h"
69 #pragma mark Constructors
77 Size() : width(0), height(0) {}
86 Size(
float width,
float height) {
97 Size(
const float* array) { width = array[0]; height = array[1]; }
158 this->width = array[0]; this->height = array[1];
170 this->width = other.
width; this->height = other.
height;
176 #pragma mark Integer Access
198 #pragma mark Comparisons
266 return width == other.
width && height == other.
height;
280 return width != other.
width || height != other.
height;
294 return width <= other.
width && height <= other.
height;
308 return width >= other.
width && height >= other.
height;
321 bool equals(
const Size& other,
float variance=CU_MATH_EPSILON)
const {
322 float dx = width-other.
width;
323 float dy = height-other.
height;
324 return ((-variance < dx && dx < variance) &&
325 (-variance < dy && dy < variance));
330 #pragma mark Operators
364 width *= a; height *= a;
470 #pragma mark Conversion Methods
482 std::string
toString(
bool verbose =
false)
const;
485 operator std::string()
const {
return toString(); }
488 operator Vec2()
const;
Size operator+(const Size &right) const
Definition: CUSize.h:409
bool operator==(const Size &other) const
Definition: CUSize.h:265
Size & operator*=(const Size &right)
Definition: CUSize.h:375
Size & set(float width, float height)
Definition: CUSize.h:143
bool operator<(const Size &v) const
Definition: CUSize.h:209
bool operator>=(const Size &v) const
Definition: CUSize.h:251
Size operator/(float scalar) const
Definition: CUSize.h:454
Size operator*(float scalar) const
Definition: CUSize.h:431
int getIWidth() const
Definition: CUSize.h:185
bool operator!=(const Size &other) const
Definition: CUSize.h:279
Size & set(const Size &other)
Definition: CUSize.h:169
Size & operator=(const Size &other)
Definition: CUSize.h:118
static const Size ZERO
Definition: CUSize.h:66
Size()
Definition: CUSize.h:77
Size(float width, float height)
Definition: CUSize.h:86
int getIHeight() const
Definition: CUSize.h:194
Size & set(const float *array)
Definition: CUSize.h:157
Size & operator/=(float a)
float width
Definition: CUSize.h:61
bool inside(const Size &other) const
Definition: CUSize.h:293
Size(const Size &other)
Definition: CUSize.h:104
float height
Definition: CUSize.h:63
Size operator*(const Size &right) const
Definition: CUSize.h:443
Size & operator*=(float a)
Definition: CUSize.h:363
bool operator>(const Size &v) const
Definition: CUSize.h:237
Size & operator+=(const Size &right)
Definition: CUSize.h:339
bool contains(const Size &other) const
Definition: CUSize.h:307
Size operator-(const Size &right) const
Definition: CUSize.h:420
Size operator/(const Size &right) const
Definition: CUSize.h:466
std::string toString(bool verbose=false) const
Size(const float *array)
Definition: CUSize.h:97
Definition: CUAnimationNode.h:52
bool operator<=(const Size &v) const
Definition: CUSize.h:223
Size & operator-=(const Size &right)
Definition: CUSize.h:351
bool equals(const Size &other, float variance=CU_MATH_EPSILON) const
Definition: CUSize.h:321