diagrams-0.2.2.3: An EDSL for creating simple diagrams

Portabilityportable
Stabilityexperimental
Maintainerbyorgey@gmail.com

Graphics.Rendering.Diagrams.Layouts

Contents

Description

Layout definitions for Graphics.Rendering.Diagrams, an embedded domain-specific language (EDSL) for creating simple diagrams.

Synopsis

Union

(##) :: Diagram -> Diagram -> DiagramSource

Superimpose one diagram atop another. d1 ## d2 results in a diagram in which d2 is on top of d1 (i.e., d1 is drawn first, then d2).

union :: [Diagram] -> DiagramSource

Create a Diagram as a union of subdiagrams which will not be repositioned. If the subdiagrams overlap, they will appear with the first Diagram on the bottom, and the last on top.

unionA :: HAlignment -> VAlignment -> [Diagram] -> DiagramSource

Create a Diagram as a union of subdiagrams superimposed on one another, aligned vertically and/or horizontally.

Lists

(<>) :: Diagram -> Diagram -> DiagramSource

d1 <> d2 is a Diagram with d1 to the left of d2, aligned along their top edges.

(//) :: Diagram -> Diagram -> DiagramSource

d1 // d2 is a Diagram with d1 above d2, aligned along their left edges.

hcat :: [Diagram] -> DiagramSource

Lay out a list of Diagrams horizontally from left to right, aligned along their top edges.

vcat :: [Diagram] -> DiagramSource

Lay out a list of Diagrams vertically from top to bottom, aligned along their left edges.

hcatA :: VAlignment -> [Diagram] -> DiagramSource

Lay out a list of Diagrams horizontally from left to right, with the given vertical alignment (top, vcenter, or bottom).

vcatA :: HAlignment -> [Diagram] -> DiagramSource

Lay out a list of Diagrams vertically from top to bottom, with the given horizontal alignment (left, hcenter, or right).

hsepSource

Arguments

:: Double

amount of separation between each pair of diagrams

-> [Diagram] 
-> Diagram 

Lay out a list of Diagrams horizontally, aligned along their top edges, with a given amount of separation in between each pair.

vsepSource

Arguments

:: Double

amount of separation between each pair of diagrams

-> [Diagram] 
-> Diagram 

Lay out a list of Diagrams vertically, aligned along their left edges, with a given amount of separation in between each pair.

hsepASource

Arguments

:: Double

amount of separation between each pair of diagrams

-> VAlignment

alignment to use (top, vcenter, or bottom)

-> [Diagram] 
-> Diagram 

Lay out a list of Diagrams horizontally, with the given amount of separation in between each pair, using the given vertical alignment (top, vcenter, or bottom).

vsepASource

Arguments

:: Double

amount of separation between each pair of diagrams

-> HAlignment

alignment to use (left, hcenter, or right)

-> [Diagram] 
-> Diagram 

Lay out a list of Diagrams vertically, with the given amount of separation in between each pair, using the given horizontal alignment (left, hcenter, or right).

hdistribSource

Arguments

:: Double

How far from one diagram to the next?

-> HAlignment

Distribute according to which parts of the diagrams (left, hcenter, right)?

-> [Diagram] 
-> Diagram 

Distribute a list of Diagrams horizontally according to a regular spacing, aligned along their top edges.

vdistribSource

Arguments

:: Double

How far from one diagram to the next?

-> VAlignment

Distribute according to which parts of the diagrams (top, vcenter, bottom)?

-> [Diagram] 
-> Diagram 

Distribute a list of Diagrams vertically according to a regular spacing, aligned along their left edges.

hdistribASource

Arguments

:: Double

How far from one diagram to the next?

-> HAlignment

Distribute according to which parts of the diagrams (left, hcenter, right)?

-> VAlignment

alignment to use (top, vcenter, bottom)

-> [Diagram] 
-> Diagram 

Distribute a list of Diagrams horizontally according to a regular spacing, with the given alignment.

vdistribASource

Arguments

:: Double

How far from one diagram to the next?

-> VAlignment

Distribute according to which parts of the diagrams (top, vcenter, bottom)?

-> HAlignment

alignment to use (left, hcenter, right)

-> [Diagram] 
-> Diagram 

Distribute a list of Diagrams vertically according to a regular spacing, with the given alignment.

position :: [(Point, Diagram)] -> DiagramSource

Create a diagram from a list of subdiagrams with explicit positions in a local coordinate system. Each subdiagram will be positioned with its center at the corresponding position. position is equivalent to positionA hcenter vcenter.

positionA :: HAlignment -> VAlignment -> [(Point, Diagram)] -> DiagramSource

Create a diagram from a list of subdiagrams with explicit positions in a local coordinate system. The alignment options specify what part of each subdiagram should be placed on the corresponding position. For example, positionA left top will position the top left corner of each subdiagram at the corresponding point.

positionAlong :: [Diagram] -> Path -> DiagramSource

Create a diagram from a list of subdiagrams and a given path, by positioning the subdiagrams at successive vertices of the path. If there are more diagrams than path vertices, the extra diagrams will be discarded.

positionAlongA :: HAlignment -> VAlignment -> [Diagram] -> Path -> DiagramSource

A version of positionAlong with explicit alignment.

grid :: [[Diagram]] -> DiagramSource

Align diagrams into a grid, with each item centered horizontally and vertically Warning: there is currently an exponential performace blowup if you nest grids. (exponential in how deep the nesting is).

gridA :: HAlignment -> VAlignment -> [[Diagram]] -> DiagramSource

Align diagrams into a grid with each item aligned as specified. Warning: there is currently an exponential performace blowup if you nest grids (exponential in how deep the nesting is).

gridAs :: [[(HAlignment, VAlignment)]] -> [[Diagram]] -> DiagramSource

Align diagrams into a grid, specifying individual alignments for each item. Warning: there is currently an exponential performace blowup if you nest grids (exponential in how deep the nesting is).

type VAlignment = AlignmentSource

Vertical alignment.

type HAlignment = AlignmentSource

Horizontal alignment.

Tree

treeSource

Arguments

:: Double

separation between layers

-> Double

separation between siblings

-> Tree Diagram 
-> Diagram 

Lay out a Tree (from Data.Tree) of Diagrams in a top-down fashion. This layout is experimental; future releases of the Diagrams library are planned which will be able to automatically draw edges between nodes in the tree.

Miscellaneous

pad :: Double -> Double -> Diagram -> DiagramSource

Add extra padding to a diagram. pad w h d is a diagram which is the same as d, but with w units added to the width and h units added to the height, with d centered in the available space. Thus pad w h is equivalent to padA w h hcenter vcenter.

padA :: Double -> Double -> HAlignment -> VAlignment -> Diagram -> DiagramSource

Add extra padding to a diagram, aligning the diagram as indicated within the avilable space.

showBBox :: Diagram -> DiagramSource

Show a rectangle denoting a diagram's bounding box, in addition to the diagram itself.

showBBoxes :: Diagram -> DiagramSource

Show the bounding boxes of a diagram and all its subdiagrams.

withSizeSource

Arguments

:: (Double -> Double -> Diagram)

Function for new diagram

-> Diagram

Old diagram

-> Diagram 

Create one diagram using the current size of another. The new diagram is returned, the old one is discarded.