Maintainer  diagramsdiscuss@googlegroups.com 

This module defines the twodimensional vector space R^2, twodimensional transformations, and various predefined twodimensional shapes. This module reexports useful functionality from a group of more specific modules:
 Diagrams.TwoD.Types defines basic types for twodimensional diagrams.
 Diagrams.TwoD.Align defines alignment combinators specialized to two dimensions (see Diagrams.Align for more general alignment).
 Diagrams.TwoD.Combinators defines ways of combining diagrams specialized to two dimensions (see also Diagrams.Combinators for more general combining).
 Diagrams.TwoD.Transform defines R^2specific transformations such as rotation by an angle, and scaling, translation, and reflection in the X and Y directions.
 Diagrams.TwoD.Ellipse defines ellipses.
 Diagrams.TwoD.Arc defines circular arcs.
 Diagrams.TwoD.Path exports various operations on twodimensional paths when viewed as regions of the plane.
 Diagrams.TwoD.Shapes defines other twodimensional shapes, e.g. various polygons.
 Diagrams.TwoD.Util defines some twodimensional utilities, such as unit vectors and functions for computing the size and extent of diagrams in R^2.
 Diagrams.TwoD.Model defines some aids for visualizing diagrams' internal model (local origins, bounding regions, etc.)
 type R2 = (Double, Double)
 type P2 = Point R2
 type Angle = Double
 unitX :: R2
 unitY :: R2
 stroke :: Renderable (Path R2) b => Path R2 > Diagram b R2
 strokeT :: Renderable (Path R2) b => Trail R2 > Diagram b R2
 hrule :: (Backend b R2, Renderable (Path R2) b) => Double > Diagram b R2
 vrule :: (Backend b R2, Renderable (Path R2) b) => Double > Diagram b R2
 circle :: (Backend b R2, Renderable Ellipse b) => Diagram b R2
 ellipse :: (Backend b R2, Renderable Ellipse b) => Double > Diagram b R2
 arc :: Angle > Angle > Path R2
 polygon :: (Backend b R2, Renderable (Path R2) b) => PolygonOpts > Diagram b R2
 polygonPath :: (PathLike p, V p ~ R2) => PolygonOpts > p
 polygonVertices :: PolygonOpts > [P2]
 data PolygonOpts = PolygonOpts {
 sides :: Int
 edgeSkip :: Int
 orientation :: PolygonOrientation
 data PolygonOrientation
 square :: (Backend b R2, Renderable (Path R2) b) => Diagram b R2
 starPolygon :: (Backend b R2, Renderable (Path R2) b) => Int > Int > Diagram b R2
 eqTriangle :: (Backend b R2, Renderable (Path R2) b) => Diagram b R2
 rotation :: Angle > Transformation R2
 rotate :: (Transformable t, V t ~ R2) => Angle > t > t
 rotationBy :: Double > Transformation R2
 rotateBy :: (Transformable t, V t ~ R2) => Angle > t > t
 scalingX :: Double > Transformation R2
 scaleX :: (Transformable t, V t ~ R2) => Double > t > t
 scalingY :: Double > Transformation R2
 scaleY :: (Transformable t, V t ~ R2) => Double > t > t
 scaling :: (HasLinearMap v, Fractional (Scalar v)) => Scalar v > Transformation v
 scale :: (Transformable t, Fractional (Scalar (V t))) => Scalar (V t) > t > t
 translationX :: Double > Transformation R2
 translateX :: (Transformable t, V t ~ R2) => Double > t > t
 translationY :: Double > Transformation R2
 translateY :: (Transformable t, V t ~ R2) => Double > t > t
 translation :: HasLinearMap v => v > Transformation v
 translate :: (Transformable t, HasLinearMap (V t)) => V t > t > t
 reflectionX :: Transformation R2
 reflectX :: (Transformable t, V t ~ R2) => t > t
 reflectionY :: Transformation R2
 reflectY :: (Transformable t, V t ~ R2) => t > t
 strutX :: (Backend b R2, Monoid m) => Double > AnnDiagram b R2 m
 strutY :: (Backend b R2, Monoid m) => Double > AnnDiagram b R2 m
 (===) :: (HasOrigin a, Boundable a, V a ~ R2, Monoid a) => a > a > a
 () :: (HasOrigin a, Boundable a, V a ~ R2, Monoid a) => a > a > a
 hcat :: (HasOrigin a, Boundable a, Qualifiable a, V a ~ R2, Monoid a) => [a] > a
 hcat' :: (HasOrigin a, Boundable a, Qualifiable a, V a ~ R2, Monoid a) => CatOpts R2 > [a] > a
 vcat :: (HasOrigin a, Boundable a, Qualifiable a, V a ~ R2, Monoid a) => [a] > a
 vcat' :: (HasOrigin a, Boundable a, Qualifiable a, V a ~ R2, Monoid a) => CatOpts R2 > [a] > a
 alignL :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 alignR :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 alignT :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 alignB :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 alignTL :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 alignTR :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 alignBL :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 alignBR :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 alignX :: (HasOrigin a, Boundable a, V a ~ R2) => Rational > a > a
 alignY :: (HasOrigin a, Boundable a, V a ~ R2) => Rational > a > a
 centerX :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 centerY :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 centerXY :: (HasOrigin a, Boundable a, V a ~ R2) => a > a
 width :: AnnDiagram b R2 m > Double
 height :: AnnDiagram b R2 m > Double
 size2D :: AnnDiagram b R2 m > (Double, Double)
 extentX :: AnnDiagram b R2 a > (Double, Double)
 extentY :: AnnDiagram b R2 a > (Double, Double)
 center2D :: AnnDiagram b R2 a > P2
 showOrigin :: (Renderable Ellipse b, Backend b R2, Monoid m) => AnnDiagram b R2 m > AnnDiagram b R2 m
R^2
Paths
stroke :: Renderable (Path R2) b => Path R2 > Diagram b R2Source
Convert a path into a diagram. The resulting diagram has the names 0, 1, ... assigned to each of the path's vertices.
Note that a bug in GHC 7.0.1 causes a context stack overflow when
inferring the type of stroke
. The solution is to give a type
signature to expressions involving stroke
, or (recommended)
upgrade GHC (the bug is fixed in 7.0.2 onwards).
strokeT :: Renderable (Path R2) b => Trail R2 > Diagram b R2Source
A composition of stroke
and pathFromTrail
for conveniently
converting a trail directly into a diagram.
Note that a bug in GHC 7.0.1 causes a context stack overflow when
inferring the type of stroke
and hence of strokeT
as well.
The solution is to give a type signature to expressions involving
strokeT
, or (recommended) upgrade GHC (the bug is fixed in 7.0.2
onwards).
Shapes
Rules
hrule :: (Backend b R2, Renderable (Path R2) b) => Double > Diagram b R2Source
Create a centered horizontal line of the given length.
vrule :: (Backend b R2, Renderable (Path R2) b) => Double > Diagram b R2Source
Create a centered vertical line of the given length.
Circleish things
ellipse :: (Backend b R2, Renderable Ellipse b) => Double > Diagram b R2Source
ellipse e
constructs an ellipse with eccentricity e
by
scaling the unit circle in the X direction. The eccentricity must
be within the interval [0,1).
arc :: Angle > Angle > Path R2Source
Given a start angle s
and an end angle e
(both in radians),
is the path of a radius one arc counterclockwise
between the two angles.
arc
s e
General polygons
polygon :: (Backend b R2, Renderable (Path R2) b) => PolygonOpts > Diagram b R2Source
Create a regular polygon from the given options.
polygonPath :: (PathLike p, V p ~ R2) => PolygonOpts > pSource
Create a closed regular polygonal path from the given options.
polygonVertices :: PolygonOpts > [P2]Source
Generate the vertices of a regular polygon from the given options.
data PolygonOpts Source
PolygonOpts  

data PolygonOrientation Source
Determine how a polygon should be oriented.
Special polygons
square :: (Backend b R2, Renderable (Path R2) b) => Diagram b R2Source
A sqaure with its center at the origin and sides of length 1, oriented parallel to the axes.
starPolygon :: (Backend b R2, Renderable (Path R2) b) => Int > Int > Diagram b R2Source
starPolygon p q
creates a star polygon, where p
indicates the
number of vertices, and an edge connects every q
th vertex.
eqTriangle :: (Backend b R2, Renderable (Path R2) b) => Diagram b R2Source
An equilateral triangle, with radius 1 and base parallel to the xaxis.
Transformations
Rotation
rotation :: Angle > Transformation R2Source
Create a transformation which performs a rotation by the given angle in radians.
rotationBy :: Double > Transformation R2Source
Create a transformation which performs a rotation by the given
fraction of a circle. For example, rotationBy (1/4)
rotates by
one quarter of a circle (i.e. 90 degrees, i.e. pi/2 radians).
rotateBy :: (Transformable t, V t ~ R2) => Angle > t > tSource
Rotate by the given fraction of a circle.
Scaling
scalingX :: Double > Transformation R2Source
Construct a transformation which scales by the given factor in the x (horizontal) direction.
scaleX :: (Transformable t, V t ~ R2) => Double > t > tSource
Scale a diagram by the given factor in the x (horizontal)
direction. To scale uniformly, use
Graphics.Rendering.Diagrams.Transform.scale
.
scalingY :: Double > Transformation R2Source
Construct a transformation which scales by the given factor in the y (vertical) direction.
scaleY :: (Transformable t, V t ~ R2) => Double > t > tSource
Scale a diagram by the given factor in the y (vertical)
direction. To scale uniformly, use
Graphics.Rendering.Diagrams.Transform.scale
.
scaling :: (HasLinearMap v, Fractional (Scalar v)) => Scalar v > Transformation v
Create a uniform scaling transformation.
scale :: (Transformable t, Fractional (Scalar (V t))) => Scalar (V t) > t > t
Scale uniformly in every dimension by the given scalar.
Translation
translationX :: Double > Transformation R2Source
Construct a transformation which translates by the given distance in the x (horizontal) direction.
translateX :: (Transformable t, V t ~ R2) => Double > t > tSource
Translate a diagram by the given distance in the x (horizontal) direction.
translationY :: Double > Transformation R2Source
Construct a transformation which translates by the given distance in the y (vertical) direction.
translateY :: (Transformable t, V t ~ R2) => Double > t > tSource
Translate a diagram by the given distance in the y (vertical) direction.
translation :: HasLinearMap v => v > Transformation v
Create a translation.
translate :: (Transformable t, HasLinearMap (V t)) => V t > t > t
Translate by a vector.
Reflection
reflectionX :: Transformation R2Source
Construct a transformation which flips a diagram from left to right, i.e. sends the point (x,y) to (x,y).
reflectX :: (Transformable t, V t ~ R2) => t > tSource
Flip a diagram from left to right, i.e. send the point (x,y) to (x,y).
reflectionY :: Transformation R2Source
Construct a transformation which flips a diagram from top to bottom, i.e. sends the point (x,y) to (x,y).
reflectY :: (Transformable t, V t ~ R2) => t > tSource
Flip a diagram from top to bottom, i.e. send the point (x,y) to (x,y).
Combinators
strutX :: (Backend b R2, Monoid m) => Double > AnnDiagram b R2 mSource
strutX d
is an empty diagram with width d
and height 0.
strutY :: (Backend b R2, Monoid m) => Double > AnnDiagram b R2 mSource
strutY d
is an empty diagram with height d
and width 0.
(===) :: (HasOrigin a, Boundable a, V a ~ R2, Monoid a) => a > a > aSource
Place two diagrams (or other boundable objects) vertically adjacent to one another, with the first diagram above the second. Since Haskell ignores whitespace in expressions, one can thus write
c === d
to place c
above d
.
() :: (HasOrigin a, Boundable a, V a ~ R2, Monoid a) => a > a > aSource
Place two diagrams (or other boundable objects) horizontally adjacent to one another, with the first diagram to the left of the second.
hcat :: (HasOrigin a, Boundable a, Qualifiable a, V a ~ R2, Monoid a) => [a] > aSource
Lay out a list of boundable objects in a row from left to right, so that their local origins lie along a single horizontal line, with successive bounding regions tangent to one another.
 For more control over the spacing, see
hcat'
.  To align the diagrams vertically (or otherwise), use alignment
combinators (such as
alignT
oralignB
) from Diagrams.TwoD.Align before applyinghcat
.  For nonaxisaligned layout, see
cat
.
hcat' :: (HasOrigin a, Boundable a, Qualifiable a, V a ~ R2, Monoid a) => CatOpts R2 > [a] > aSource
vcat :: (HasOrigin a, Boundable a, Qualifiable a, V a ~ R2, Monoid a) => [a] > aSource
Lay out a list of boundable objects in a column from top to bottom, so that their local origins lie along a single vertical line, with successive bounding regions tangent to one another.
 For more control over the spacing, see
vcat'
.  To align the diagrams horizontally (or otherwise), use alignment
combinators (such as
alignL
oralignR
) from Diagrams.TwoD.Align before applyingvcat
.  For nonaxisaligned layout, see
cat
.
vcat' :: (HasOrigin a, Boundable a, Qualifiable a, V a ~ R2, Monoid a) => CatOpts R2 > [a] > aSource
Alignment
alignL :: (HasOrigin a, Boundable a, V a ~ R2) => a > aSource
Align along the left edge, i.e. translate the diagram in a horizontal direction so that the local origin is on the left edge of the bounding region.
alignX :: (HasOrigin a, Boundable a, V a ~ R2) => Rational > a > aSource
alignX
moves the local origin horizontally as follows:

alignX (1)
moves the local origin to the left edge of the bounding region; 
align 1
moves the local origin to the right edge;  any other argument interpolates linearly between these. For
example,
alignX 0
centers,alignX 2
moves the origin one "radius" to the right of the right edge, and so on.
alignY :: (HasOrigin a, Boundable a, V a ~ R2) => Rational > a > aSource
Like alignX
, but moving the local origin vertically, with an
argument of 1
corresponding to the top edge and (1)
corresponding
to the bottom edge.
centerX :: (HasOrigin a, Boundable a, V a ~ R2) => a > aSource
Center the local origin along the Xaxis.
centerY :: (HasOrigin a, Boundable a, V a ~ R2) => a > aSource
Center the local origin along the Yaxis.
centerXY :: (HasOrigin a, Boundable a, V a ~ R2) => a > aSource
Center along both the X and Yaxes.
Utilities
width :: AnnDiagram b R2 m > DoubleSource
Compute the width of a diagram.
height :: AnnDiagram b R2 m > DoubleSource
Compute the height of a diagram.
extentX :: AnnDiagram b R2 a > (Double, Double)Source
Compute the absolute xcoordinate range of a diagram in R2, in the form (lo,hi).
extentY :: AnnDiagram b R2 a > (Double, Double)Source
Compute the absolute ycoordinate range of a diagram in R2, in the form (lo,hi).
center2D :: AnnDiagram b R2 a > P2Source
Compute the point at the center (in the x and ydirections) of a diagram.
Visual aids for understanding the internal model
showOrigin :: (Renderable Ellipse b, Backend b R2, Monoid m) => AnnDiagram b R2 m > AnnDiagram b R2 mSource
Mark the origin of a diagram by placing a red dot 1/50th its size.