DrScheme supports a turtle graphics interface. These are the turtle functions:
Turtles also adds these syntactic forms:
(split (turn/radians (/ pi 2)))
you will have two turtles, pointing at right angles to each other. To see that, try this:
(draw 100)
You will see two lines. Now, if you evaluate those two expression again, you will have four turtles, etc
(split* (turn/radians (/ pi 3)) (turn/radians (/ pi 2)))
tprompt provides a way to limit the splitting of the turtles. Before the expression E is run, the state of the turtles (how many, their positions and headings) is "checkpointed," then E is evaluated and the state of the turtles is restored, but all drawing that may have occured during execution of E remains.
For example, if you do this:
(tprompt (draw 100))
the turtle will move forward 100 pixels, draw a line there and then be immediately put back in it's original position. Also, if you do this:
(tprompt (split (turn/radians (/ pi 2))))
the turtle will split into two turtles, one will turn 90 degrees and then the turtles will be put back into their original state - as if the split never took place.
The fern functions below demonstrate more advanced use of tprompt.
In the file ``turex.ss'' in the ``graphics'' library of your PLT distribution, you will find these functions and values defined, as example turtle programs. (The file is located in the ``graphics'' subdirectory of the ``collects'' subdirectory of the ``mred'' subdirectory of the PLT distribution).
This will draw the Peano space-filling curve, using split.
This will draw the Peano space-filling curve, without using split.
(turn/radians (- (/ pi 2)))