Copyright | (c) 2016 Brent Yorgey |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | byorgey@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
An alternative monoid for trails which rotates trails so their starting and ending tangents match at join points.
Documentation
Following
is just like Trail' Line V2
, except that it has a
different Monoid
instance. Following
values are
concatenated, just like regular lines, except that they are also
rotated so the tangents match at the join point. In addition,
they are normalized so the tangent at the start point is in the
direction of the positive x axis (essentially we are considering
trails equivalent up to rotation).
Pro tip: you can concatenate a list of trails so their tangents
match using ala
from Control.Lens, like so:
ala follow foldMap :: [Trail' Line V2 n] -> Trail' Line V2 n
This is illustrated in the example below.
import Control.Lens (ala) import Diagrams.TwoD.Path.Follow wibble :: Trail' Line V2 Double wibble = hrule 1 <> hrule 0.5 # rotateBy (1/6) <> hrule 0.5 # rotateBy (-1/6) <> a where a = arc (xDir # rotateBy (-1/4)) (1/5 @@ turn) # scale 0.7 followExample = [ wibble , wibble # replicate 5 # ala follow foldMap ] # map stroke # map centerXY # vsep 1 # frame 0.5