pub struct Rect {
pub min: Point,
pub max: Point,
}Expand description
A closed axis-aligned rectangle with positive width and height.
Routes may touch the boundary but never enter the open interior.
Fields§
§min: PointThe corner with the smallest coordinates.
max: PointThe corner with the largest coordinates; strictly greater than min on both axes.
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> Self
pub fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> Self
Creates the rectangle [x0, x1] x [y0, y1], ordering the bounds.
§Panics
Panics if the rectangle has zero width or height. Use Rect::try_new to get
None instead.
§Examples
use connector_routing::{Point, Rect};
let r = Rect::new(10, 0, 0, 5);
assert_eq!(r.min, Point::new(0, 0));
assert_eq!(r.width(), 10);Sourcepub fn try_new(x0: i32, y0: i32, x1: i32, y1: i32) -> Option<Self>
pub fn try_new(x0: i32, y0: i32, x1: i32, y1: i32) -> Option<Self>
Creates the rectangle [x0, x1] x [y0, y1], or None if it is degenerate.
Sourcepub fn interior_contains(&self, p: Point) -> bool
pub fn interior_contains(&self, p: Point) -> bool
Whether p lies in the open interior.
Sourcepub fn boundary_contains(&self, p: Point) -> bool
pub fn boundary_contains(&self, p: Point) -> bool
Whether p lies on the boundary.
Sourcepub fn buffer(&self, amount: i32) -> Self
pub fn buffer(&self, amount: i32) -> Self
The rectangle grown by amount on every side.
§Panics
Panics if a negative amount makes the rectangle degenerate.
Sourcepub fn interiors_overlap(&self, other: &Self) -> bool
pub fn interiors_overlap(&self, other: &Self) -> bool
Whether the open interiors of the two rectangles intersect.
Sourcepub fn blocks_segment(&self, a: Point, b: Point) -> bool
pub fn blocks_segment(&self, a: Point, b: Point) -> bool
Whether the closed axis-parallel segment from a to b meets the open interior.
a and b must share one coordinate.