diagrams-contrib-1.1.2: Collection of user contributions to diagrams EDSL

Diagrams.TwoD.Path.Turtle

Description

Stateful domain specific language for diagram paths, modelled after the classic "turtle" graphics language.

Synopsis

# Turtle control commands

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

Get the current turtle angle, in degrees.

Set the current turtle angle, in degrees.

towards :: Monad m => P2 -> TurtleT m () Source

Sets the heading towards a given location.

isDown :: Monad m => TurtleT m Bool Source

Queries whether the pen is currently drawing a path or not.

pos :: Monad m => TurtleT m P2 Source

Get the current turtle X/Y position.

setPos :: Monad m => P2 -> TurtleT m () Source

Set the current turtle X/Y position.

setPenWidth :: Monad m => Double -> TurtleT m () Source

Sets the pen size

setPenColor :: Monad m => Colour Double -> TurtleT m () Source

Sets the pen color

# Drawing control

penUp :: Monad m => TurtleT m () Source

Ends the current path, and enters into "penUp" mode

penDown :: Monad m => TurtleT m () Source

Ends the current path, and enters into "penDown" mode

penHop :: Monad m => TurtleT m () Source

Start a new trail at current position

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.