Clamps the edges of the rectangle to fit within a bound. */
| 382 | } |
| 383 | /** Clamps the edges of the rectangle to fit within a bound. */ |
| 384 | Rect clamp(Rect bound) const { |
| 385 | Rect r; |
| 386 | r.pos.x = math::clampSafe(pos.x, bound.pos.x, bound.pos.x + bound.size.x); |
| 387 | r.pos.y = math::clampSafe(pos.y, bound.pos.y, bound.pos.y + bound.size.y); |
| 388 | r.size.x = math::clamp(pos.x + size.x, bound.pos.x, bound.pos.x + bound.size.x) - r.pos.x; |
| 389 | r.size.y = math::clamp(pos.y + size.y, bound.pos.y, bound.pos.y + bound.size.y) - r.pos.y; |
| 390 | return r; |
| 391 | } |
| 392 | /** Nudges the position to fix inside a bounding box. */ |
| 393 | Rect nudge(Rect bound) const { |
| 394 | Rect r; |