40 Rect<T>::Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight) :
52 Rect<T>::Rect(
const Vector2<T>& position,
const Vector2<T>& size) :
65 Rect<T>::Rect(
const Rect<U>& rectangle) :
66 left (static_cast<T>(rectangle.left)),
67 top (static_cast<T>(rectangle.top)),
68 width (static_cast<T>(rectangle.width)),
69 height(static_cast<T>(rectangle.height))
76 bool Rect<T>::contains(T x, T y)
const
78 return (x >= left) && (x < left + width) && (y >= top) && (y < top + height);
84 bool Rect<T>::contains(
const Vector2<T>& point)
const
86 return contains(point.x, point.y);
92 bool Rect<T>::intersects(
const Rect<T>& rectangle)
const
95 return intersects(rectangle, intersection);
100 template <
typename T>
101 bool Rect<T>::intersects(
const Rect<T>& rectangle, Rect<T>& intersection)
const
104 T interLeft = std::max(left, rectangle.left);
105 T interTop = std::max(top, rectangle.top);
106 T interRight = std::min(left + width, rectangle.left + rectangle.width);
107 T interBottom = std::min(top + height, rectangle.top + rectangle.height);
110 if ((interLeft < interRight) && (interTop < interBottom))
112 intersection = Rect<T>(interLeft, interTop, interRight - interLeft, interBottom - interTop);
117 intersection = Rect<T>(0, 0, 0, 0);
124 template <
typename T>
125 inline bool operator ==(
const Rect<T>& left,
const Rect<T>& right)
127 return (left.left == right.left) && (left.width == right.width) &&
128 (left.top == right.top) && (left.height == right.height);
133 template <
typename T>
134 inline bool operator !=(
const Rect<T>& left,
const Rect<T>& right)
136 return !(left == right);
bool operator!=(const Color &left, const Color &right)
Overload of the != operator.
bool operator==(const Color &left, const Color &right)
Overload of the == operator.