* Compute the bounding rectangle around two rectangles. * @param r1 First rectangle. * @param r2 Second rectangle. * @return The bounding rectangle, the smallest rectangle that contains both arguments. */
| 34 | * @return The bounding rectangle, the smallest rectangle that contains both arguments. |
| 35 | */ |
| 36 | Rect BoundingRect(const Rect &r1, const Rect &r2) |
| 37 | { |
| 38 | /* If either the first or the second is empty, return the other. */ |
| 39 | if (IsEmptyRect(r1)) return r2; |
| 40 | if (IsEmptyRect(r2)) return r1; |
| 41 | |
| 42 | Rect r; |
| 43 | |
| 44 | r.top = std::min(r1.top, r2.top); |
| 45 | r.bottom = std::max(r1.bottom, r2.bottom); |
| 46 | r.left = std::min(r1.left, r2.left); |
| 47 | r.right = std::max(r1.right, r2.right); |
| 48 | |
| 49 | return r; |
| 50 | } |
no test coverage detected