Lines Matching refs:rect

165 bool Rect::Contains(const Rect& rect) const {  in Contains()
166 return (rect.x() >= x() && rect.right() <= right() && rect.y() >= y() && in Contains()
167 rect.bottom() <= bottom()); in Contains()
170 bool Rect::Intersects(const Rect& rect) const { in Intersects()
171 return !(IsEmpty() || rect.IsEmpty() || rect.x() >= right() || in Intersects()
172 rect.right() <= x() || rect.y() >= bottom() || rect.bottom() <= y()); in Intersects()
175 void Rect::Intersect(const Rect& rect) { in Intersect() argument
176 if (IsEmpty() || rect.IsEmpty()) { in Intersect()
181 int left = std::max(x(), rect.x()); in Intersect()
182 int top = std::max(y(), rect.y()); in Intersect()
183 int new_right = std::min(right(), rect.right()); in Intersect()
184 int new_bottom = std::min(bottom(), rect.bottom()); in Intersect()
194 void Rect::Union(const Rect& rect) { in Union() argument
196 *this = rect; in Union()
199 if (rect.IsEmpty()) in Union()
202 SetByBounds(std::min(x(), rect.x()), std::min(y(), rect.y()), in Union()
203 std::max(right(), rect.right()), in Union()
204 std::max(bottom(), rect.bottom())); in Union()
207 void Rect::Subtract(const Rect& rect) { in Subtract() argument
208 if (!Intersects(rect)) in Subtract()
210 if (rect.Contains(*this)) { in Subtract()
220 if (rect.y() <= y() && rect.bottom() >= bottom()) { in Subtract()
222 if (rect.x() <= x()) { in Subtract()
223 rx = rect.right(); in Subtract()
224 } else if (rect.right() >= right()) { in Subtract()
225 rr = rect.x(); in Subtract()
227 } else if (rect.x() <= x() && rect.right() >= right()) { in Subtract()
229 if (rect.y() <= y()) { in Subtract()
230 ry = rect.bottom(); in Subtract()
231 } else if (rect.bottom() >= bottom()) { in Subtract()
232 rb = rect.y(); in Subtract()
238 void Rect::AdjustToFit(const Rect& rect) { in AdjustToFit() argument
243 AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width); in AdjustToFit()
244 AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height); in AdjustToFit()
269 bool Rect::SharesEdgeWith(const Rect& rect) const { in SharesEdgeWith()
270 return (y() == rect.y() && height() == rect.height() && in SharesEdgeWith()
271 (x() == rect.right() || right() == rect.x())) || in SharesEdgeWith()
272 (x() == rect.x() && width() == rect.width() && in SharesEdgeWith()
273 (y() == rect.bottom() || bottom() == rect.y())); in SharesEdgeWith()
285 int Rect::ManhattanInternalDistance(const Rect& rect) const { in ManhattanInternalDistance()
287 c.Union(rect); in ManhattanInternalDistance()
289 int x = std::max(0, c.width() - width() - rect.width() + 1); in ManhattanInternalDistance()
290 int y = std::max(0, c.height() - height() - rect.height() + 1); in ManhattanInternalDistance()
300 bool Rect::ApproximatelyEqual(const Rect& rect, int tolerance) const { in ApproximatelyEqual() argument
301 return std::abs(x() - rect.x()) <= tolerance && in ApproximatelyEqual()
302 std::abs(y() - rect.y()) <= tolerance && in ApproximatelyEqual()
303 std::abs(right() - rect.right()) <= tolerance && in ApproximatelyEqual()
304 std::abs(bottom() - rect.bottom()) <= tolerance; in ApproximatelyEqual()