Returns the intersection of `this` and `b`. */
| 408 | } |
| 409 | /** Returns the intersection of `this` and `b`. */ |
| 410 | Rect intersect(Rect b) const { |
| 411 | Rect r; |
| 412 | r.pos.x = std::fmax(pos.x, b.pos.x); |
| 413 | r.pos.y = std::fmax(pos.y, b.pos.y); |
| 414 | r.size.x = std::fmin(pos.x + size.x, b.pos.x + b.size.x) - r.pos.x; |
| 415 | r.size.y = std::fmin(pos.y + size.y, b.pos.y + b.size.y) - r.pos.y; |
| 416 | return r; |
| 417 | } |
| 418 | /** Returns a Rect with its position set to zero. */ |
| 419 | Rect zeroPos() const { |
| 420 | return Rect(Vec(), size); |