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

Maintainerdiagrams-discuss@googlegroups.com

Diagrams.TwoD.Shapes

Contents

Description

Various two-dimensional shapes.

Synopsis

Miscellaneous

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.

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

Constructors

PolygonOpts 

Fields

sides :: Int

Number of sides; the default is 5.

edgeSkip :: Int

Create 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 :: PolygonOrientation

Determine how the polygon should be oriented.

data PolygonOrientation Source

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

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.

rect :: (Backend b R2, Renderable (Path R2) b) => Double -> Double -> Diagram b R2Source

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

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 qth vertex.

eqTriangle :: (Backend b R2, Renderable (Path R2) b) => Diagram b R2Source

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

Other shapes

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

roundedRectPath 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.