diagrams-lib-1.3.0.6: 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 :: (InSpace V2 n t, TrailLike t) => n -> 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 :: (InSpace V2 n t, TrailLike t) => n -> 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 :: (InSpace V2 n t, TrailLike t, OrderedField n) => Int -> n -> 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 :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

eqTriangle :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

A synonym for triangle, provided for backwards compatibility.

square :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

pentagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

hexagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

heptagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

septagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> 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 :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

nonagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

decagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

hendecagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

dodecagon :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> t Source

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

Other special polygons

unitSquare :: (InSpace V2 n t, TrailLike t, OrderedField n) => t Source

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

rect :: (InSpace V2 n t, TrailLike t, OrderedField n) => n -> n -> t Source

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

Other shapes

roundedRect :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> n -> 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)
  ]

data RoundedRectOpts d Source

Constructors

RoundedRectOpts 

Fields

_radiusTL :: d
 
_radiusTR :: d
 
_radiusBL :: d
 
_radiusBR :: d
 

Instances

roundedRect' :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> RoundedRectOpts n -> 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.