proto-repl-charts.examples.canvas.l-system

This provides an example of drawing on the canvas using Lindenmayer Systems
aka L-systems. Based on https://brehaut.net/blog/2011/l_systems

draw-fractal

(draw-fractal options)
Uses an l-system to draw a fractal on a canvas.

Options:

  Canvas options

   * canvas-name - The name to use for the canvas.
   * clear-rect? - defaults to true

   L-system Options

   * start - The starting string to expand in the l-system
   * depth - The number of recursions
   * rules - The rules to expand the starting string.

   Initial turtle location and direction

   * x - initial x location on canvas
   * y - initial y location on canvas
   * start-direction - start direction in degrees. Defaults to 0
   * operations - A map of l-system items to commands to run on the turtle

end-branch

(end-branch turtle)
Ends a branch for the turtle. Returns it back to it's last known location.

expand-l-system

(expand-l-system production-rules depth items)
Expands the sequence of items using the given production rules.
* items - A sequence of elements to be expanded. Usually a string of characters.
* production-rules - a function that takes one item from the sequence and return
  a sequence of new items that it expands to. Usually a map of characters to strings.
* depth - The number of times to expand the items.

Example:
(expand-l-system {\A "AB" \B "A"} 3 "A")
=> (\A \B \A \A \B)

forward

(forward turtle distance)
Moves turtle forward the specified distance.

random

(random minv maxv)
Chooses a value between min and max

rotate

(rotate turtle theta)
Rotates the turtle the specified number of radians

start-branch

(start-branch turtle)
Start a new branch on the turtle

value-with-chaos

(value-with-chaos chaos v)
Returns a value adjusted by a certain amount of randomness.