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

Copyright(c) 2011 Michael Sloan
LicenseBSD-style (see LICENSE)
MaintainerMichael Sloan <mgsloan at gmail>
Safe HaskellNone
LanguageHaskell2010

Diagrams.TwoD.Path.Turtle

Contents

Description

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

Synopsis

Documentation

Turtle control commands

runTurtle :: (Floating n, Ord n) => Turtle n a -> TurtleState n Source #

Run the turtle, yielding the final turtle state.

runTurtleT :: (OrderedField n, Monad m) => TurtleT n m a -> m (TurtleState n) 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 V2 n) b, TypeableFloat n) => Turtle n a -> QDiagram b V2 n Any Source #

Run the turtle, yielding a diagram.

drawTurtleT :: (Monad m, Renderable (Path V2 n) b, TypeableFloat n) => TurtleT n m a -> m (QDiagram b V2 n Any) Source #

A more general way to run the turtle. Returns a computation in the underlying monad m yielding the final diagram.

sketchTurtle :: (Floating n, Ord n) => Turtle n a -> Path V2 n Source #

Run the turtle, ignoring any pen style commands and yielding a 2D path.

sketchTurtleT :: (Monad m, Floating n, Ord n) => TurtleT n m a -> m (Path V2 n) 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 :: (OrderedField n, Monad m) => n -> TurtleT n m () Source #

Move the turtle forward, along the current heading.

backward :: (OrderedField n, Monad m) => n -> TurtleT n m () Source #

Move the turtle backward, directly away from the current heading.

left :: (OrderedField n, Monad m) => n -> TurtleT n m () Source #

Modify the current heading to the left by the specified angle in degrees.

right :: (OrderedField n, Monad m) => n -> TurtleT n m () Source #

Modify the current heading to the right by the specified angle in degrees.

State accessors / setters

heading :: (OrderedField n, Monad m) => TurtleT n m n Source #

Get the current turtle angle, in degrees.

setHeading :: (OrderedField n, Monad m) => n -> TurtleT n m () Source #

Set the current turtle angle, in degrees.

towards :: (Monad m, RealFloat n) => P2 n -> TurtleT n m () Source #

Sets the heading towards a given location.

isDown :: Monad m => TurtleT n m Bool Source #

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

pos :: Monad m => TurtleT n m (P2 n) Source #

Get the current turtle X/Y position.

setPos :: (OrderedField n, Monad m) => P2 n -> TurtleT n m () Source #

Set the current turtle X/Y position.

setPenWidth :: (OrderedField n, Monad m) => Measure n -> TurtleT n m () Source #

Sets the pen size

setPenColor :: (OrderedField n, Monad m) => Colour Double -> TurtleT n m () Source #

Sets the pen color

Drawing control

penUp :: (OrderedField n, Monad m) => TurtleT n m () Source #

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

penDown :: (OrderedField n, Monad m) => TurtleT n m () Source #

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

penHop :: (OrderedField n, Monad m) => TurtleT n m () Source #

Start a new trail at current position

closeCurrent :: (OrderedField n, Monad m) => TurtleT n m () Source #

Closes the current path , to the starting position of the current trail. Has no effect when the pen position is up.