pub struct RectRange<T: Num + PartialOrd> { /* private fields */ }
Expand description
RectRange is rectangle representation using std::ops::Range
.
Diffrent from RangeIntoIterator
implementation and iter
method(with ‘clone’).
Implementations§
Source§impl<T: Num + PartialOrd> RectRange<T>
impl<T: Num + PartialOrd> RectRange<T>
Sourcepub fn new(lx: T, ly: T, ux: T, uy: T) -> Option<RectRange<T>>
pub fn new(lx: T, ly: T, ux: T, uy: T) -> Option<RectRange<T>>
construct a range from left x, lower y, right x, upper y
Sourcepub fn zero_start(x: T, y: T) -> Option<RectRange<T>>
pub fn zero_start(x: T, y: T) -> Option<RectRange<T>>
construct a range x_range: 0..x, y_range: 0..y
Sourcepub fn from_point<P: IntoTuple2<T>>(p: P) -> Option<RectRange<T>>
pub fn from_point<P: IntoTuple2<T>>(p: P) -> Option<RectRange<T>>
construct a range x_range: 0..p.x, y_range: 0..p.y
Sourcepub fn from_ranges(x_range: Range<T>, y_range: Range<T>) -> Option<RectRange<T>>
pub fn from_ranges(x_range: Range<T>, y_range: Range<T>) -> Option<RectRange<T>>
construct a range x_range: 0..x, y_range: 0..y
Sourcepub fn contains<P: IntoTuple2<T>>(&self, p: P) -> bool
pub fn contains<P: IntoTuple2<T>>(&self, p: P) -> bool
checks if the range contains the point
Source§impl<T: Num + PartialOrd + Clone> RectRange<T>
impl<T: Num + PartialOrd + Clone> RectRange<T>
Sourcepub fn slide<P: IntoTuple2<T>>(self, t: P) -> RectRange<T>
pub fn slide<P: IntoTuple2<T>>(self, t: P) -> RectRange<T>
slide range by the given point
Sourcepub fn slide_start<P: IntoTuple2<T>>(self, t: P) -> RectRange<T>
pub fn slide_start<P: IntoTuple2<T>>(self, t: P) -> RectRange<T>
slide start point without checking
Sourcepub fn slide_end<P: IntoTuple2<T>>(self, t: P) -> RectRange<T>
pub fn slide_end<P: IntoTuple2<T>>(self, t: P) -> RectRange<T>
slide end point without checking
Sourcepub fn intersects(&self, other: &RectRange<T>) -> bool
pub fn intersects(&self, other: &RectRange<T>) -> bool
judges if 2 ranges have intersection
Sourcepub fn intersection(&self, other: &RectRange<T>) -> Option<RectRange<T>>
pub fn intersection(&self, other: &RectRange<T>) -> Option<RectRange<T>>
gets the intersection of 2 ranges
Sourcepub fn lower_left(&self) -> (T, T)
pub fn lower_left(&self) -> (T, T)
get the lower left corner(inclusive)
Sourcepub fn lower_right(&self) -> (T, T)
pub fn lower_right(&self) -> (T, T)
get the lower right corner(inclusive)
Sourcepub fn upper_left(&self) -> (T, T)
pub fn upper_left(&self) -> (T, T)
get the upper left corner(inclusive)
Sourcepub fn upper_right(&self) -> (T, T)
pub fn upper_right(&self) -> (T, T)
get the upper right corner(inclusive)
Sourcepub fn is_edge<P: IntoTuple2<T>>(&self, p: P) -> bool
pub fn is_edge<P: IntoTuple2<T>>(&self, p: P) -> bool
checks if the point is on the edge of the rectangle
Sourcepub fn is_vert_edge<P: IntoTuple2<T>>(&self, p: P) -> bool
pub fn is_vert_edge<P: IntoTuple2<T>>(&self, p: P) -> bool
checks if the point is on the vertical edge of the rectangle
Sourcepub fn is_horiz_edge<P: IntoTuple2<T>>(&self, p: P) -> bool
pub fn is_horiz_edge<P: IntoTuple2<T>>(&self, p: P) -> bool
checks if the point is on the horizoni edge of the rectangle
Source§impl<T: Num + PartialOrd + Copy> RectRange<T>
impl<T: Num + PartialOrd + Copy> RectRange<T>
Source§impl<T: Num + PartialOrd + ToPrimitive + Copy> RectRange<T>
impl<T: Num + PartialOrd + ToPrimitive + Copy> RectRange<T>
pub fn to_u8(self) -> Option<RectRange<u8>>
pub fn to_u16(self) -> Option<RectRange<u16>>
pub fn to_u32(self) -> Option<RectRange<u32>>
pub fn to_u64(self) -> Option<RectRange<u64>>
pub fn to_i8(self) -> Option<RectRange<i8>>
pub fn to_i16(self) -> Option<RectRange<i16>>
pub fn to_i32(self) -> Option<RectRange<i32>>
pub fn to_i64(self) -> Option<RectRange<i64>>
pub fn to_usize(self) -> Option<RectRange<usize>>
Source§impl<T: Num + PartialOrd + Copy + FromPrimitive + ToPrimitive> RectRange<T>
impl<T: Num + PartialOrd + Copy + FromPrimitive + ToPrimitive> RectRange<T>
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for RectRange<T>
impl<'de, T> Deserialize<'de> for RectRange<T>
Source§fn 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>,
Source§impl<T: Num + PartialOrd + Copy> IntoIterator for RectRange<T>
impl<T: Num + PartialOrd + Copy> IntoIterator for RectRange<T>
impl<T: Eq + Num + PartialOrd> Eq for RectRange<T>
impl<T: Num + PartialOrd> StructuralPartialEq for RectRange<T>
Auto Trait Implementations§
impl<T> Freeze for RectRange<T>where
T: Freeze,
impl<T> RefUnwindSafe for RectRange<T>where
T: RefUnwindSafe,
impl<T> Send for RectRange<T>where
T: Send,
impl<T> Sync for RectRange<T>where
T: Sync,
impl<T> Unpin for RectRange<T>where
T: Unpin,
impl<T> UnwindSafe for RectRange<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more