h$:O7|5      !"#$%&'()*+,-./01234None}5 worldturtle*What it says on the tin. A lerp function. 6 worldturtleReturn a valid heading value between (0, 360]. We want 360 to be 360 (full rotation). We want 361 to be 1 (wraparound rotation). Special case: we want 0 to be 0 (no rotation). Though really 0 is equal to 360 we will let this special case slide as it helps in our time elapsed calculations.789:;<=>?@ABCDEFGHI56Color functions"(c) Archibald Neil MacDonald, 2020BSD3archibaldnmac@gmail.com experimentalPOSIXNone worldturtle5Rotates a given color's hue between [0, 360) degrees. worldturtleDegrees to change hue. worldturtleColor to shift. worldturtle!Resultant color with hue shifted.JKLMNOPQRSTUVWXYZ[\]^_`abcdef WorldTurtle"(c) Archibald Neil MacDonald, 2020BSD3archibaldnmac@gmail.com experimentalPOSIXNone worldturtleCreates the default turtle polygon arrow with a given outline color and fill color. worldturtleDraws a line from a start-point to an end-point with a given thickness. worldturtle Outline color worldturtle Fill color worldturtle Arrow shape. worldturtleStarting point. worldturtle Ending point. worldturtleLine thickness. worldturtleProduced line.None= ghijklmnopqrsNone  worldturtleThe Turtle that is drawn on the canvas! Create a new turtle using .t worldturtle.Maybe Monad on top of the State Monad of form SequenceCommand a. This represents a computation that can be "partial." I.E. we can only animate so much of the scene with the time given.u worldturtle&Generates default parameter arguments.v worldturtleGets the remaining simulation time of the current turtle process. The simulation time dictates how much time is remaining for an animation, and it will be reduced as the animations play in sequence. Once this value hits 0 the exit command will be called and the monad will stop processing.w worldturtleSets the simulation time in the state monad. If the simulation time is <= 0 then this setter will immediately call the exit function which will kill any further processing of the monad.x worldturtleTakes a value away form the current sim time and store the updated time. See w.y worldturtle-Given a picture, adds it to the picture list.z worldturtleGiven a sequence and a State, returns the result of the computation and the final state of the computation of form (r, s). When r is Just, then the computation completed, otherwise the computation ended early due to lack of time available (i.e. a partial animation).{ worldturtleGiven a computation to run and an amount of time to run it in, renders the final "picture".| worldturtleRuns two items in parallel then applies a semigroup combination operator to the result of both. This combination can only return if both A and B return. Compare to }! which can return if one returns.} worldturtle2Runs two items in sequence, returns the result of a if a- passes, otherwise returns the results of b. The implication of this is that only the result of a will be returned while animating, and b when animation is finished.w worldturtle Time to set.x worldturtle-Value to subtract from store simulation time.y worldturtlePicture to add to our animation| worldturtle Sequence a to run. worldturtle Sequence b to run. worldturtle$New sequence of A and B in parallel.} worldturtle Sequence a to run. worldturtle Sequence b to run.~tuvwxyz{|} None worldturtleA  represents an instruction to execute on a turtle. It could be as simple as "draw a line" or more complicated like "draw 300 circles."s can be executed in order by combining them using the monadic operator .8For example, to draw an equilateral triangle using  1https://en.wikibooks.org/wiki/Haskell/do_notation do notation: drawTriangle :: TurtleCommand () drawTriangle = do setHeading east forward 100 left 120 forward 100 left 120 forward 100Which would produce: docs/images/drawtriangle.gifdraw triangle gif worldturtleA  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 s, s can be executed in order by combining commands in order using the monadic operator . To execute a  in a , use either the   function or the   operator./For how to achieve parallel animations see Graphics.WorldTurtle#parallel.  worldturtle  takes a  and a  to execute the command on. The result of the computation is returned wrapped in a .-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 xOr to create a command that accepts a turtle and draws a right angle: myCommand :: Turtle -> WorldCommand () myCommand = run $ forward 10 >> right 90 >> forward 10  worldturtleCommand to execute worldturtle!Turtle to apply the command upon. worldturtle Result as a  The commands used"(c) Archibald Neil MacDonald, 2020BSD3archibaldnmac@gmail.com experimentalPOSIXNone0(  worldturtleCreates a new  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 ..  worldturtleThis variant of   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  .  worldturtle*Move the turtle backward by the specified distance,, in the direction the turtle is headed.  worldturtleShorthand for  . worldturtle)Move the turtle forward by the specified distance,, in the direction the turtle is headed. worldturtleShorthand for . worldturtleStamp a copy of the turtle shape onto the canvas at the current turtle position. worldturtle0Turn a turtle right by the given degrees amount. worldturtleShorthand for . worldturtle/Turn a turtle left by the given degrees amount. worldturtleShorthand for . worldturtleDraw 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. worldturtleDraw 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. worldturtleReturns the turtle's current position. Default (starting) position is (0, 0). worldturtle*Warps the turtle to its starting position (0, 0)" and resets the orientation to . (90. degrees). No line is drawn moving the turtle. worldturtleWarps 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. worldturtle Alias of . worldturtleReturns the turtle's heading.07 is along the positive x-axis, going anticlockwise. So:East is 0 degrees. North is 90 degrees.West is 180 degrees. South is 270 degrees.The default heading is North (90 degrees). worldturtleSets the turtle's heading. See . worldturtleReturns the turtle's pen color. The color of the turtle's pen.The default color is black. worldturtle"Set the turtle's pen color. See . worldturtleReturns 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.  worldturtle,Sets the turtle's pen to down or up. See .! worldturtle.Returns the turtle's pen size. Defaults to 2." worldturtle#Sets the turtle's pen size. See !.# worldturtle?Returns whether the turtle is visible. The default value is True.$ worldturtle%Sets the turtle's visibility. See #.% worldturtle3Returns 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.& worldturtle Sets the turtle's speed. See %.' worldturtleReturns 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.( worldturtle)Sets the turtle's rotation speed. See '.) worldturtle&Gets the turtle's representation as a .* worldturtle&Sets the turtle's representation to a  . See )4. 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+ worldturtleClears all drawings form the canvas. Does not alter any turtle's state., worldturtleSleep for a given amount of time in seconds. When sleeping no animation runs. A negative value will be clamped to 0.- worldturtleGiven a command, runs the command, then resets the turtle's state back to what the state was before the command was run.. worldturtle90 degrees./ worldturtle0 degrees.0 worldturtle180 degrees.1 worldturtle270 degrees.  worldturtleInitial position of the turtle. worldturtleInitial heading of the turtle. worldturtle)Color of the turtle and the turtle's pen. worldturtleThe generated turtle.  worldturtleDistance to move the turtle. worldturtleDistance to move the turtle. worldturtle#Rotation amount to apply to turtle. worldturtle#Rotation amount to apply to turtle. worldturtleRadius of the circle. worldturtleRadius of the circle. worldturtle+Angle to travel in degrees. For example: 360 for a full circle or 180 for a semicircle. worldturtleReturned current point. worldturtlePosition to warp to. worldturtle%Returned heading as angle in degrees. worldturtleHeading to apply.  worldturtleReturned current pen color. worldturtleNew pen color to apply worldturtle"True if pen is down, false if not.  worldturtle4New state for pen flag. True for down. False for up.! worldturtleSize of turtle's pen." worldturtleNew size for turtle's pen.# worldturtleTrue if turtle is visible, False if not.$ worldturtleNew state for visible flag.% worldturtleSpeed of turtle.& worldturtle New speed.' worldturtleRotation speed of turtle.( worldturtleNew rotation speed.* worldturtlePicture to apply.*  !"#$%&'()*+,-./01* +, &()%'!#- "*$/.01 WorldTurtle"(c) Archibald Neil MacDonald, 2020BSD3archibaldnmac@gmail.com experimentalPOSIXNone72 worldturtleTakes a  and executes the command on an implicitly created turtle that starts at position (0, 0) with heading .. 3This is a convenience function written in terms of 3 as: -runTurtle c = runWorld $ makeTurtle >>= run c See also:  .3 worldturtle3 takes a 3 and produces the animation in a new window! Interacting with the window.While running, you can interact with the window in the following way:Action InteractionPan the viewport.Click and drag Zoom in/out.Mousewheel up/down'Reset the viewport to initial position.SpacebarReset the animation.R keyPause the animation.P keyQuit Escape key4 worldturtleThis is an infix version of  ! 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 .*To create a turtle and draw a right-angle: myCommand :: WorldCommand () myCommand = do t <- makeTurtle t >/> do forward 10 right 90 forward 102 worldturtleCommand sequence to execute.3 worldturtleCommand sequence to execute4 worldturtle!Turtle to apply the command upon. worldturtleCommand to execute worldturtle Result as a JKLMNOPQRSTUVWXYZ[\]^_`abcdef  !"#$%&'()*+,-./0123423 444      !"#$%&'()*+,-./0123456789:;<=>?@A BCDEFDGHDGIDGJDGKDGLDGMDGNDGODGPDQRDQSDQTDUVDUWDUXDUYZ[D\]D\^D\_D\`D\aD\bD\cD\dD\eD\fD\gD\hD\iD\jD\kD\lD\mD\nD\oD\pD\qD\rD\sD\tD\uvwvxvyvz{)+-/%75|31}~      *worldturtle-0.2.2.0-68hfV5al0d0H5uyh27W3qYGraphics.WorldTurtleGraphics.WorldTurtle.CommandsGraphics.WorldTurtle.ColorGraphics.WorldTurtle.Shapes$Graphics.WorldTurtle.Internal.Coords$Graphics.WorldTurtle.Internal.Turtle&Graphics.WorldTurtle.Internal.Sequence makeTurtle&Graphics.WorldTurtle.Internal.Commandsrun>/>baseGHC.Base<|>empty/gloss-rendering-1.13.1.1-8DJY9w4p1JwEbyfA1K5Rhv%Graphics.Gloss.Internals.Data.PicturePointshiftHue turtleArrow thickLineTurtle TurtleCommand WorldCommand makeTurtle'backwardbkforwardfdstamprightrtleftltcirclearcpositionhomegoto setPositionheading setHeadingpenColor setPenColorpenDown setPenDownpenSize setPenSizevisible setVisiblespeedsetSpeed rotationSpeedsetRotationSpeedrepresentationsetRepresentationclearsleepbranchnortheastwestsouth runTurtlerunWorldlerpnormalizeHeading%gloss-1.13.2.1-B4o3AXcBiKhAuDRvvtRVImGraphics.Gloss.Data.Point pointInBoxGraphics.Gloss.Data.VectorunitVectorAtAngle normalizeVangleVVrotateVmulSVdetVdotVargVmagVGraphics.Gloss.Geometry.AnglenormalizeAngleradToDegdegToRad$Graphics.Gloss.Data.Point.Arithmetic*negate-+PathVectorGraphics.Gloss.Data.Colororange chartreuse aquamarineazurevioletrosemagentacyanyellowbluegreenredwhiteblackgreyN withAlphawithBlue withGreenwithReddarklightbrightdim addColors mixColors#Graphics.Gloss.Internals.Data.ColorColor makeColor makeColorI rgbaOfColor TurtleDatascale defaultTurtle drawTurtleSequenceCommand defaultTSCsimTime setSimTimedecrementSimTime addPicture processTurtle renderTurtlecombineSequencealternateSequenceTSCpics totalSimTimeturtlesgenerateTurtleanimate'animate>>seqTseqWseqToTPicture