pub struct Rect {
pub llx: f64,
pub lly: f64,
pub urx: f64,
pub ury: f64,
}Expand description
A rectangle normalized per §7.9.5: the array [x1 y1 x2 y2] gives
two diagonally opposite corners in either order, so consumers
must normalize — this type stores (min, min) → (max, max) always.
Fields§
§llx: f64Lower-left x (the smaller x).
lly: f64Lower-left y (the smaller y).
urx: f64Upper-right x (the larger x).
ury: f64Upper-right y (the larger y).
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn from_corners(x1: f64, y1: f64, x2: f64, y2: f64) -> Self
pub fn from_corners(x1: f64, y1: f64, x2: f64, y2: f64) -> Self
Normalize two arbitrary diagonal corners into a Rect
(§7.9.5’s corners-in-any-order rule).
Sourcepub fn contains(&self, other: &Self) -> bool
pub fn contains(&self, other: &Self) -> bool
Whether other lies wholly inside this rectangle, edges included.
Inclusive on every edge, which is the answer the page-boundary
questions want: §14.11.2’s boxes routinely coincide exactly (Table
30 makes CropBox default to MediaBox, and the defaulted case
must not report itself as “outside”), and a page whose crop box
equals its media box is the overwhelmingly common shape.
Both rectangles are assumed §7.9.5-normalized — true by
construction for anything from Rect::from_corners or from the
page-tree walk, which is every Rect pdfcer produces.
Sourcepub fn intersection(&self, other: &Self) -> Option<Self>
pub fn intersection(&self, other: &Self) -> Option<Self>
The overlap of two rectangles, or None when it has no area
(disjoint, or touching only along an edge or at a corner).
A zero-area overlap is None rather than a degenerate Rect
because every caller is resolving a page box, and a page box with
no area frames nothing (ISO 32000-2 §14.11.2.1 leaves that case
undefined — ambiguity PB-A1).