Skip to main content

Rect

Struct Rect 

Source
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: f64

Lower-left x (the smaller x).

§lly: f64

Lower-left y (the smaller y).

§urx: f64

Upper-right x (the larger x).

§ury: f64

Upper-right y (the larger y).

Implementations§

Source§

impl Rect

Source

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).

Source

pub fn width(&self) -> f64

Width (always non-negative by construction).

Source

pub fn height(&self) -> f64

Height (always non-negative by construction).

Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for Rect

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Rect

Source§

impl Debug for Rect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Rect

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Rect

Auto Trait Implementations§

§

impl Forget for Rect

§

impl Freeze for Rect

§

impl Move for Rect

§

impl RefUnwindSafe for Rect

§

impl Send for Rect

§

impl Sync for Rect

§

impl Unpin for Rect

§

impl UnsafeUnpin for Rect

§

impl UnwindSafe for Rect

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.