pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}Expand description
Axis-aligned rectangle, (x, y) = top-left, y-down.
Fields§
§x: f32§y: f32§width: f32§height: f32Implementations§
Source§impl Rect
impl Rect
Sourcepub const EVERYTHING: Rect
pub const EVERYTHING: Rect
The conservative “cannot bound this” rect: content whose transform reaches the eye plane maps here — culling never rejects it, layers clamp to their clip instead.
pub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub fn from_ltrb(l: f32, t: f32, r: f32, b: f32) -> Self
pub fn from_origin_size(origin: Point, size: Size) -> Self
pub fn right(&self) -> f32
pub fn bottom(&self) -> f32
pub fn origin(&self) -> Point
pub fn size(&self) -> Size
pub fn is_empty(&self) -> bool
Sourcepub fn union(&self, other: &Rect) -> Rect
pub fn union(&self, other: &Rect) -> Rect
Smallest rect containing both (empty rects are identity).
pub fn intersects(&self, other: &Rect) -> bool
pub fn contains(&self, p: Point) -> bool
Sourcepub fn contains_inclusive(&self, p: Point) -> bool
pub fn contains_inclusive(&self, p: Point) -> bool
Like Self::contains but with the far edges included — Skia’s
contains_inclusive. Hit-testing wants this: a rect path’s bounds ARE
its outline, and a point on the outline counts as inside.
pub fn expand(&self, d: f32) -> Rect
pub fn corners(&self) -> [Point; 4]
Trait Implementations§
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze 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