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

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

Wumpus.Core.PictureLanguage

Contents

Description

Type classes and derived functions to compose 2D pictures.

The operations are fairly standard - see Regions in Paul Hudak's 'The Haskell School of Expression' and the pretty printing libraries wl-pprint and Text.PrettyPrint.HughesPJ (pretty printing combinators are some ways in 'One and a half D' as they have horizontal operations but only carriage return in the vertical.

Synopsis

Data types for alignment

data HAlign Source

Horizontal alignment - align to the top, center or bottom.

Constructors

HTop 
HCenter 
HBottom 

Instances

data VAlign Source

Vertical alignment - align to the left, center or bottom.

Constructors

VLeft 
VCenter 
VRight 

Instances

Type family and classes

type family PUnit a Source

The type of points within a Picture.

class Horizontal a whereSource

Move horizontally.

Methods

moveH :: PUnit a -> a -> aSource

leftBound :: a -> PUnit aSource

rightBound :: a -> PUnit aSource

Instances

(Num u, Ord u) => Horizontal (Picture u) 

class Vertical a whereSource

Move vertically.

Methods

moveV :: PUnit a -> a -> aSource

topBound :: a -> PUnit aSource

bottomBound :: a -> PUnit aSource

Instances

(Num u, Ord u) => Vertical (Picture u) 

class Composite a whereSource

 a `over` b

Place 'picture' a over b. The idea of over here is the same as z-ordering in 2D design programs. Implementations of this class should 'draw' picture a over b but move neither.

Similarly beneath should 'draw' the first picture behind the second but move neither.

Beneath has a default definition:

 beneath = flip over

Methods

over :: a -> a -> aSource

beneath :: a -> a -> aSource

Instances

(Num u, Ord u) => Composite (Picture u) 

class Move a whereSource

Move in both the horizontal and vertical.

Methods

move :: PUnit a -> PUnit a -> a -> aSource

Instances

(Num u, Ord u, Horizontal (Picture u), Vertical (Picture u)) => Move (Picture u) 

class Blank a whereSource

Create a picture that has no content but occupies space (i.e. it has a bounding box).

Methods

blank :: PUnit a -> PUnit a -> aSource

Instances

(Num u, Ord u) => Blank (Picture u) 

Bounds

Corresponding operations are available on bounding boxes - the definitions here have different type class obligations.

center :: (Horizontal a, Vertical a, Fractional u, u ~ PUnit a) => a -> Point2 uSource

The center of a picture.

topleft :: (Horizontal a, Vertical a, u ~ PUnit a) => a -> Point2 uSource

Extract the top-left corner.

topright :: (Horizontal a, Vertical a, u ~ PUnit a) => a -> Point2 uSource

Extract the top-right corner.

bottomleft :: (Horizontal a, Vertical a, u ~ PUnit a) => a -> Point2 uSource

Extract the bottom-left corner.

bottomright :: (Horizontal a, Vertical a, u ~ PUnit a) => a -> Point2 uSource

Extract the bottom-right corner.

Composition

(-@-) :: (Horizontal a, Vertical a, Composite a, Move a, Fractional u, u ~ PUnit a) => a -> a -> aSource

 a -@- b

Center a on top of b, a is potentially moved and drawn over b.

(->-) :: (Horizontal a, Composite a, Num u, u ~ PUnit a) => a -> a -> aSource

 a ->- b

Horizontal composition - move b, placing it to the right of a.

(-<-) :: (Horizontal a, Composite a, Num u, u ~ PUnit a) => a -> a -> aSource

 a -<- b

Horizontal composition - move a, placing it to the left of b.

(-//-) :: (Vertical a, Composite a, Num u, u ~ PUnit a) => a -> a -> aSource

 a -//- b

Vertical composition - move b, placing it below a.

above :: (Vertical a, Composite a, Num u, u ~ PUnit a) => a -> a -> aSource

 a `above` b

Vertical composition - move a, placing it above b.

below :: (Vertical a, Composite a, Num u, u ~ PUnit a) => a -> a -> aSource

 a `below` b

Vertical composition - move a, placing it below b

at :: (Move a, u ~ PUnit a) => a -> Point2 u -> aSource

Place the picture at the supplied point.

stackOnto :: Composite a => [a] -> a -> aSource

 xs `stackOnto` a

Stack the list of pictures xs over a.

Note, the first picture in the list is drawn at the top, the last picture is draw over a.

hcat :: (Horizontal a, Composite a, Num u, u ~ PUnit a) => a -> [a] -> aSource

 x ->- xs

Concatenate the list pictures xs horizontally with (->-) starting at x.

vcat :: (Vertical a, Composite a, Num u, u ~ PUnit a) => a -> [a] -> aSource

 x -//- xs

Concatenate the list of pictures xs vertically with (-//-) starting at x.

stackOntoCenter :: (Horizontal a, Vertical a, Composite a, Move a, Fractional u, u ~ PUnit a) => [a] -> a -> aSource

Stack pictures centered ontop of each other - the first picture in the list is drawn at the top, last picture is on drawn at the bottom.

hspace :: (Num u, Composite a, Horizontal a, Blank a, u ~ PUnit a) => u -> a -> a -> aSource

 hspace n a b

Concatenate the pictures a and b with (->-) - injecting a space of n units to separate the pictures.

vspace :: (Num u, Composite a, Vertical a, Blank a, u ~ PUnit a) => u -> a -> a -> aSource

 vspace n a b

Concatenate the pictures a and b with (-//-) - injecting a space of n units to separate the pictures.

hsep :: (Num u, Composite a, Horizontal a, Blank a, u ~ PUnit a) => u -> a -> [a] -> aSource

 hsep n x xs

Concatenate the list of pictures xs horizontally with hspace starting at x. The pictures are interspersed with spaces of n units.

vsep :: (Num u, Composite a, Vertical a, Blank a, u ~ PUnit a) => u -> a -> [a] -> aSource

 vsep n x xs

Concatenate the list of pictures xs vertically with vspace starting at x. The pictures are interspersed with spaces of n units.

Compose with alignment

alignH :: (Fractional u, Composite a, Horizontal a, Vertical a, Move a, u ~ PUnit a) => HAlign -> a -> a -> aSource

 alignH z a b

Move picture b up or down to be horizontally aligned along a line from the top, center or bottom of picture a

alignV :: (Fractional u, Composite a, Horizontal a, Vertical a, Move a, u ~ PUnit a) => VAlign -> a -> a -> aSource

 alignV z a b

Move picture b left or right to be vertically aligned along a line from the left side, center or right side of picture a

hcatA :: (Fractional u, Horizontal a, Vertical a, Composite a, Move a, u ~ PUnit a) => HAlign -> a -> [a] -> aSource

Variant of hcat that aligns the pictures as well as concatenating them.

vcatA :: (Fractional u, Horizontal a, Vertical a, Composite a, Move a, u ~ PUnit a) => VAlign -> a -> [a] -> aSource

Variant of vcat that aligns the pictures as well as concatenating them.

hsepA :: (Fractional u, Horizontal a, Vertical a, Composite a, Move a, Blank a, u ~ PUnit a) => HAlign -> u -> a -> [a] -> aSource

Variant of hsep that aligns the pictures as well as concatenating and spacing them.

vsepA :: (Fractional u, Horizontal a, Vertical a, Composite a, Move a, Blank a, u ~ PUnit a) => VAlign -> u -> a -> [a] -> aSource

Variant of vsep that aligns the pictures as well as concatenating and spacing them.