pub struct RectPx {
pub x: f32,
pub y: f32,
pub w: f32,
pub h: f32,
}Expand description
An axis-aligned rectangle in physical pixels.
§Examples
use ferrochart_core::geom::RectPx;
let r = RectPx { x: 10.0, y: 20.0, w: 30.0, h: 40.0 };
assert_eq!((r.right(), r.bottom()), (40.0, 60.0));Fields§
§x: f32Left edge.
y: f32Top edge.
w: f32Width.
h: f32Height.
Implementations§
Source§impl RectPx
impl RectPx
Sourcepub fn contains(self, p: PointPx) -> bool
pub fn contains(self, p: PointPx) -> bool
Whether p lies inside (left/top edges inclusive, right/bottom exclusive).
§Examples
use ferrochart_core::geom::{PointPx, RectPx};
let r = RectPx { x: 0.0, y: 0.0, w: 10.0, h: 10.0 };
assert!(r.contains(PointPx { x: 0.0, y: 9.5 }));
assert!(!r.contains(PointPx { x: 10.0, y: 5.0 }));Sourcepub fn intersect(self, other: Self) -> Self
pub fn intersect(self, other: Self) -> Self
Intersection with other; an empty rectangle (zero size) if they do not overlap.
§Examples
use ferrochart_core::geom::RectPx;
let a = RectPx { x: 0.0, y: 0.0, w: 10.0, h: 10.0 };
let b = RectPx { x: 5.0, y: 5.0, w: 10.0, h: 10.0 };
assert_eq!(a.intersect(b), RectPx { x: 5.0, y: 5.0, w: 5.0, h: 5.0 });Trait Implementations§
impl Copy for RectPx
impl StructuralPartialEq for RectPx
Auto Trait Implementations§
impl Forget for RectPx
impl Freeze for RectPx
impl Move for RectPx
impl RefUnwindSafe for RectPx
impl Send for RectPx
impl Sync for RectPx
impl Unpin for RectPx
impl UnsafeUnpin for RectPx
impl UnwindSafe for RectPx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more