Struct tree_layout::Rectangle
source · pub struct Rectangle<T> {
pub min: Point<T>,
pub max: Point<T>,
}
Expand description
Fields§
§min: Point<T>
origin x points of the rectangle
max: Point<T>
origin y points of the rectangle
Implementations§
source§impl<T> Rectangle<T>
impl<T> Rectangle<T>
Constructors for rectangle_2d
sourcepub fn from_anchor<P>(origin: P, width: T, height: T) -> Rectangle<T>where
T: Clone + Add<Output = T>,
P: Into<Point<T>>,
pub fn from_anchor<P>(origin: P, width: T, height: T) -> Rectangle<T>where T: Clone + Add<Output = T>, P: Into<Point<T>>,
sourcepub fn from_center<P>(center: P, width: T, height: T) -> Rectangle<T>where
T: Clone + One + Add<Output = T> + Sub<Output = T> + Div<Output = T>,
P: Into<Point<T>>,
pub fn from_center<P>(center: P, width: T, height: T) -> Rectangle<T>where T: Clone + One + Add<Output = T> + Sub<Output = T> + Div<Output = T>, P: Into<Point<T>>,
pub fn from_origin(width: T, height: T) -> Rectangle<T>where T: Clone + Zero<Output = T> + One + Add + Sub<Output = T> + Div<Output = T>,
source§impl<T> Rectangle<T>
impl<T> Rectangle<T>
sourcepub fn width(&self) -> Twhere
T: Clone + Sub<Output = T>,
pub fn width(&self) -> Twhere T: Clone + Sub<Output = T>,
Get the width of the rectangle
Examples
let rect = Rectangle::new(0.0, 0.0, 1.0, 1.0);
assert_eq!(rect.width(), 1.0);
sourcepub fn height(&self) -> Twhere
T: Clone + Sub<Output = T>,
pub fn height(&self) -> Twhere T: Clone + Sub<Output = T>,
Get the height of the rectangle
Examples
let rect = Rectangle::new(0.0, 0.0, 1.0, 1.0);
assert_eq!(rect.height(), 1.0);
sourcepub fn origin(&self) -> Point<T>where
T: Clone,
pub fn origin(&self) -> Point<T>where T: Clone,
Get the origin of the rectangle
Examples
let rect = Rectangle::from_center((0.0, 0.0), 1.0,1.0);
assert_eq!(rect.origin(), -Point::new(0.5, 0.5));
sourcepub fn center(&self) -> Point<T>where
T: Clone + One + Add<Output = T> + Sub<Output = T> + Div<Output = T>,
pub fn center(&self) -> Point<T>where T: Clone + One + Add<Output = T> + Sub<Output = T> + Div<Output = T>,
Get the center point of the rectangle
Examples
let rect = Rectangle::new(0.0, 0.0, 1.0, 1.0);
assert_eq!(rect.center(), Point::new(0.5, 0.5));
pub fn contains(&self, point: &Point<T>) -> boolwhere T: Clone + PartialOrd,
Trait Implementations§
source§impl<T> PartialEq for Rectangle<T>where
T: PartialEq,
impl<T> PartialEq for Rectangle<T>where T: PartialEq,
source§impl<T> Shape2D for Rectangle<T>where
T: Signed + Clone + PartialOrd,
impl<T> Shape2D for Rectangle<T>where T: Signed + Clone + PartialOrd,
source§fn is_valid(&self) -> bool
fn is_valid(&self) -> bool
A valid rectangle means it has a positive area.
Examples
let rect = Rectangle::new(0.0, 0.0, 1.0, 1.0);
assert!(rect.is_valid());
source§fn vertices<'a>(
&'a self,
_: usize
) -> <Rectangle<T> as Shape2D>::VertexIterator<'a>
fn vertices<'a>( &'a self, _: usize ) -> <Rectangle<T> as Shape2D>::VertexIterator<'a>
Returns four vertices counterclockwise in the ↑Y coordinate system
source§fn edges<'a>(&'a self, _: usize) -> <Rectangle<T> as Shape2D>::LineIterator<'a>
fn edges<'a>(&'a self, _: usize) -> <Rectangle<T> as Shape2D>::LineIterator<'a>
Returns four edges counterclockwise in the ↑Y coordinate system
§type VertexIterator<'a> = IntoIter<Point<T>>
where
T: 'a
type VertexIterator<'a> = IntoIter<Point<T>> where T: 'a
The value type of the shape.
§type LineIterator<'a> = IntoIter<Line<T>>
where
T: 'a
type LineIterator<'a> = IntoIter<Line<T>> where T: 'a
The value type of the shape.
impl<T> Copy for Rectangle<T>where T: Copy,
impl<T> Eq for Rectangle<T>where T: Eq,
impl<T> StructuralEq for Rectangle<T>
impl<T> StructuralPartialEq for Rectangle<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Rectangle<T>where T: RefUnwindSafe,
impl<T> Send for Rectangle<T>where T: Send,
impl<T> Sync for Rectangle<T>where T: Sync,
impl<T> Unpin for Rectangle<T>where T: Unpin,
impl<T> UnwindSafe for Rectangle<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
Mutably borrows from an owned value. Read more