Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

This module provides a monadic interface to build `TPath`

values.
It does so using `PathBuilder`

s. The construction of a `PathBuilder`

is equivalent to the construction of a `TPath`

by hand, but with
a sometimes more convenient syntax.

For example, this path corresponds to a triangle:

trianglePath :: TPath trianglePath = bpath (pointAtXY (-1) 0) $ do line $ pointAtXY 1 0 line $ pointAtXY 0 1 pcycle

The equivalent syntax created by hand would be:

trianglePath :: TPath trianglePath = Cycle $ Start (pointAtXY (-1) 0) ->- pointAtXY 1 0 ->- pointAtXY 0 1

The `Cycle`

constructor at the beginning may seem unintuitive, since we are building
the path from left to right. In the `PathBuilder`

monad, the instructions are always
written in order.

## Synopsis

- data PathBuilder a
- bpath :: TPoint -> PathBuilder a -> TPath
- line :: TPoint -> PathBuilder ()
- pcycle :: PathBuilder ()
- rectangle :: TPoint -> PathBuilder ()
- circle :: Double -> PathBuilder ()
- ellipse :: Double -> Double -> PathBuilder ()
- node :: LaTeX -> PathBuilder ()
- grid :: [GridOption] -> TPoint -> PathBuilder ()

# Path builder

data PathBuilder a Source #

## Instances

Monad PathBuilder Source # | |

Defined in Text.LaTeX.Packages.TikZ.PathBuilder (>>=) :: PathBuilder a -> (a -> PathBuilder b) -> PathBuilder b # (>>) :: PathBuilder a -> PathBuilder b -> PathBuilder b # return :: a -> PathBuilder a # fail :: String -> PathBuilder a # | |

Functor PathBuilder Source # | |

Defined in Text.LaTeX.Packages.TikZ.PathBuilder fmap :: (a -> b) -> PathBuilder a -> PathBuilder b # (<$) :: a -> PathBuilder b -> PathBuilder a # | |

Applicative PathBuilder Source # | |

Defined in Text.LaTeX.Packages.TikZ.PathBuilder pure :: a -> PathBuilder a # (<*>) :: PathBuilder (a -> b) -> PathBuilder a -> PathBuilder b # liftA2 :: (a -> b -> c) -> PathBuilder a -> PathBuilder b -> PathBuilder c # (*>) :: PathBuilder a -> PathBuilder b -> PathBuilder b # (<*) :: PathBuilder a -> PathBuilder b -> PathBuilder a # |

bpath :: TPoint -> PathBuilder a -> TPath Source #

Build a path using a *starting point* and a `PathBuilder`

.

# Builder functions

line :: TPoint -> PathBuilder () Source #

Line from the current point to the given one.

pcycle :: PathBuilder () Source #

rectangle :: TPoint -> PathBuilder () Source #

Rectangle with the current point as one cornder and the given point as the opposite corner.

circle :: Double -> PathBuilder () Source #

Circle with the given radius centered at the current point.

:: Double | Half width of the ellipse. |

-> Double | Half height of the ellipse. |

-> PathBuilder () |

Ellipse with width and height described by the arguments and centered at the current point.

node :: LaTeX -> PathBuilder () Source #

Text centered at the current point.

grid :: [GridOption] -> TPoint -> PathBuilder () Source #