-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | LOGO-like Turtle graphics with a monadic interface. -- -- Have you ever heard of Turtle Graphics? -- -- If not, then think of a turtle as a cursor you can program to -- draw! -- -- Turtle graphics are a fantastic introduction to the world of -- programming and to the syntax of a new programming language. -- -- -- This module is a framework built on top of gloss to render -- turtles programmed in Haskell as animations. This is primarily aimed -- as a teaching tool to beginners - but also, it's cool to draw things! -- -- See The API ref, Graphics.WorldTurtle, for features! -- -- It's easy to create a new project with stack: -- --
--   stack new my-worldturtle-project aneilmac/worldturtle
--   cd my-worldturtle-project
--   stack build
--   stack exec my-worldturtle-project
--   
@package worldturtle @version 0.2.2.1 -- | This module is a collection of color manipulation commands! module Graphics.WorldTurtle.Color -- | Rotates a given color's hue between [0, 360) degrees. shiftHue :: Float -> Color -> Color -- | This module exposes shapes not found in gloss but may be found to be -- worthwhile. module Graphics.WorldTurtle.Shapes -- | Creates the default turtle polygon arrow with a given outline color -- and fill color. turtleArrow :: Color -> Color -> Picture -- | Draws a line from a start-point to an end-point with a given -- thickness. thickLine :: Point -> Point -> Float -> Picture -- | This module contains all commands used to create, move and manipulate -- a turtle. module Graphics.WorldTurtle.Commands -- | The Turtle that is drawn on the canvas! Create a new turtle using -- makeTurtle. data Turtle type Point = (Float, Float) -- | Creates a new Turtle and displays it on the canvas. This turtle -- can then be manipulated! For example, to create a turtle and then move -- the turtle forward: -- --
--   main:: IO ()
--   main = runWorld $ do
--     t <- makeTurtle
--     t >/> forward 90
--   
-- -- The default turtle starts at position (0, 0) and is -- orientated north. makeTurtle :: WorldCommand Turtle -- | This variant of makeTurtle takes a starting position, a -- starting orientation, and a color to apply to the turtle and the -- turtle's pen. -- --
--   myCommand :: WorldCommand ()
--   myCommand = do
--     t1 <- makeTurtle' (0, 0)  0 green
--     t2 <- makeTurtle' (0, 0) 90 red
--     (t1 >/> forward 90) \<|\> (t2 >/> forward 90)
--   
-- -- See makeTurtle. makeTurtle' :: Point -> Float -> Color -> WorldCommand Turtle -- | Clears all drawings form the canvas. Does not alter any turtle's -- state. clear :: WorldCommand () -- | Sleep for a given amount of time in seconds. When sleeping no -- animation runs. A negative value will be clamped to 0. sleep :: Float -> WorldCommand () -- | Move the turtle forward by the specified distance, in the -- direction the turtle is headed. forward :: Float -> TurtleCommand () -- | Shorthand for forward. fd :: Float -> TurtleCommand () -- | Move the turtle backward by the specified distance, in the -- direction the turtle is headed. backward :: Float -> TurtleCommand () -- | Shorthand for backward. bk :: Float -> TurtleCommand () -- | Turn a turtle left by the given degrees amount. left :: Float -> TurtleCommand () -- | Shorthand for left. lt :: Float -> TurtleCommand () -- | Turn a turtle right by the given degrees amount. right :: Float -> TurtleCommand () -- | Shorthand for right. rt :: Float -> TurtleCommand () -- | Draw a circle with a given radius. The center is -- radius units left of the turtle if positive. -- Otherwise radius units right of the turtle if -- negative. -- -- The circle is drawn in an anticlockwise direction if the radius is -- positive, otherwise, it is drawn in a clockwise direction. -- -- Circle is an alias for circle r = arc r 360. circle :: Float -> TurtleCommand () -- | Draw an arc with a given radius. The center is -- radius units left of the turtle if positive. -- Otherwise radius units right of the turtle if -- negative. -- -- The arc is drawn in an anticlockwise direction if the radius is -- positive, otherwise, it is drawn in a clockwise direction. arc :: Float -> Float -> TurtleCommand () -- | Warps the turtle to a new position. The turtle jumps to this new -- position with no animation. If the pen is down then a line is drawn. -- -- This does not affect the turtle's heading. goto :: Point -> TurtleCommand () -- | Alias of goto. setPosition :: Point -> TurtleCommand () -- | Warps the turtle to its starting position (0, 0) and resets -- the orientation to north (90 degrees). No line is -- drawn moving the turtle. home :: TurtleCommand () -- | Sets the turtle's heading. See heading. setHeading :: Float -> TurtleCommand () -- | Sets the turtle's speed. See speed. setSpeed :: Float -> TurtleCommand () -- | Sets the turtle's rotation speed. See rotationSpeed. setRotationSpeed :: Float -> TurtleCommand () -- | Stamp a copy of the turtle shape onto the canvas at the current turtle -- position. stamp :: TurtleCommand () -- | Gets the turtle's representation as a Picture. representation :: TurtleCommand Picture -- | Returns the turtle's current position. Default (starting) position is -- (0, 0). position :: TurtleCommand Point -- | Returns the turtle's heading. -- -- 0 is along the positive x-axis, going anticlockwise. So: -- -- -- -- The default heading is North (90 degrees). heading :: TurtleCommand Float -- | Returns the turtle's current speed. Speed is is distance per -- second. A speed of 0 is equivalent to no animation being -- performed and instant movement. The default value is 200. speed :: TurtleCommand Float -- | Returns the turtle's current rotation speed. Rotation speed is is the -- speed in seconds it takes to do a full revolution. A speed of -- 0 is equivalent to no animation being performed and instant -- rotation. The default value is 20. rotationSpeed :: TurtleCommand Float -- | Returns the turtle's pen color. The color of the turtle's pen.The -- default color is black. penColor :: TurtleCommand Color -- | Returns whether the turtle's pen is down. When the turtle's pen is -- down it will draw a line when it moves. The default value is -- True. penDown :: TurtleCommand Bool -- | Returns the turtle's pen size. Defaults to 2. penSize :: TurtleCommand Float -- | Returns whether the turtle is visible. The default value is -- True. visible :: TurtleCommand Bool -- | Given a command, runs the command, then resets the turtle's state back -- to what the state was before the command was run. branch :: TurtleCommand a -> TurtleCommand a -- | Set the turtle's pen color. See penColor. setPenColor :: Color -> TurtleCommand () -- | Sets the turtle's pen to down or up. See penDown. setPenDown :: Bool -> TurtleCommand () -- | Sets the turtle's pen size. See penSize. setPenSize :: Float -> TurtleCommand () -- | Sets the turtle's representation to a Picture. See -- representation. For example, to set the turtle as a red circle: -- --
--   import Graphics.WorldTurtle
--   import qualified Graphics.Gloss.Data.Picture as G
--   
--    myCommand :: TurtleCommand ()
--    myCommand = do
--      setPenColor red
--      setRepresentation (G.color red $ G.circleSolid 10)
--      forward 90
--   
setRepresentation :: Picture -> TurtleCommand () -- | Sets the turtle's visibility. See visible. setVisible :: Bool -> TurtleCommand () -- | 0 degrees. east :: Float -- | 90 degrees. north :: Float -- | 180 degrees. west :: Float -- | 270 degrees. south :: Float -- | Graphics.WorldTurtle is a module for writing and rendering -- turtle graphics in Haskell. -- -- Take a look at the examples on Github! module Graphics.WorldTurtle -- | Takes a TurtleCommand and executes the command on an implicitly -- created turtle that starts at position (0, 0) with heading -- north. -- -- This is a convenience function written in terms of runWorld as: -- --
--   runTurtle c = runWorld $ makeTurtle >>= run c
--   
-- -- See also: makeTurtle. runTurtle :: TurtleCommand () -> IO () -- | A TurtleCommand represents an instruction to execute on a -- turtle. It could be as simple as "draw a line" or more complicated -- like "draw 300 circles." -- -- TurtleCommands can be executed in order by combining them using -- the monadic operator (>>). -- -- For example, to draw an equilateral triangle using do notation: -- --
--   drawTriangle :: TurtleCommand ()
--   drawTriangle = do
--     setHeading east
--     forward 100
--     left 120
--     forward 100
--     left 120
--     forward 100
--   
-- -- Which would produce: -- data TurtleCommand a -- | runWorld takes a WorldCommand and produces the animation -- in a new window! -- --

Interacting with the window.

-- -- While running, you can interact with the window in the following way: -- -- TODO: table runWorld :: WorldCommand () -> IO () -- | A WorldCommand represents an instruction that affects the -- entire animation canvas. -- -- This could be as simple as "make a turtle" or more complicated like -- "run these 5 turtles in parallel." -- -- Like TurtleCommands, WorldCommands can be executed in -- order by combining commands in order using the monadic operator -- (>>). -- -- To execute a TurtleCommand in a WorldCommand, use either -- the run function or the >/> operator. -- -- For how to achieve parallel animations see -- Graphics.WorldTurtle#parallel. data WorldCommand a -- | run takes a TurtleCommand and a Turtle to execute -- the command on. The result of the computation is returned wrapped in a -- WorldCommand. -- -- For example, to create a turtle and get its x -- position one might write: -- --
--   myCommand :: Turtle -> WorldCommand Float
--   myCommand t = do
--     (x, _) <- run position t
--     return x
--   
-- -- Or to create a command that accepts a turtle and draws a right angle: -- --
--   myCommand :: Turtle -> WorldCommand ()
--   myCommand = run $ forward 10 >> right 90 >> forward 10
--   
run :: TurtleCommand a -> Turtle -> WorldCommand a -- | This is an infix version of run where the arguments are -- swapped. -- -- We take a turtle and a command to execute on the turtle. The result of -- the computation is returned wrapped in a WorldCommand. -- -- To create a turtle and draw a right-angle: -- --
--   myCommand :: WorldCommand ()
--   myCommand = do
--     t <- makeTurtle
--     t >/> do 
--       forward 10
--       right 90
--       forward 10
--   
(>/>) :: Turtle -> TurtleCommand a -> WorldCommand a infixl 4 >/> -- | An associative binary operation (<|>) :: Alternative f => f a -> f a -> f a infixl 3 <|> -- | The identity of <|> empty :: Alternative f => f a