Maintainer | diagrams-discuss@googlegroups.com |
---|---|

Safe Haskell | None |

Various two-dimensional shapes.

- hrule :: (TrailLike t, V t ~ R2) => Double -> t
- vrule :: (TrailLike t, V t ~ R2) => Double -> t
- regPoly :: (TrailLike t, V t ~ R2) => Int -> Double -> t
- triangle :: (TrailLike t, V t ~ R2) => Double -> t
- eqTriangle :: (TrailLike t, V t ~ R2) => Double -> t
- square :: (TrailLike t, Transformable t, V t ~ R2) => Double -> t
- pentagon :: (TrailLike t, V t ~ R2) => Double -> t
- hexagon :: (TrailLike t, V t ~ R2) => Double -> t
- heptagon :: (TrailLike t, V t ~ R2) => Double -> t
- septagon :: (TrailLike t, V t ~ R2) => Double -> t
- octagon :: (TrailLike t, V t ~ R2) => Double -> t
- nonagon :: (TrailLike t, V t ~ R2) => Double -> t
- decagon :: (TrailLike t, V t ~ R2) => Double -> t
- hendecagon :: (TrailLike t, V t ~ R2) => Double -> t
- dodecagon :: (TrailLike t, V t ~ R2) => Double -> t
- unitSquare :: (TrailLike t, V t ~ R2) => t
- rect :: (TrailLike t, Transformable t, V t ~ R2) => Double -> Double -> t
- roundedRect :: (TrailLike t, V t ~ R2) => Double -> Double -> Double -> t
- data RoundedRectOpts = RoundedRectOpts {}
- radiusTL :: Lens' RoundedRectOpts Double
- radiusTR :: Lens' RoundedRectOpts Double
- radiusBL :: Lens' RoundedRectOpts Double
- radiusBR :: Lens' RoundedRectOpts Double
- roundedRect' :: (TrailLike t, V t ~ R2) => Double -> Double -> RoundedRectOpts -> t

# Miscellaneous

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

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 -> tSource

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 -> tSource

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 -> tSource

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

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

A synonym for `triangle`

, provided for backwards compatibility.

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

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 -> tSource

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

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

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

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

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

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

A synonym for `heptagon`

. It is, however, completely inferior,
being a base admixture of the Latin *septum* (seven) and the
Greek γωνία (angl

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

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

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

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

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

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

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

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

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

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) => tSource

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 -> tSource

`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 -> tSource

`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 Source

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

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