Copyright | (c) 2011 diagrams-lib team (see LICENSE) |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | diagrams-discuss@googlegroups.com |
Safe Haskell | None |
Language | Haskell2010 |
Various two-dimensional shapes.
Synopsis
- hrule :: (InSpace V2 n t, TrailLike t) => n -> t
- vrule :: (InSpace V2 n t, TrailLike t) => n -> t
- regPoly :: (InSpace V2 n t, TrailLike t) => Int -> n -> t
- triangle :: (InSpace V2 n t, TrailLike t) => n -> t
- eqTriangle :: (InSpace V2 n t, TrailLike t) => n -> t
- square :: (InSpace V2 n t, TrailLike t) => n -> t
- pentagon :: (InSpace V2 n t, TrailLike t) => n -> t
- hexagon :: (InSpace V2 n t, TrailLike t) => n -> t
- heptagon :: (InSpace V2 n t, TrailLike t) => n -> t
- septagon :: (InSpace V2 n t, TrailLike t) => n -> t
- octagon :: (InSpace V2 n t, TrailLike t) => n -> t
- nonagon :: (InSpace V2 n t, TrailLike t) => n -> t
- decagon :: (InSpace V2 n t, TrailLike t) => n -> t
- hendecagon :: (InSpace V2 n t, TrailLike t) => n -> t
- dodecagon :: (InSpace V2 n t, TrailLike t) => n -> t
- unitSquare :: (InSpace V2 n t, TrailLike t) => t
- rect :: (InSpace V2 n t, TrailLike t) => n -> n -> t
- roundedRect :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> n -> t
- data RoundedRectOpts d = RoundedRectOpts {}
- radiusTL :: forall d. Lens' (RoundedRectOpts d) d
- radiusTR :: forall d. Lens' (RoundedRectOpts d) d
- radiusBL :: forall d. Lens' (RoundedRectOpts d) d
- radiusBR :: forall d. Lens' (RoundedRectOpts d) d
- roundedRect' :: (InSpace V2 n t, TrailLike t, RealFloat n) => n -> n -> RoundedRectOpts n -> t
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) => 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) => 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) => n -> t Source #
A synonym for triangle
, provided for backwards compatibility.
square :: (InSpace V2 n t, TrailLike t) => 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) => 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) => 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) => 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) => 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) => 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) => 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) => 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) => 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) => 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) => 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) => 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 #
Instances
Num d => Default (RoundedRectOpts d) Source # | |
Defined in Diagrams.TwoD.Shapes def :: RoundedRectOpts d # |
radiusTL :: forall d. Lens' (RoundedRectOpts d) d Source #
radiusTR :: forall d. Lens' (RoundedRectOpts d) d Source #
radiusBL :: forall d. Lens' (RoundedRectOpts d) d Source #
radiusBR :: forall d. Lens' (RoundedRectOpts d) d Source #
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.