wumpus-core-0.17.0: Pure Haskell PostScript and SVG generation.

PortabilityGHC with TypeFamilies and more
Stabilityunstable
Maintainerstephen.tetley@gmail.com

Wumpus.Core.BoundingBox

Contents

Description

Bounding box with no notion of 'empty'.

Empty pictures cannot be created with Wumpus. This greatly simplifies the implementation of pictures themselves and bounding boxes.

WARNING - this module is no so tightly designed, with some of the functions seeming superfluous in hindsight. It is likely to change in the future.

Synopsis

Types

data BoundingBox a Source

Bounding box of a picture, represented by the lower left and upper right corners.

We cannot construct empty pictures - so bounding boxes are spared the obligation to be empty. BoundingBox is an instance of the Semigroup class where append is the union operation.

Constructors

BBox 

Fields

ll_corner :: Point2 a
 
ur_corner :: Point2 a
 

Instances

Type class

class Boundary a whereSource

Type class extracting the bounding box of an object - Picture, Path etc.

Methods

boundary :: a -> BoundingBox (DUnit a)Source

Instances

(Fractional u, Ord u) => Boundary (PrimEllipse u) 
(Num u, Ord u) => Boundary (Path u) 
(Fractional u, Ord u) => Boundary (Primitive u) 
Boundary (Picture u) 

Operations

bbox :: Ord a => Point2 a -> Point2 a -> BoundingBox aSource

Contruct a bounding box, vis the BBox constructor with range checking on the corner points.

bbox throws an error if the width or height of the constructed bounding box is negative.

obbox :: Num a => a -> a -> BoundingBox aSource

Create a BoundingBox with bottom left corner at the origin, and dimensions w and h.

union :: Ord a => BoundingBox a -> BoundingBox a -> BoundingBox aSource

The union of two bounding boxes. This is also the append of BoundingBox's Semigroup instance.

trace :: (Num a, Ord a) => [Point2 a] -> BoundingBox aSource

Trace a list of points, retuning the BoundingBox that includes them.

trace throws a run-time error when supplied with the empty list.

corners :: BoundingBox a -> (Point2 a, Point2 a, Point2 a, Point2 a)Source

Generate all the corners of a bounding box, counter-clock wise from the bottom left, i.e. (bl, br, tr, tl).

withinBB :: Ord a => Point2 a -> BoundingBox a -> BoolSource

Within test - is the supplied point within the bounding box?

boundaryWidth :: Num a => BoundingBox a -> aSource

Extract the width of a bounding box.

boundaryHeight :: Num a => BoundingBox a -> aSource

Extract the height of a bounding box.

boundaryBottomLeft :: BoundingBox a -> Point2 aSource

Extract the bottom-left corner of the bounding box.

boundaryTopRight :: BoundingBox a -> Point2 aSource

Extract the top-right corner of the bounding box.

boundaryTopLeft :: BoundingBox a -> Point2 aSource

Extract the top-left corner of the bounding box.

boundaryBottomRight :: BoundingBox a -> Point2 aSource

Extract the bottom-right corner of the bounding box.

leftPlane :: BoundingBox a -> aSource

Extract the unit of the left vertical plane.

rightPlane :: BoundingBox a -> aSource

Extract the unit of the right vertical plane.

lowerPlane :: BoundingBox a -> aSource

Extract the unit of the lower horizontal plane.

upperPlane :: BoundingBox a -> aSource

Extract the unit of the upper horizontal plane.