# L-system Playground ## Current Status Completed. ## Overview An L-system, or Lindenmayer system, is a parallel rewriting system and a type of formal grammar used to model the growth of biological organisms. Przemysław Prusinkiewicz and Aristid Lindenmayer beautifully explored these concepts in the book, [The Algorithmic Beauty of Plants](http://algorithmicbotany.org/papers/abop/abop.pdf). In addition to biological growth, L-systems can be used to generate space-filling curves and to describe mathematical processes, such as fractals, through iterative production rules. This project builds a simplistic L-System playground and presents a variety of known patterns, including space-filling curves. ## Project Last year, I constructed the L-System rules for [[2023-07-27-h-curve|H-indexing curve]]. Ironically, I did this using nothing but a simple piece of paper. Although this technique works, I recognized that a lab environment, that could dynamically evaluate such rules, offering immediate feedback, would be more efficient. Lindenmayer system defines a formal grammar, similar to a programming language. I preserved a similar text-based representation. ``` F: Move forward by line length drawing a line -: Turn left by turning angle +: Turn right by turning angle A: An axiom A => B: A rule setting = value: A configuration setting ``` An intentional decision was made not to support branching, which is denoted by the symbols `‌[` and `]`. While aware of their power, my preference is to see them implemented as a "fork" operation for parallel processing, an aspect I have yet to explore. Later, it came to my attention that the `F` operator alone is inadequate for modeling fractal curves with a dimension less than 1, such as Cantor dust. As those curves are not within my primary field of interest, I didn’t implement the `f` counterpart, which moves forward without drawing a line. I have compiled a small collection of L-system rules from various sources and published them on the website provided below. I apologize for missing attributions; I lost the original sources and need to recover them. Each curve is interactive and can be adjusted as needed. URL: https://github.com/oneearedrabbit/l-sys-playground/tree/master/l-system ![[l-system-playground.png]] ## Notes This is a single-file static website that implements an L-system playground to visualize iterative fractals, in the form of a web component. It uses CodeMirror, an external dependency, to provide a code editor. To use the website, simply open `index.html` in your preferred web browser. Web Component example: ``` <web-fractal data-name="H-indexing" data-creator="oneearedrabbit" data-creation-date="2024-02-12" data-description="A new two-dimensional indexing scheme called H-indexing, which has superior (possibly optimal) locality in comparison with the well-known Hilbert indexings. H-indexings form a Hamiltonian cycle and we prove that they are optimally locality-preserving among all cyclic indexings." > order = 4 angle = 90 A => BF-F-BFFFC-F-FC+F+BF-F-BFFFC-F-FC B => BFFFC-F-FC+F+B C => C+F+BF-F-BFFFC </web-fractal> ```