pub trait RectExt: Sized {
type Val: Copy + Add<Output = Self::Val> + Sub<Output = Self::Val> + PartialOrd;
Show 46 methods
// Required methods
fn from_pos_size(
pos: impl Into<Vec2<Self::Val>>,
size: impl Into<Vec2<Self::Val>>,
) -> Self;
fn width(&self) -> Self::Val;
fn height(&self) -> Self::Val;
fn x(&self) -> Self::Val;
fn y(&self) -> Self::Val;
fn set_width(&mut self, w: Self::Val);
fn set_height(&mut self, h: Self::Val);
fn set_x(&mut self, x: Self::Val);
fn set_y(&mut self, y: Self::Val);
// Provided methods
fn from_ranges(
lr: impl Into<Range<Self::Val>>,
tb: impl Into<Range<Self::Val>>,
) -> Self { ... }
fn from_points(
a: impl Into<Vec2<Self::Val>>,
b: impl Into<Vec2<Self::Val>>,
) -> Self { ... }
fn pos(&self) -> Vec2<Self::Val> { ... }
fn size(&self) -> Vec2<Self::Val> { ... }
fn left(&self) -> Self::Val { ... }
fn top(&self) -> Self::Val { ... }
fn right(&self) -> Self::Val { ... }
fn bottom(&self) -> Self::Val { ... }
fn top_left(&self) -> Vec2<Self::Val> { ... }
fn top_right(&self) -> Vec2<Self::Val> { ... }
fn bot_right(&self) -> Vec2<Self::Val> { ... }
fn bot_left(&self) -> Vec2<Self::Val> { ... }
fn xrange(&self) -> Range<Self::Val> { ... }
fn yrange(&self) -> Range<Self::Val> { ... }
fn center(&self) -> Vec2<Self::Val>
where Self::Val: Div<Output = Self::Val> + Two { ... }
fn pad_rect(&self, padding: impl Into<Padding<Self::Val>>) -> Self
where Self::Val: PartialOrd + Zero { ... }
fn extend_rect(&self, margin: impl Into<Padding<Self::Val>>) -> Self { ... }
fn bound_join(&self, other: impl Into<Self>) -> Self { ... }
fn intersect(&self, other: impl Into<Self>) -> Self { ... }
fn move_to(&mut self, pos: impl Into<Vec2<Self::Val>>) -> &mut Self { ... }
fn encloses(&self, other: &Self) -> bool { ... }
fn contains(&self, point: impl Into<Vec2<Self::Val>>) -> bool { ... }
fn intersects(&self, other: &Self) -> bool { ... }
fn area(&self) -> Self::Val
where Self::Val: Mul<Output = Self::Val> { ... }
fn is_empty(&self) -> bool
where Self::Val: PartialEq + Zero { ... }
fn clamp(&self, pt: impl Into<Vec2<Self::Val>>) -> Vec2<Self::Val> { ... }
fn set_pos(&mut self, pos: impl Into<Vec2<Self::Val>>) { ... }
fn set_size(&mut self, size: impl Into<Vec2<Self::Val>>) { ... }
fn extend_bot(&mut self, amt: Self::Val) { ... }
fn extend_right(&mut self, amt: Self::Val) { ... }
fn extend_left(&mut self, amt: Self::Val) { ... }
fn extend_top(&mut self, amt: Self::Val) { ... }
fn moved_by(&self, amt: impl Into<Vec2<Self::Val>>) -> Self { ... }
fn set_right(&mut self, r: Self::Val) { ... }
fn set_left(&mut self, l: Self::Val) { ... }
fn set_bottom(&mut self, b: Self::Val) { ... }
fn set_top(&mut self, t: Self::Val) { ... }
}Required Associated Types§
Required Methods§
Sourcefn from_pos_size(
pos: impl Into<Vec2<Self::Val>>,
size: impl Into<Vec2<Self::Val>>,
) -> Self
fn from_pos_size( pos: impl Into<Vec2<Self::Val>>, size: impl Into<Vec2<Self::Val>>, ) -> Self
Create new rectangle from position of top left corner and size.
Sourcefn set_height(&mut self, h: Self::Val)
fn set_height(&mut self, h: Self::Val)
Set the height of the rectangle.
Provided Methods§
Sourcefn from_ranges(
lr: impl Into<Range<Self::Val>>,
tb: impl Into<Range<Self::Val>>,
) -> Self
fn from_ranges( lr: impl Into<Range<Self::Val>>, tb: impl Into<Range<Self::Val>>, ) -> Self
Create the rectangle from ranges of coordinates.
Sourcefn from_points(
a: impl Into<Vec2<Self::Val>>,
b: impl Into<Vec2<Self::Val>>,
) -> Self
fn from_points( a: impl Into<Vec2<Self::Val>>, b: impl Into<Vec2<Self::Val>>, ) -> Self
Create the rectangle from two points.
Sourcefn pad_rect(&self, padding: impl Into<Padding<Self::Val>>) -> Self
fn pad_rect(&self, padding: impl Into<Padding<Self::Val>>) -> Self
Shrink the rectangle with padding.
Sourcefn extend_rect(&self, margin: impl Into<Padding<Self::Val>>) -> Self
fn extend_rect(&self, margin: impl Into<Padding<Self::Val>>) -> Self
Enlarge the rectangle with the given padding.
Sourcefn bound_join(&self, other: impl Into<Self>) -> Self
fn bound_join(&self, other: impl Into<Self>) -> Self
Create rectangle that encloses both of the rectangles.
Sourcefn intersect(&self, other: impl Into<Self>) -> Self
fn intersect(&self, other: impl Into<Self>) -> Self
Create rectangle that is the intersection of two rectangles.
Sourcefn move_to(&mut self, pos: impl Into<Vec2<Self::Val>>) -> &mut Self
fn move_to(&mut self, pos: impl Into<Vec2<Self::Val>>) -> &mut Self
Change the position of the rectangle.
Sourcefn encloses(&self, other: &Self) -> bool
fn encloses(&self, other: &Self) -> bool
Check whether this rectangle fully encloses the other rectangle.
Sourcefn contains(&self, point: impl Into<Vec2<Self::Val>>) -> bool
fn contains(&self, point: impl Into<Vec2<Self::Val>>) -> bool
Check whether this rectangle contains the given point.
Sourcefn intersects(&self, other: &Self) -> bool
fn intersects(&self, other: &Self) -> bool
Check whether two rectangles intersect.
Sourcefn clamp(&self, pt: impl Into<Vec2<Self::Val>>) -> Vec2<Self::Val>
fn clamp(&self, pt: impl Into<Vec2<Self::Val>>) -> Vec2<Self::Val>
Clamp the point to be contained in the rectangle.
Sourcefn extend_bot(&mut self, amt: Self::Val)
fn extend_bot(&mut self, amt: Self::Val)
Extend the rectangle from bottom by the given amount.
Sourcefn extend_right(&mut self, amt: Self::Val)
fn extend_right(&mut self, amt: Self::Val)
Extend the rectangle from right by the given amount.
Sourcefn extend_left(&mut self, amt: Self::Val)
fn extend_left(&mut self, amt: Self::Val)
Extend the rectangle from left by the given amount.
Sourcefn extend_top(&mut self, amt: Self::Val)
fn extend_top(&mut self, amt: Self::Val)
Extend the rectangle from left by the given amount.
Sourcefn moved_by(&self, amt: impl Into<Vec2<Self::Val>>) -> Self
fn moved_by(&self, amt: impl Into<Vec2<Self::Val>>) -> Self
Create new rectangle moved by the given amount.
Sourcefn set_bottom(&mut self, b: Self::Val)
fn set_bottom(&mut self, b: Self::Val)
Set the bottom value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".