#[repr(C)]pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}Expand description
2D Rectangle in floating point pixels.
Fields§
§x: f32§y: f32§width: f32§height: f32Implementations§
Source§impl Rect
impl Rect
pub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub const fn from_xywh(x: f32, y: f32, width: f32, height: f32) -> Self
pub const fn zero() -> Self
pub fn min_x(self) -> f32
pub fn max_x(self) -> f32
pub fn min_y(self) -> f32
pub fn max_y(self) -> f32
Sourcepub fn intersect(self, other: Self) -> Option<Self>
pub fn intersect(self, other: Self) -> Option<Self>
Computes intersection with another rectangle if overlapping.
Sourcepub fn contains_point(self, px: f32, py: f32) -> bool
pub fn contains_point(self, px: f32, py: f32) -> bool
Returns true if this rectangle contains the given point (px, py).
Sourcepub fn contains_rect(self, other: Self) -> bool
pub fn contains_rect(self, other: Self) -> bool
Returns true if this rectangle completely encloses other.
Sourcepub fn snap_to_pixel(self) -> Self
pub fn snap_to_pixel(self) -> Self
Chromium subpixel layout boundary snapping via LayoutUnit (1/64th px fixed point).
Snaps bounding edges against global screen space, deriving width and height
as snapped_max - snapped_min. This guarantees adjacent sibling boxes and
deeply nested descendants snap seamlessly with zero hairline cracks or rounding drift.
Sourcepub fn snap_to_scale(self, scale: f32) -> Self
pub fn snap_to_scale(self, scale: f32) -> Self
Snaps bounding edges against a device scale factor (e.g. 1.0 for 1x, 2.0 for Retina).
Trait Implementations§
impl Copy for Rect
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> 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