Îõ³h%Bã?â<      !"#$%&'()*+,-./0123456789:;None™< worldturtle*What it says on the tin. A lerp function. = worldturtle±Return 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.>?@ABCDEFGHIJKLMNOP<=Color 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.QRSTUVWXYZ[\]^_`abcdefghijklm WorldTurtle"(c) Archibald Neil MacDonald, 2020BSD3archibaldnmac@gmail.com experimentalPOSIXNone5 worldturtle×Creates the default turtle polygon arrow with a given outline color and fill color. worldturtleÇDraws 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.NoneY nopqrstuvwxyzNone 0 worldturtleÄThe Turtle that is drawn on the canvas! Create a new turtle using .{ worldturtle2Maybe Coroutine on top of the State Monad of form SequenceCommand aÿ. This represents a computation that can be "paused." I.E. we can only animate so much of the scene with the time given.| worldturtle&Generates default parameter arguments.} worldturtle*Attempts to reduce our simulation time by dù. If we run out of simualtion time, this Monad whill yield, allowing for a render, before it continues once again.~ worldturtle-Given a picture, adds it to the picture list. worldturtleêGiven a sequence, 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 two sequences a and bÕ, instead of running them both as separate animations, run them both in parallel!} worldturtle*Decrement simulation time by this amount.  worldturtle,True if simulation yielded, false otherwise.~ worldturtlePicture to add to our animation worldturtleCommands to execute€ worldturtle Sequence a to run. worldturtle Sequence b to run. worldturtle3New sequence of A and B which returns both results.‚{ƒ„…|}~†‡ˆ‰€ 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, such as "run these 5 turtles in parallel."Like s, Ýs can be executed in sequence by combining commands in order using the monadic operator Š. To execute a  within a , use the   function or   operator.For parallel animations, see  . 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 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 worldturtleCommand to execute worldturtle!Turtle to apply the command upon. worldturtle Result as a ‹ŒŽThe commands used"(c) Archibald Neil MacDonald, 2020BSD3archibaldnmac@gmail.com experimentalPOSIXNoneÖÛ4. 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 2.  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  . worldturtleÔStamp a copy of the turtle shape onto the canvas at the current turtle position. worldturtle3Writes a string to screen at the turtle's position.3The written text color will match turtle pen color.This is eqivelent to: label = label' 0.2 worldturtle Variant of Æ which takes a scale argument to scale the size of the drawn text. 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. worldturtleÉReturns 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 2 (90. degrees). No line is drawn moving the turtle. worldturtle2Sets the turtle's position to the new given value.äThis command does not animate, nor is a line drawn between the old position and the new position.Use  if you want a drawn line.2This command does not affect the turtle's heading. worldturtle2Sets the turtle's position to the new given value.This command will animate. A line will be drawn between the turtle's old position and the new set position if the turtle's pen is down.Use ! if you do not want a drawn line.2This command does not affect the turtle's heading. 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 . worldturtleÖReturns 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 . worldturtle†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.  worldturtleÄSets the turtle's pen to down. Turtle will draw as it moves. See  and !.! worldturtleÆSets the turtle's pen to up. Turtle will not draw as it moves. See  and  ." 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 to visible. 4The turtle's representation will be drawn to canvas.See $ and &.& worldturtle*Sets the turtle's visibility to invisible.8The turtle's representation will not be drawn to canvas.See $ and %.' 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 '.) worldturtleŠ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 720.* 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- worldturtleÇClears all drawings form the canvas. Does not alter any turtle's state.. worldturtle×World sleeps for a given amount of time in seconds before running the next command. This is the  WorldComamnd variant of /.$A negative value will be clamped to 0./ worldturtleßTurtle waits for a given amount of time in seconds before continuing with the next command. This is the  variant of ..$A negative value will be clamped to 0.0 worldturtle'Repeats the same command several times.Example: -repeatFor 4 $ do forward 50 right 90This is an alias of ‘.That is: repeatFor = replicateM_1 worldturtleûGiven a command, runs the command, then resets the turtle's state back to what the state was before the command was run.2 worldturtle90 degrees.3 worldturtle0 degrees.4 worldturtle180 degrees.5 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. worldturtleString to write to screen. worldturtleScale of text to draw. worldturtleString to write to screen.  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. 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." worldturtleSize of turtle's pen.# worldturtleNew size for turtle's pen.$ worldturtleTrue if turtle is visible, False if not.' worldturtleSpeed of turtle.( worldturtle New speed.) worldturtleRotation speed of turtle.* worldturtleNew rotation speed., worldturtlePicture to apply.. worldturtle#Amount of time to sleep in seconds./ worldturtle"Amount of time to wait in seconds.0 worldturtle$Number of times to repeat a command. worldturtleCommand to repeat.0  !"#$%&'()*+,-./0123450 -. (*/0+')"$1 !#,%&3245 WorldTurtle"(c) Archibald Neil MacDonald, 2020BSD3archibaldnmac@gmail.com experimentalPOSIXNone?o6 worldturtleTakes a Õ and executes the command on an implicitly created turtle that starts at position (0, 0) with heading 2. 3This is a convenience function written in terms of 9 as: -runTurtle c = runWorld $ makeTurtle >>= run c See also: .7 worldturtle Variant of 67 which takes an additional background color parameter. 8 worldturtleWhile s can be combined with ŠÛ to produce sequential instructions, we can also use the parallel animation operator 8Ì to achieve parallel instructions. That is: animate two turtles at time!Here is an example: õ import Graphics.WorldTurtle main :: IO () main = runWorld $ do t1 <- makeTurtle' (0, 0) north green t2 <- makeTurtle' (0, 0) north red -- Draw the anticlockwise and clockwise circles in sequence. t1 >/> circle 90 >> t2 >/> circle (-90) clear -- Draw the anticlockwise and clockwise circles in parallel. t1 >/> circle 90 >!> t2 >/> circle (-90)*Which would produce an animation like this )docs/images/parallel_serial_turtles_2.gifparallel and serial gif Note that 8 is an alias for ’, and is defined as:  (>!>) = bindM2 (const . return)9 worldturtle9 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 key: worldturtle Variant of 97 which takes an additional background color parameter. ; 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 106 worldturtleCommand sequence to execute.7 worldturtleBackground color. worldturtleCommand sequence to execute.8 worldturtle$First command to execute in parallel worldturtle&Second command to execute in parallel. worldturtleResult command9 worldturtleCommand sequence to execute: worldturtleBackground color worldturtleCommand sequence to execute; worldturtle!Turtle to apply the command upon. worldturtleCommand to execute worldturtle Result as a ÙQRSTUVWXYZ[\]^_`abcdefghijklm  !"#$%&'()*+,-./0123456789:; 679:;883;4“     !"#$%&'()*+,-./0123456789:;<=>?@ABCD EF GHIJKILMILNILOILPILQILRILSILTILUIVWIVXIVYIZ[IZ\IZ]IZ^ _ `IabIacIadIaeIafIagIahIaiIajIakIalIamIanIaoIapIaqIarIasIatIauIavIawIaxIayIaz {| {} {~ {€(*,/$8641‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•  –  — ˜ ™“š›œžŸworldturtle-0.3.1.0-inplaceGraphics.WorldTurtle.CommandsGraphics.WorldTurtle.ColorGraphics.WorldTurtle.ShapesGraphics.WorldTurtle$Graphics.WorldTurtle.Internal.Coords$Graphics.WorldTurtle.Internal.Turtle&Graphics.WorldTurtle.Internal.Sequence makeTurtle&Graphics.WorldTurtle.Internal.Commandsrun>/>>!>Àgloss-renderi_-1.13.1.1-b9ba44bfc03e7fea320c154c044df1036b57cd0f%Graphics.Gloss.Internals.Data.PicturePointshiftHue turtleArrow thickLineTurtle TurtleCommand WorldCommand makeTurtle'backwardbkforwardfdstamplabellabel'rightrtleftltcirclearcpositionhomejumpgotoheading setHeadingpenColor setPenColorpenDown setPenDownsetPenUppenSize setPenSizevisible setVisible setInvisiblespeedsetSpeed rotationSpeedsetRotationSpeedrepresentationsetRepresentationclearsleepwait repeatForbranchnortheastwestsouth runTurtle runTurtle'runWorld runWorld'lerpnormalizeHeading7gloss-1.13.2.1-6064f4a467ec1fc96ab038b0566a3011024c7c95Graphics.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 defaultTSCdecrementSimTime addPicture startSequence runParallelTSC SequencePause finalPicspicsturtlesresumeSequence renderPausegenerateTurtleanimate'baseGHC.Base>>seqTseqWseqToTPicture Control.Monad replicateM_?monad-parallel-0.7.2.5-af23555311ce519d18edf76345743847a33b1cc9Control.Monad.ParallelbindM2