diagrams-lib-0.5: Embedded domain-specific language for declarative graphics

Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellSafe-Infered

Diagrams.BoundingBox

Contents

Description

Definitions and functions for working with bounding boxes.

Synopsis

Bounding boxes

data BoundingBox v Source

A bounding box is an axis-aligned region determined by two points indicating its "lower" and "upper" corners.

Constructing bounding boxes

fromCorners :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => Point v -> Point v -> BoundingBox vSource

Create a bounding box from any two opposite corners.

fromPoint :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => Point v -> BoundingBox vSource

Create a degenerate bounding "box" containing only a single point.

fromPoints :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => [Point v] -> Maybe (BoundingBox v)Source

Create the smallest bounding box containing all the given points.

boundingBox :: forall a. (Enveloped a, HasBasis (V a), Ord (Basis (V a))) => a -> BoundingBox (V a)Source

Create a bounding box for any boundable object (such as a diagram or path).

Queries on bounding boxes

getCorners :: BoundingBox v -> (Point v, Point v)Source

Gets the lower and upper corners that define the bounding box.

getAllCorners :: (HasBasis v, AdditiveGroup (Scalar v), Ord (Basis v)) => BoundingBox v -> [Point v]Source

Computes all of the corners of the bounding box.

boxExtents :: AdditiveGroup v => BoundingBox v -> vSource

Get the size of the bounding box - the vector from the lesser to the greater point.

boxTransform :: (AdditiveGroup v, HasLinearMap v, Fractional (Scalar v), AdditiveGroup (Scalar v), Ord (Basis v)) => BoundingBox v -> BoundingBox v -> Transformation vSource

Create a transformation mapping points from one bounding box to the other.

boxFit :: (Enveloped a, Transformable a, Ord (Basis (V a))) => BoundingBox (V a) -> a -> aSource

Transforms a boundable thing to fit within a BoundingBox.

contains :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => BoundingBox v -> Point v -> BoolSource

Check whether a point is contained in a bounding box (including its edges).

contains' :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => BoundingBox v -> Point v -> BoolSource

Check whether a point is strictly contained in a bounding box.

inside :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => BoundingBox v -> BoundingBox v -> BoolSource

Test whether the first bounding box is contained inside the second.

inside' :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => BoundingBox v -> BoundingBox v -> BoolSource

Test whether the first bounding box is strictly contained inside the second.

outside :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => BoundingBox v -> BoundingBox v -> BoolSource

Test whether the first bounding box lies outside the second (although they may intersect in their boundaries).

outside' :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => BoundingBox v -> BoundingBox v -> BoolSource

Test whether the first bounding box lies strictly outside the second (they do not intersect at all).

Operations on bounding boxes

union :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => BoundingBox v -> BoundingBox v -> BoundingBox vSource

Form the smallest bounding box containing the given two bounding boxes.

intersection :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => BoundingBox v -> BoundingBox v -> Maybe (BoundingBox v)Source

Form the largest bounding box contained within this given two bounding boxes, or Nothing if the two bounding boxes do not overlap at all.

unions :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => [BoundingBox v] -> Maybe (BoundingBox v)Source

Compute the smallest bounding box containing all the given bounding boxes (or Nothing if the list is empty).

intersections :: (HasBasis v, Ord (Basis v), AdditiveGroup (Scalar v), Ord (Scalar v)) => [BoundingBox v] -> Maybe (BoundingBox v)Source

Compute the largest bounding box contained in all the given bounding boxes (or Nothing is the list is empty).