What is this ?
This is a fractal toy that generates a picture according to a set of instructions stored in a simple string of characters (the genome).
It can be used to generate trees, squiggles and other shapes.
The algorithm used is related to
L-systems and
turtle graphics.
It is coded in javascript and uses html5 canvas.
How to write a genome
A genome is a chain of operations executed by bots. A bot draws a line as it goes forward. It can also turn and duplicate itself.
A bot executes a specific operation for every character that appears in the genome.
- f : draw forward in the direction I'm currently facing.
- n : step forward with no drawing.
- - : step backward with no drawing.
- c : draws a filled circle.
- l : turn left.
- r : turn right.
- d : duplicate - create a child in my direction.
- b : branch - 50% chance of creating a child in my direction.
- s : step - either draw forward or do nothing, at random.
- t : turn : turn left or right, at random.
- ? : turn left or right or not at all, at random.
- m : mirror - 50% chance that turning left and right are inverted.
- a:*; : defines the angle of a turn to * degrees. 90 gives square angles.
- g:*; : defines the maximum amount of generations to *. Keep it small or your browser might crash !
- s:*; : defines the starting angle to * degrees.
- b:*; : defines the branching symmetry to * branches.
- c:*; : defines the size of the circles to * (this is affected by the ratio).
- d:*; : defines the distance travelled by a step forward to * pixels (when the ratio is 1). Basically, this sets the size of the drawing.
- r:*; : defines the ratio to * (a number between 0 and 2). A ratio of 0.5 means that each generation is half the size of its parent.