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

Copyright(c) 2011 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

Diagrams.TwoD.Shapes

Contents

Description

Various two-dimensional shapes.

Synopsis

Miscellaneous

hrule :: (TrailLike t, V t ~ R2) => Double -> t Source

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

hruleEx = vcat' (with & sep .~ 0.2) (map hrule [1..5])
        # centerXY # pad 1.1

vrule :: (TrailLike t, V t ~ R2) => Double -> t Source

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

vruleEx = hcat' (with & sep .~ 0.2) (map vrule [1, 1.2 .. 2])
        # centerXY # pad 1.1

Regular polygons

regPoly :: (TrailLike t, V t ~ R2) => Int -> Double -> t Source

Create a regular polygon. The first argument is the number of sides, and the second is the length of the sides. (Compare to the polygon function with a PolyRegular option, which produces polygons of a given radius).

The polygon will be oriented with one edge parallel to the x-axis.

triangle :: (TrailLike t, V t ~ R2) => Double -> t Source

An equilateral triangle, with sides of the given length and base parallel to the x-axis.

eqTriangle :: (TrailLike t, V t ~ R2) => Double -> t Source

A synonym for triangle, provided for backwards compatibility.

square :: (TrailLike t, Transformable t, V t ~ R2) => Double -> t Source

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

pentagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A regular pentagon, with sides of the given length and base parallel to the x-axis.

hexagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A regular hexagon, with sides of the given length and base parallel to the x-axis.

heptagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A regular heptagon, with sides of the given length and base parallel to the x-axis.

septagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A synonym for heptagon. It is, however, completely inferior, being a base admixture of the Latin septum (seven) and the Greek γωνία (angle).

octagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A regular octagon, with sides of the given length and base parallel to the x-axis.

nonagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A regular nonagon, with sides of the given length and base parallel to the x-axis.

decagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A regular decagon, with sides of the given length and base parallel to the x-axis.

hendecagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A regular hendecagon, with sides of the given length and base parallel to the x-axis.

dodecagon :: (TrailLike t, V t ~ R2) => Double -> t Source

A regular dodecagon, with sides of the given length and base parallel to the x-axis.

Other special polygons

unitSquare :: (TrailLike t, V t ~ R2) => t Source

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

rect :: (TrailLike t, Transformable t, V t ~ R2) => Double -> Double -> t Source

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

Other shapes

roundedRect :: (TrailLike t, V t ~ R2) => Double -> Double -> Double -> t Source

roundedRect w h r generates a closed trail, or closed path centered at the origin, of an axis-aligned rectangle with width w, height h, and circular rounded corners of radius r. If r is negative the corner will be cut out in a reverse arc. If the size of r is larger than half the smaller dimension of w and h, then it will be reduced to fit in that range, to prevent the corners from overlapping. The trail or path begins with the right edge and proceeds counterclockwise. If you need to specify a different radius for each corner individually, use roundedRect' instead.

roundedRectEx = pad 1.1 . centerXY $ hcat' (with & sep .~ 0.2)
  [ roundedRect  0.5 0.4 0.1
  , roundedRect  0.5 0.4 (-0.1)
  , roundedRect' 0.7 0.4 (with & radiusTL .~ 0.2
                               & radiusTR .~ -0.2
                               & radiusBR .~ 0.1)
  ]

roundedRect' :: (TrailLike t, V t ~ R2) => Double -> Double -> RoundedRectOpts -> t Source

roundedRect' works like roundedRect but allows you to set the radius of each corner indivually, using RoundedRectOpts. The default corner radius is 0. Each radius can also be negative, which results in the curves being reversed to be inward instead of outward.