[Phaser 3] L-systems demo

Hi all,
I recently discovered Lindenmayer systems, which I find very interesting not only for performing some kind of procedural graphics but also for creating levels. And as now with the quarantine I have plenty of time … :mask:

In this demo, self-replicating (fractal) forms are rendered. To do this, it uses the LsPointsGenerator class, which converts a Lindenmayer string into a map of suitable points for rendering, also adding random factors in the system.

Demo: https://jjcapellan.github.io/ls-points-generator/
Repository demo: https://github.com/jjcapellan/ls-points-generator/tree/master/demo
Repository LsPointsGenerator: https://github.com/jjcapellan/ls-points-generator

Some images:

About the demo:
I used a graphics object to make the lines of different thickness and colors between each point and its ancestor, but I couldn’t use the lineGradientStyle method to get a gradient between points since it didn’t appear when generating the texture (using generateTexture ()). It seems that it is a problem of difficult solution.

About LsPointsGenerator:
The memory consumption of an ls-system increases in geometric proportion with each iteration, so it is essential to previously calculate the number of points that will be generated in order to reduce the number of iterations if necessary before generating the map. I learned this lesson the hard way. :grinning:

I hope you like it.

Greetings.

4 Likes

Really cool!

1 Like