Trait figures::Rectlike [−][src]
pub trait Rectlike<T, Unit>: Sized where
T: Zero + PartialOrd + Mul<T, Output = T> + Sub<T, Output = T> + One + Add<T, Output = T> + Div<T, Output = T> + Copy, {
Show 16 methods
fn as_rect(&self) -> Rect<T, Unit>;
fn as_extents(&self) -> ExtentsRect<T, Unit>;
fn as_sized(&self) -> SizedRect<T, Unit>;
fn width(&self) -> Figure<T, Unit>;
fn height(&self) -> Figure<T, Unit>;
fn origin(&self) -> Point<T, Unit>;
fn translate<V: Into<Vector<T, Unit>>>(&self, by: V) -> Self;
fn inflate<V: Into<Vector<T, Unit>>>(&self, by: V) -> Self;
fn to_non_empty(self) -> Option<Self> { ... }
fn is_empty(&self) -> bool { ... }
fn area(&self) -> Figure<T, Unit> { ... }
fn size(&self) -> Size<T, Unit> { ... }
fn center(&self) -> Point<T, Unit> { ... }
fn contains(&self, point: Point<T, Unit>) -> bool { ... }
fn intersection<R: Rectlike<T, Unit>>(
&self,
other: &R
) -> Option<ExtentsRect<T, Unit>> { ... }
fn union<R: Rectlike<T, Unit>>(
&self,
other: &R
) -> Option<ExtentsRect<T, Unit>> { ... }
}
Expand description
Functionalitiy that all rectangle types implement
Required methods
Returns this rectangle as a Rect
. The rectangle’s underlying data will
be unchanged by this operation.
fn as_extents(&self) -> ExtentsRect<T, Unit>
fn as_extents(&self) -> ExtentsRect<T, Unit>
Returns this rectangle converted to an ExtentsRect
.
Moves this rectangle by the vector provided.
Provided methods
fn to_non_empty(self) -> Option<Self>
fn to_non_empty(self) -> Option<Self>
Checks to see if this rect is empty. If it is, None is returned. If it isn’t, the rect is returned unmodified.
Returns true if point
is within this rectangle.
fn intersection<R: Rectlike<T, Unit>>(
&self,
other: &R
) -> Option<ExtentsRect<T, Unit>>
fn intersection<R: Rectlike<T, Unit>>(
&self,
other: &R
) -> Option<ExtentsRect<T, Unit>>
Returns the intersecting area between the two rectangles. If the rectangles do not intersect, None is returned.
Returns the union of the two rectangles. If both rectangles aren’t empty, the smallest rectangle that both rectangles can fit into will be returned. If either rectangle is empty, the other rectangle is returned unmodified.