Fall Forest Generator
I've been participating in this year's Weird Web October and it's been a lovely excuse to be creative and play with hand-coding various goofy things. I'm compiling all those little pages in one convenient place, feel free to follow along!
One of the day's prompts was "Organic", which led me into playing with L-systems and generating a little tree:
I was really happy with the ruleset and variation in shapes it provided, so I wanted to branch out and see a whole forest of them at once! Then I wanted a pretty backdrop of sky and ground. That led to playing with adding some rolling hills (the code for which I had in an old Glitch demo! 🫗), and tweaking and tweaking. I find the results so pleasing they deserved their own dedicated page. You can keep clicking to generate different layouts/ color schemes.
During drawing, the generated symbols are interpreted with some natural random variation in things like angle and distance traveled. Here's the L-system rules after tweaking for the forest, along with how they're interpreted:
# When a symbol has multiple replacements, one is chosen at random with equal probability.
# If a symbol has no replacements, it is copied to the next generaton as-is.
# All trees start as "TRFFL"
T: Trunk, each T increases the weight of the trunk stroke
B: Branch, reduce trunk stroke weight
R: Roots, adds two diagonal strokes for the base of the trunk
F: Forward, advances trunk/branches
L: Leaf, draws a leaf, acts as new growth
+: Turn Clockwise
-: Turn Counterclockwise
[: Push the current state onto the stack
]: Pop the top state from the stack and resume from there
# Rules
L -> B+[--FL]-[FFL][++FL]
L -> B-[++FL]+[FFL][--FL]
L -> B[---FL][--FL][FFL][++FL][+FL]
F -> F
F -> FF
T -> T
T -> TT
T -> TT # twice because I didn't feel like implementing weights
I also had a really nice time playing with color using the newer CSS color spaces and
functions, in particular
oklch
and
color-mix.
I've decided to set it aside for now and keep following Weird Web October but I want to pull some of this into a simple walking simulator or some other small game, because the aesthetics are really pleasing to me!
Happy Autumn 🍁