Copyright | (c) 2011 Michael Sloan |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Michael Sloan <mgsloan at gmail> |
Safe Haskell | None |
Language | Haskell2010 |
Stateful domain specific language for diagram paths, modelled after the classic "turtle" graphics language.
- type Turtle = TurtleT Identity
- type TurtleT = StateT TurtleState
- runTurtle :: Turtle a -> TurtleState
- runTurtleT :: Monad m => TurtleT m a -> m TurtleState
- drawTurtle :: Renderable (Path R2) b => Turtle a -> Diagram b R2
- drawTurtleT :: (Monad m, Functor m, Renderable (Path R2) b) => TurtleT m a -> m (Diagram b R2)
- sketchTurtle :: Turtle a -> Path R2
- sketchTurtleT :: (Functor m, Monad m) => TurtleT m a -> m (Path R2)
- forward :: Monad m => Double -> TurtleT m ()
- backward :: Monad m => Double -> TurtleT m ()
- left :: Monad m => Double -> TurtleT m ()
- right :: Monad m => Double -> TurtleT m ()
- heading :: Monad m => TurtleT m Double
- setHeading :: Monad m => Double -> TurtleT m ()
- towards :: Monad m => P2 -> TurtleT m ()
- isDown :: Monad m => TurtleT m Bool
- pos :: Monad m => TurtleT m P2
- setPos :: Monad m => P2 -> TurtleT m ()
- setPenWidth :: Monad m => Double -> TurtleT m ()
- setPenColor :: Monad m => Colour Double -> TurtleT m ()
- penUp :: Monad m => TurtleT m ()
- penDown :: Monad m => TurtleT m ()
- penHop :: Monad m => TurtleT m ()
- closeCurrent :: Monad m => TurtleT m ()
Documentation
type TurtleT = StateT TurtleState Source
Turtle control commands
runTurtle :: Turtle a -> TurtleState Source
Run the turtle, yielding the final turtle state.
runTurtleT :: Monad m => TurtleT m a -> m TurtleState Source
A more general way to run the turtle. Returns a computation in the
underlying monad m
yielding the final turtle state.
drawTurtle :: Renderable (Path R2) b => Turtle a -> Diagram b R2 Source
Run the turtle, yielding a diagram.
drawTurtleT :: (Monad m, Functor m, Renderable (Path R2) b) => TurtleT m a -> m (Diagram b R2) Source
A more general way to run the turtle. Returns a computation in
the underlying monad m
yielding the final diagram.
sketchTurtle :: Turtle a -> Path R2 Source
Run the turtle, ignoring any pen style commands and yielding a 2D path.
sketchTurtleT :: (Functor m, Monad m) => TurtleT m a -> m (Path R2) Source
A more general way to run the turtle. Returns a computation in
the underlying monad m
, ignoring any pen style commands and
yielding a 2D path.
Motion commands
forward :: Monad m => Double -> TurtleT m () Source
Move the turtle forward, along the current heading.
backward :: Monad m => Double -> TurtleT m () Source
Move the turtle backward, directly away from the current heading.
left :: Monad m => Double -> TurtleT m () Source
Modify the current heading to the left by the specified angle in degrees.
right :: Monad m => Double -> TurtleT m () Source
Modify the current heading to the right by the specified angle in degrees.
State accessors / setters
setHeading :: Monad m => Double -> TurtleT m () Source
Set the current turtle angle, in degrees.
isDown :: Monad m => TurtleT m Bool Source
Queries whether the pen is currently drawing a path or not.
setPenWidth :: Monad m => Double -> TurtleT m () Source
Sets the pen size
Drawing control
closeCurrent :: Monad m => TurtleT m () Source
Closes the current path , to the starting position of the current trail. Has no effect when the pen position is up.