123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- #ifndef __MATH_CCGEOMETRY_H__
- #define __MATH_CCGEOMETRY_H__
- #include "platform/CCPlatformMacros.h"
- #include "base/ccMacros.h"
- #include "math/CCMath.h"
- NS_CC_BEGIN
- class CC_DLL Size
- {
- public:
-
- float width;
-
- float height;
- public:
-
- operator Vec2() const
- {
- return Vec2(width, height);
- }
- public:
-
- Size();
- Size(float width, float height);
- Size(const Size& other);
- explicit Size(const Vec2& point);
-
-
- Size& operator= (const Size& other);
-
- Size& operator= (const Vec2& point);
-
- Size operator+(const Size& right) const;
-
- Size operator-(const Size& right) const;
-
- Size operator*(float a) const;
-
- Size operator/(float a) const;
-
- void setSize(float width, float height);
-
- bool equals(const Size& target) const;
-
- static const Size ZERO;
- };
- class CC_DLL Rect
- {
- public:
-
- Vec2 origin;
-
- Size size;
- public:
-
- Rect();
-
- Rect(float x, float y, float width, float height);
-
- Rect(const Vec2& pos, const Size& dimension);
-
- Rect(const Rect& other);
-
- Rect& operator= (const Rect& other);
-
- void setRect(float x, float y, float width, float height);
-
- float getMinX() const;
-
- float getMidX() const;
-
- float getMaxX() const;
-
- float getMinY() const;
-
- float getMidY() const;
-
- float getMaxY() const;
-
- bool equals(const Rect& rect) const;
-
- bool containsPoint(const Vec2& point) const;
-
- bool intersectsRect(const Rect& rect) const;
-
- bool intersectsCircle(const Vec2& center, float radius) const;
-
- Rect unionWithRect(const Rect & rect) const;
-
- void merge(const Rect& rect);
-
- static const Rect ZERO;
- };
- NS_CC_END
- #endif
|