Struct buffer_graphics_lib::math::Rect
source · [−]#[repr(C)]pub struct Rect<T> {
pub x1: T,
pub y1: T,
pub x2: T,
pub y2: T,
}
Fields
x1: T
y1: T
x2: T
y2: T
Implementations
sourceimpl<T: Add<Output = T> + Copy> Rect<T>
impl<T: Add<Output = T> + Copy> Rect<T>
pub const fn new(x1: T, y1: T, x2: T, y2: T) -> Self
pub fn from_point(point: Point2<T>, w: T, h: T) -> Self
sourceimpl<T: Copy + Add<Output = T> + Sub<Output = T> + Ord + Default> Rect<T>
impl<T: Copy + Add<Output = T> + Sub<Output = T> + Ord + Default> Rect<T>
pub fn width(&self) -> T
pub fn height(&self) -> T
pub fn clip_to_positive(&self) -> Rect<T>
pub fn move_to(&self, x: T, y: T) -> Rect<T>
pub fn translate(&self, x: T, y: T) -> Rect<T>
pub fn topleft(&self) -> Point2<T>
pub fn bottomright(&self) -> Point2<T>
sourcepub fn union(&self, other: &Rect<T>) -> Rect<T>
pub fn union(&self, other: &Rect<T>) -> Rect<T>
Union this rect and another, the result will contain both rectangles Generally, this means the result will be bigger than self
sourcepub fn intersect(&self, other: &Rect<T>) -> Rect<T>
pub fn intersect(&self, other: &Rect<T>) -> Rect<T>
Intersect this rect and another, the result will contain the area covered by both rectangles Generally, this means the result will be smaller than self
Returns
self if rectangles do not intersect
pub fn intersects(&self, other: &Rect<T>) -> bool
Trait Implementations
sourceimpl<'de, T> Deserialize<'de> for Rect<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Rect<T>where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: Ord> Ord for Rect<T>
impl<T: Ord> Ord for Rect<T>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<T: PartialEq> PartialEq<Rect<T>> for Rect<T>
impl<T: PartialEq> PartialEq<Rect<T>> for Rect<T>
sourceimpl<T: PartialOrd> PartialOrd<Rect<T>> for Rect<T>
impl<T: PartialOrd> PartialOrd<Rect<T>> for Rect<T>
sourcefn partial_cmp(&self, other: &Rect<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &Rect<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Copy> Copy for Rect<T>
impl<T: Eq> Eq for Rect<T>
impl<T> StructuralEq for Rect<T>
impl<T> StructuralPartialEq for Rect<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Rect<T>where
T: RefUnwindSafe,
impl<T> Send for Rect<T>where
T: Send,
impl<T> Sync for Rect<T>where
T: Sync,
impl<T> Unpin for Rect<T>where
T: Unpin,
impl<T> UnwindSafe for Rect<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more