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

Diagrams.TwoD.Shapes

Description

Various two-dimensional shapes.

Synopsis

Miscellaneous

hrule :: (PathLike p, V p ~ R2) => Double -> pSource

Create a centered horizontal (L-R) line of the given length.

vrule :: (PathLike p, V p ~ R2) => Double -> pSource

Create a centered vertical (T-B) line of the given length.

General polygons

polygon :: (PathLike p, V p ~ R2) => PolygonOpts -> pSource

Create a closed regular polygon from the given options.

Generate the vertices of a regular polygon from the given options.

Constructors

 PolygonOpts Fieldssides :: IntNumber of sides; the default is 5. edgeSkip :: IntCreate star polygons by setting the edge skip to some number other than 1 (the default). With an edge skip of n, edges will connect every nth vertex. orientation :: PolygonOrientationDetermine how the polygon should be oriented.

Determine how a polygon should be oriented.

Constructors

 NoOrient No special orientation; one vertex will be at (1,0). This is the default. OrientToX Orient so the botommost edge is parallel to the x-axis. OrientToY Orient so the leftmost edge is parallel to the y-axis.

Special polygons

unitSquare :: (Transformable p, PathLike p, V p ~ R2) => pSource

A sqaure with its center at the origin and sides of length 1, oriented parallel to the axes.

square :: (PathLike p, Transformable p, V p ~ R2) => Double -> pSource

A sqaure with its center at the origin and sides of the given length, oriented parallel to the axes.

rect :: (PathLike p, Transformable p, V p ~ R2) => Double -> Double -> pSource

`rect w h` is an axis-aligned rectangle of width `w` and height `h`, centered at the origin.

starPolygon :: (PathLike p, Transformable p, V p ~ R2) => Int -> Int -> pSource

`starPolygon p q` creates a star polygon, where `p` indicates the number of vertices, and an edge connects every `q`th vertex.

eqTriangle :: (PathLike p, Transformable p, V p ~ R2) => pSource

An equilateral triangle, with radius 1 and base parallel to the x-axis.

Other shapes

roundedRect :: (PathLike p, V p ~ R2) => R2 -> Double -> pSource

`roundedRect v r` generates a closed trail, or closed path centered at the origin, of an axis-aligned rectangle with diagonal `v` and circular rounded corners of radius `r`. `r` must be between `0` and half the smaller dimension of `v`, inclusive; smaller or larger values of `r` will be treated as `0` or half the smaller dimension of `v`, respectively. The trail or path begins with the right edge and proceeds counterclockwise.