Copyright  (c) 2011 Michael Sloan 

License  BSDstyle (see LICENSE) 
Maintainer  Michael Sloan <mgsloan at gmail>, Deepak Jois <deepak.jois@gmail.com> 
Safe Haskell  None 
Language  Haskell2010 
Authors : Michael Sloan at gmail, Deepak Jois deepak.jois@gmail.com
A module consisting of core types and functions to represent and operate on a "turtle".
More info about turtle graphics: http://en.wikipedia.org/wiki/Turtle_graphics
 data TurtleState n = TurtleState {}
 data TurtlePath n = TurtlePath {}
 data PenStyle n = PenStyle {}
 forward :: (Floating n, Ord n) => n > TurtleState n > TurtleState n
 backward :: (Floating n, Ord n) => n > TurtleState n > TurtleState n
 left :: (Floating n, Ord n) => n > TurtleState n > TurtleState n
 right :: (Floating n, Ord n) => n > TurtleState n > TurtleState n
 setPenColor :: (Ord n, Floating n) => Colour Double > TurtleState n > TurtleState n
 setPenColour :: (Ord n, Floating n) => Colour Double > TurtleState n > TurtleState n
 setPenWidth :: (Ord n, Floating n) => n > TurtleState n > TurtleState n
 startTurtle :: (Floating n, Ord n) => TurtleState n
 setHeading :: (Floating n, Ord n) => n > TurtleState n > TurtleState n
 towards :: RealFloat n => P2 n > TurtleState n > TurtleState n
 setPenPos :: (Ord n, Floating n) => P2 n > TurtleState n > TurtleState n
 penUp :: (Ord n, Floating n) => TurtleState n > TurtleState n
 penDown :: (Ord n, Floating n) => TurtleState n > TurtleState n
 penHop :: (Ord n, Floating n) => TurtleState n > TurtleState n
 closeCurrent :: (Floating n, Ord n) => TurtleState n > TurtleState n
 traceTurtle :: Show n => TurtleState n > TurtleState n
 getTurtleDiagram :: (Renderable (Path V2 n) b, TypeableFloat n) => TurtleState n > QDiagram b V2 n Any
 getTurtlePath :: (Floating n, Ord n) => TurtleState n > Path V2 n
Turtle data types and accessors
data TurtleState n Source
Core turtle data type. A turtle needs to keep track of its current position, like its position, heading etc., and all the paths that it has traversed so far.
We need to record a new path, everytime an attribute like style, pen position etc changes, so that we can separately track styles for each portion of the eventual path that the turtle took.
TurtleState  

Show n => Show (TurtleState n) Source 
data TurtlePath n Source
Turtle path type that captures a list of paths and the style attributes associated with them
Show n => Show (TurtlePath n) Source 
Style attributes associated with the turtle pen
Motion commands
:: (Floating n, Ord n)  
=> n  Distance to move 
> TurtleState n  Turtle to move 
> TurtleState n  Resulting turtle 
Move the turtle forward by x
units
:: (Floating n, Ord n)  
=> n  Distance to move 
> TurtleState n  Turtle to move 
> TurtleState n  Resulting turtle 
Move the turtle backward by x
units
:: (Floating n, Ord n)  
=> n  Degree of turn 
> TurtleState n  Turtle to turn 
> TurtleState n  Resulting turtle 
Turn the turtle anticlockwise (left)
:: (Floating n, Ord n)  
=> n  Degree of turn 
> TurtleState n  Turtle to turn 
> TurtleState n  Resulting turtle 
Turn the turtle clockwise (right)
Pen style commands
:: (Ord n, Floating n)  
=> Colour Double  Width of Pen 
> TurtleState n  Turtle to change 
> TurtleState n  Resulting Turtle 
alias of setPenColour
:: (Ord n, Floating n)  
=> Colour Double  Width of Pen 
> TurtleState n  Turtle to change 
> TurtleState n  Resulting Turtle 
Set a new pen color for turtle.
If pen is down, this adds the current trail to paths
and starts a new empty
trail.
:: (Ord n, Floating n)  
=> n  Width of Pen 
> TurtleState n  Turtle to change 
> TurtleState n  Resulting Turtle 
Set a new pen width for turtle.
If pen is down, this adds the current trail to paths
and starts a new empty
trail.
State setters
startTurtle :: (Floating n, Ord n) => TurtleState n Source
The initial state of turtle. The turtle is located at the origin, at an
orientation of 0 degrees with its pen position down. The pen style is
defaultPenStyle
.
:: (Floating n, Ord n)  
=> n  Degree of orientation 
> TurtleState n  Turtle to orient 
> TurtleState n  Resulting turtle 
Turn the turtle to the given orientation, in degrees
:: RealFloat n  
=> P2 n  Point to orient turtle towards 
> TurtleState n  Turtle to orient 
> TurtleState n  Resulting turtle 
Sets the turtle orientation towards a given location.
:: (Ord n, Floating n)  
=> P2 n  Position to place true 
> TurtleState n  Turtle to position 
> TurtleState n  Resulting turtle 
Set the turtle X/Y position.
If pen is down and the current trail is nonempty, this will also add the
current trail to the paths
field.
Drawing control
:: (Ord n, Floating n)  
=> TurtleState n  Turtle to modify 
> TurtleState n  Resulting turtle 
Puts the turtle pen in “Up” mode. Turtle movements will not draw anything
Does nothing if the pen was already up. Otherwise, it creates a turtle with
the current trail added to paths
.
:: (Ord n, Floating n)  
=> TurtleState n  Turtle to modify 
> TurtleState n  Resulting turtle 
Puts the turtle pen in “Down” mode. Turtle movements will cause drawing to happen
Does nothing if the pen was already down. Otherwise, starts a new trail starting at the current position.
penHop :: (Ord n, Floating n) => TurtleState n > TurtleState n Source
closeCurrent :: (Floating n, Ord n) => TurtleState n > TurtleState n Source
Debugging
traceTurtle :: Show n => TurtleState n > TurtleState n Source
Prints out turtle representation and returns it. Use for debugging
Diagram related
getTurtleDiagram :: (Renderable (Path V2 n) b, TypeableFloat n) => TurtleState n > QDiagram b V2 n Any Source
Creates a diagram from a turtle
Applies the styles to each trails in paths
separately and combines them
into a single diagram
getTurtlePath :: (Floating n, Ord n) => TurtleState n > Path V2 n Source
Creates a path from a turtle, ignoring the styles.