Copyright  (c) 2013 diagramslib team (see LICENSE) 

License  BSDstyle (see LICENSE) 
Maintainer  diagramsdiscuss@googlegroups.com 
Safe Haskell  None 
Language  Haskell2010 
 class (Metric (V t), OrderedField (N t)) => TrailLike t where
 fromSegments :: TrailLike t => [Segment Closed (V t) (N t)] > t
 fromLocSegments :: TrailLike t => Located [Segment Closed (V t) (N t)] > t
 fromOffsets :: TrailLike t => [Vn t] > t
 fromLocOffsets :: (V t ~ v, N t ~ n, V (v n) ~ v, N (v n) ~ n, TrailLike t) => Located [v n] > t
 fromVertices :: TrailLike t => [Point (V t) (N t)] > t
 (~~) :: (V t ~ v, N t ~ n, TrailLike t) => Point v n > Point v n > t
 explodeTrail :: (V t ~ v, N t ~ n, Additive v, TrailLike t) => Located (Trail v n) > [t]
The TrailLike class
class (Metric (V t), OrderedField (N t)) => TrailLike t where Source
A type class for traillike things, i.e. things which can be
constructed from a concretely located Trail
. Instances include
lines, loops, trails, paths, lists of vertices, twodimensional
Diagram
s, and Located
variants of all the above.
Usually, type variables with TrailLike
constraints are used as
the output types of functions, like
foo :: (TrailLike t) => ... > t
Functions with such a type can be used to construct trails, paths, diagrams, lists of points, and so on, depending on the context.
To write a function with a signature like the above, you can of
course call trailLike
directly; more typically, one would use
one of the provided functions like fromOffsets
, fromVertices
,
fromSegments
, or ~~
.
(Metric v, OrderedField n) => TrailLike [Point v n]  A list of points is traillike; this instance simply
computes the vertices of the trail, using 
TrailLike t => TrailLike (Active t)  
TrailLike t => TrailLike (TransInv t)  Translationally invariant things are traillike as long as the underlying type is. 
TrailLike t => TrailLike (Located t) 

(Metric v, OrderedField n) => TrailLike (Trail v n) 

(Metric v, OrderedField n) => TrailLike (Path v n)  Paths are traillike; a trail can be used to construct a singleton path. 
(Metric v, OrderedField n) => TrailLike (Trail' Loop v n)  Loops are traillike. If given a 
(Metric v, OrderedField n) => TrailLike (Trail' Line v n)  Lines are traillike. If given a 
(TypeableFloat n, Renderable (Path V2 n) b) => TrailLike (QDiagram b V2 n Any) 
Constructing TrailLikes
fromSegments :: TrailLike t => [Segment Closed (V t) (N t)] > t Source
Construct a traillike thing from a list of segments, with the origin as the location.
fromSegmentsEx = fromSegments [ straight (r2 (1,1)) , bézier3 (r2 (1,1)) unitX unit_Y , straight unit_X ] # centerXY # pad 1.1
fromLocSegments :: TrailLike t => Located [Segment Closed (V t) (N t)] > t Source
Construct a traillike thing from a located list of segments.
fromOffsets :: TrailLike t => [Vn t] > t Source
Construct a traillike thing of linear segments from a list of offsets, with the origin as the location.
fromOffsetsEx = fromOffsets [ unitX , unitX # rotateBy (1/6) , unitX # rotateBy (1/6) , unitX ] # centerXY # pad 1.1
fromLocOffsets :: (V t ~ v, N t ~ n, V (v n) ~ v, N (v n) ~ n, TrailLike t) => Located [v n] > t Source
Construct a traillike thing of linear segments from a located list of offsets.
fromVertices :: TrailLike t => [Point (V t) (N t)] > t Source
Construct a traillike thing connecting the given vertices with linear segments, with the first vertex as the location. If no vertices are given, the empty trail is used with the origin as the location.
import Data.List (transpose) fromVerticesEx = ( [ pentagon 1 , pentagon 1.3 # rotateBy (1/15) , pentagon 1.5 # rotateBy (2/15) ] # transpose # concat ) # fromVertices # closeTrail # strokeTrail # centerXY # pad 1.1
(~~) :: (V t ~ v, N t ~ n, TrailLike t) => Point v n > Point v n > t Source
Create a linear trail between two given points.
twiddleEx = mconcat ((~~) <$> hexagon 1 <*> hexagon 1) # centerXY # pad 1.1
explodeTrail :: (V t ~ v, N t ~ n, Additive v, TrailLike t) => Located (Trail v n) > [t] Source
Given a concretely located trail, "explode" it by turning each segment into its own separate trail. Useful for (say) applying a different style to each segment.
explodeTrailEx = pentagon 1 # explodeTrail  generate a list of diagrams # zipWith lc [orange, green, yellow, red, blue] # mconcat # centerXY # pad 1.1