Trait iron_shapes::traits::TryBoundingBox [−][src]
Try the calculation of the 'bounding box', i.e. the smallest rectangle that contains the geometrical object. In some cases this is not always possible, so the try might fail. For instance a set of polygons does not have a bounding box if the set is empty.
Required methods
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
Return the bounding box of this geometry if a bounding box is defined.
Implementors
impl<T> TryBoundingBox<T> for PointString<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
Compute the bounding box of all the points in this string.
Returns None
if the string is empty.
Examples
use iron_shapes::point_string::PointString; use iron_shapes::traits::TryBoundingBox; use iron_shapes::rect::Rect; let coords = vec![(0, 0), (1, 0), (2, 1), (-1, -3)]; let point_string = PointString::new(coords); assert_eq!(point_string.try_bounding_box(), Some(Rect::new((2, 1), (-1, -3))));
impl<T> TryBoundingBox<T> for Polygon<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
impl<T> TryBoundingBox<T> for SimplePolygon<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
impl<T> TryBoundingBox<T> for SimpleRPolygon<T> where
T: CoordinateType,
[src]
T: CoordinateType,
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
impl<T: CoordinateType> TryBoundingBox<T> for Geometry<T>
[src]
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
Calculate the bounding box of this geometrical shape by calling the bounding box method of the concrete type.
impl<T: CoordinateType> TryBoundingBox<T> for Edge<T>
[src]
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
Get bounding box of edge (always exists).
impl<T: CoordinateType> TryBoundingBox<T> for Path<T>
[src]
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
Compute the bounding box of this path. The returned bounding box is not necessarily the smallest bounding box.
TODO: Find a better approximation.
impl<T: CoordinateType> TryBoundingBox<T> for Rect<T>
[src]
fn try_bounding_box(&self) -> Option<Rect<T>>
[src]
Get bounding box of rectangle (always exists).