12 void AdjustAlongAxis(
T dst_origin,
T dst_size,
14 if (*origin < dst_origin) {
16 *size = std::min(dst_size, *size);
18 *size = std::min(dst_size, *size);
19 *origin = std::min(dst_origin + dst_size, *origin + *size) - *size;
34 rect_.point.x += horizontal;
35 rect_.point.y += vertical;
39 return (point_x >=
x()) && (point_x <
right()) &&
40 (point_y >=
y()) && (point_y <
bottom());
59 if (rx >= rr || ry >= rb)
60 rx = ry = rr = rb = 0;
62 return Rect(rx, ry, rr - rx, rb - ry);
77 return Rect(rx, ry, rr - rx, rb - ry);
94 if (rect.
x() <=
x()) {
101 if (rect.
y() <=
y()) {
107 return Rect(rx, ry, rr - rx, rb - ry);
115 AdjustAlongAxis(rect.
x(), rect.
width(), &new_x, &new_width);
116 AdjustAlongAxis(rect.
y(), rect.
height(), &new_y, &new_height);
117 return Rect(new_x, new_y, new_width, new_height);
138 rect_.point.x += horizontal;
139 rect_.point.y += vertical;
143 return (point_x >=
x()) && (point_x <
right()) &&
144 (point_y >=
y()) && (point_y <
bottom());
158 float rx = std::max(
x(), rect.
x());
159 float ry = std::max(
y(), rect.
y());
163 if (rx >= rr || ry >= rb)
164 rx = ry = rr = rb = 0;
166 return FloatRect(rx, ry, rr - rx, rb - ry);
176 float rx = std::min(
x(), rect.
x());
177 float ry = std::min(
y(), rect.
y());
181 return FloatRect(rx, ry, rr - rx, rb - ry);
198 if (rect.
x() <=
x()) {
203 }
else if (rect.
x() <=
x() && rect.
right() >=
right()) {
205 if (rect.
y() <=
y()) {
211 return FloatRect(rx, ry, rr - rx, rb - ry);
217 float new_width =
width();
218 float new_height =
height();
219 AdjustAlongAxis(rect.
x(), rect.
width(), &new_x, &new_width);
220 AdjustAlongAxis(rect.
y(), rect.
height(), &new_y, &new_height);
221 return FloatRect(new_x, new_y, new_width, new_height);
226 y() + (
height() + 1.0f) / 2.0f);
bool Intersects(const FloatRect &rect) const
Point CenterPoint() const
void Inset(float horizontal, float vertical)
Rect Union(const Rect &rect) const
Rect Subtract(const Rect &rect) const
FloatPoint CenterPoint() const
A 2 dimensional point with 0,0 being the upper-left starting coordinate.
bool Intersects(const Rect &rect) const
Rect AdjustToFit(const Rect &rect) const
void Offset(float horizontal, float vertical)
Rect Intersect(const Rect &rect) const
FloatRect Intersect(const FloatRect &rect) const
void Inset(int32_t horizontal, int32_t vertical)
bool Contains(int32_t point_x, int32_t point_y) const
FloatRect AdjustToFit(const FloatRect &rect) const
FloatRect Subtract(const FloatRect &rect) const
bool SharesEdgeWith(const FloatRect &rect) const
void set_width(int32_t w)
bool SharesEdgeWith(const Rect &rect) const
bool Contains(float point_x, float point_y) const
void Offset(int32_t horizontal, int32_t vertical)
FloatRect Union(const FloatRect &rect) const
void set_height(int32_t h)