I have long been interested in fractals, so when I discovered Lindenmayer Systems as a simple way to create them, I was inspired to write a Lua script that can transform L-systems into stereo waveforms in Osci-Render. In this script, you can easily create your own L-system and render it at different iterations and frequencies. Hypothetically, anything you can draw with only connected straight lines can be rendered with an L-system.
What is an L-system?
L-systems are a way to describe growth patterns, including how fractals emerge from a simple set of rules. The online L-System renderer by piratefsh is a GREAT way to play around and experiment with different ideas before plugging them into my script in Osci-Render.
<<http://piratefsh.github.io/p5js-art/public/lsystems/>>
Try looking up the Wikipedia article or a YouTube video to learn how they work! Here's the video that introduced me to the idea:
<<https://youtu.be/OMB1JLIdwNA?si=Gx3K3MdVi8QSWLm2>>
Key Features of the Script:
1. Customizable L-systems: Choose your own axiom, rules, angle, length, and number of iterations to generate unique and captivating designs. I've included a few examples to help get you started.
2. Interactive Sliders: Take full control of your creations with easy-to-use sliders for adjusting parameters like frequency, iteration, size, and even some fun effects.
3. Efficient Move Reduction: Automatically optimize your L-systems by removing unnecessary moves to enhance performance and change the timbre of your image's sound. This works by modifying the output string itself, so you can even run this outside of Osci-Render and connect it to other scripts that use L-systems!
4. Explanations and Debugging: The script is filled with comments, enabling you to learn how everything works and even make modifications. The code is organized so that functions and variables are defined first, making the logic flow that comes afterward easier to read. There are also debugging toggles that tell you what happens in the first sample via the console.
5. Approximation at High Frequencies: With enough iterations, you might have so many details in your image that Osci-Render physically can't calculate everything fast enough, even at the highest sample rate. When that happens, the script approximates your image instead, preserving your desired frequency at the cost of clarity.
Have fun! Feel free to send an email to gradenLT@gmail.com if you encounter any unexpected issues.
v1.0.2 Patch Notes:
Fixed an issue where the find_dif_start_end_angle function would return a nonzero number of turns if the final angle of an L-system string was coterminal with the initial angle.
Added a function, interp_axiom, which prevents spaces in the axiom from being counted as moves.
In L-System Examples, moved all custom settings from the top of lua files to the CONFIG section of those lua files.
In L-System Examples, fixed a typo in the custom setting for slider_b in the "Text" script.
Corrected some mistakes in the README file.
Pssst! Here's a bit of inspiration ;)
|
|
\/
The recursion formula behind life itself?--PREVIOUS VERSIONS--
v1.0.1 Patch Notes:
Changed the N_calc function to take the floor of input values. This means the range of slider_b must be defined in the project or artificially adjusted in the code to get iterations higher than one. The tradeoff is simpler logic, and that you can now tell the true iteration (N) by rounding down slider_b.
In v1.0, N_calc had domain = [0,1] and range = [1, max_N] with a separate case for iteration = [some positive integer]. Not only was the use of multiple cases confusing, but the condition distinguishing between them was faulty.
Updated Recursion Logic to allow iteration = 0, i.e. return the axiom without recursion
Script files now have the .lua extension and can be imported directly into Osci-Render
Improved readability of the README and the commented instructions in the main script