|
| constexpr float | right () const |
| constexpr float | bottom () const |
| Point | origin () const |
| Size | size () const |
| Point | center () const |
| constexpr float | center_x () const |
| | True center in continuous coordinates — exact halves, no truncation.
|
| constexpr float | center_y () const |
| bool | contains (Point p) const |
| constexpr bool | contains (float px, float py) const |
| constexpr bool | encloses (const Rect &r) const |
| | Whole-rect containment: does this rect fully enclose r?
|
| constexpr bool | is_empty () const |
| Rect | inset (float amount) const |
| Rect | inset (float h, float v) const |
| Rect | reduced (float d) const |
| | Shrink by d on every side (the common "padding" idiom).
|
| Rect | reduced (float dx, float dy) const |
| Rect | expanded (float d) const |
| | Grow by d on every side.
|
| Rect | expanded (float dx, float dy) const |
| constexpr Rect | translated (float dx, float dy) const |
| constexpr Rect | with_x (float v) const |
| constexpr Rect | with_y (float v) const |
| constexpr Rect | with_width (float v) const |
| constexpr Rect | with_height (float v) const |
| constexpr Rect | with_size (float w, float h) const |
| constexpr Rect | with_position (float nx, float ny) const |
| constexpr Rect | with_size_keeping_center (float w, float h) const |
| | Resize about the center — the center stays put and the edges move.
|
| Rect | remove_from_top (float amount) |
| Rect | remove_from_bottom (float amount) |
| Rect | remove_from_left (float amount) |
| Rect | remove_from_right (float amount) |
| constexpr bool | intersects (const Rect &o) const |
| Rect | intersection (const Rect &o) const |
| | The overlap, or an empty rect when they do not overlap.
|
| Rect | union_with (const Rect &o) const |
| | Smallest rect enclosing both.
|
| IntRect | to_nearest_int () const |
| | Round each edge to the nearest integer.
|
| IntRect | to_enclosing_int () const |
| | Smallest integer rect that fully CONTAINS this one.
|
| bool | operator== (const Rect &r) const |
| bool | operator!= (const Rect &r) const |
Axis-aligned rectangle in continuous (float) coordinates.
── WHY THERE IS ALSO AN IntRect ────────────────────────────────────── A float rect's center is x + width / 2.0f. An INTEGER rect's center is x + width / 2 — integer division, which TRUNCATES. For an even extent the two agree; for an odd one they differ by half a pixel. That half pixel is not academic: it is the difference between a 7px row's content landing on the pixel grid and landing between two pixels, where it renders as a blurry double-width line. Code that computes an integer layout with float maths and rounds at the end does NOT reproduce integer-rect behavior, because the truncation has to happen at each step, not once at the end.
So the two types deliberately do NOT share an implementation. Pick the one that matches the coordinate space you are actually in, and convert explicitly with to_int() / to_float().
| bool pulp::view::Rect::encloses |
( |
const Rect & | r | ) |
const |
|
inlineconstexpr |
Whole-rect containment: does this rect fully enclose r?
NOT an overload of contains, on purpose. Rect has default member initializers, so a braced {50, 30} is a valid two-field Rect as well as a valid Point — which makes the natural, idiomatic r.contains({50, 30}) ambiguous at EVERY call site the moment a contains(const Rect&) overload exists. A distinct name is the fix; encloses also says what it does more plainly than a third contains.