Designing An L-System Playground with Raylib in C++

Overview

Over the past few months, my interest in proceduralism has been growing steadily and I have been craving coding projects through which I can practice something complex yet interesting. I decided to focus on L systems, because they are relatively simple to implement in any programming language, leaving me with the time to solve other programming problems that would make this an intuitive application to use. 

I wanted to design something that is fairly easy to use and understand but also pleasurable to observe. L-systems can produce some mesmerizing pattern which are after constrained to a single image or frame.

Flaws and Learnings

Although the L-system canvas is in 3d, the actual system can only interpret 2d and L-system rules, meaning we can do fancy stuff like rolling. However, implementing this is not too much of a headache. 

The system is also not really memory efficient. If I had to do this again I would probably be more mindfulof memory management as the result string grows exponentially depending on the inputted rules. This is the main performance bottleneck of this implementation.  

Aside from these two flaws, my final program itself could benefit from more features like drawing multiple instances of different L-systems with their animations and rules. This can come in the future along with other quality-of-life improvements like more controls, themes, and better camera controls.


Intentions and Technology

L system gen is a simple Windows desktop application that draws and animates L-systems. It comes with a drawing canvas and a control interface. Users can enter or manipulate preset rules and parameters through this interface to draw an L-system, of n-number iterations. Users can also use one of three animation modes to watch the L-systems evolve.

I decided to use this program to familiarize myself with Raylib. I wanted to practice C++ and familiarise myself with building and deploying cross-platform graphical applications. But I wanted to spend a few weeks on this, not a month getting Vulkan or GL to play nice, hence using a graphics library. Raylib is as simple as Processing or P5JS, both of which I have experience in from the past, making it super quick to get up and running with just a  few functions. I am using ImGui as my User Interface library, wrapped with rlmgui to make it play nice with Raylib. I did not use a build script this time but rather set everything up through vs code as the project followed a simple OOP structure of modular classes.