On this page:
F
f
-
+
/
|[|
|]|
start
finish
scale-final?

8 2D L-system turtles

 (require lindenmayer/turtle) package: lindenmayer

lindenmayer/turtle provides support for 2D turtle graphics in L-systems.

lindenmayer symbol

F
F(len, _ ...)

  

len

 

:

 

real?
Moves the turtle forward and draws a line.

If len is supplied, the turtles moves that distance (negative values move backwards). If len is not supplied, F checks for a variable named l and uses its value. Otherwise, it moves two steps forward.

lindenmayer symbol

f
f(len, _ ...)

  

len

 

:

 

real?
Like F, but does not draw a line.

lindenmayer symbol

-
-(_ ...)
Rotates the turtle counterclockwise. It rotates by θ degrees if that variable is defined, and by 90 degrees otherwise.

lindenmayer symbol

+
+(_ ...)
Like -, but rotates clockwise.

lindenmayer symbol

/
/(width, _ ...)

  

width

 

:

 

(and/c real? positive?)
Set the turtle line drawing with. The default width is 1.

lindenmayer symbol

|[|
|[|(_ ...)
Save the current turtle state.

lindenmayer symbol

|]|
|]|(_ ...)
Restore the turtle to the state of the matching |[|.

procedure

(start variables)  turtles?

  variables : hash?
Creates an initial, with the turtle facing to the right.

procedure

(finish variables turtles)  pict?

  variables : hash?
  turtles : turtles?
Turns the given turtles into a pict.

parameter

(scale-final?)  boolean?

(scale-final? scale?)  void?
  scale? : boolean?
 = #t
Determines if finish scales the resulting pict so that it fits in a 300x300 rectangle.