For today’s post I thought I’d take you through some of my “creative process” for playing with L-Systems, fractals created using an algorithmic grammar.
We start with a simple shape:
This shape is my “replacement rule” for the L-System. To draw this shape I use the sequence of letters F-F+F+F-F, with F meaning “draw a line forward”, ‘-‘ meaning “turn left 120 degrees” and ‘+’ meaning “turn right 120 degrees.” If I start with a triangle, and replace each side of the triangle with this starting shape I get the following:
If I repeat this for each line of the new shape, and again on each line of the resulting shape, after a few iterations I get this:
The Sierpinski Gasket, one of the most persistent recurring fractals with untold methods for drawing it.
But what if I didn’t start with a triangle? What if I started with a square?
Then I’d get this:
That’s pretty good, but if what if inverted the square by flipping it inside out. A typical square is drawn F+F+F+F with ‘+’ being a right turn of 90 degrees. But if I change those pluses to minuses I get this:
And here’s what an inverted pentagon would look like:
Okay, that’s pretty good, but what if we skewed our initial replacement shape?
So now our initial triangle would look something like this:
Keep repeating this process and you get something really different:
Same number of lines that we used to draw our Sierpinski Gasket, but with less overlap (this is one of my favorites). Let’s try another skewed shape:
And the resulting first stage is:
Now what do we get?
That’s good but let’s invert it. Our first stage is:
And after a few iterations we get:
Now let’s start with an inverted hexagon:
And see what happens:
If we turn the hexagon right-side out:
We get this:
But L-Systems also allow for moving without drawing a line, typically represented by the ‘f’ character. Let’s take our first motif and remove a section:
If we apply this replacement rule to an inverted triangle we get this:
And after a few iterations:
Turn our triangle right-side out and we get:
Followed by:
Here’s a couple other skip motifs:
And the result:
Initial Stage:
Result:
Now let’s remove some sections from our skewed replacement rules:
First Stage:
Result:
Replacement Motif:
First Stage:
Result:
Each of the above shapes had no replacement rule for ‘f’ so these segments were kept empty. If we use the same replacement rule for ‘f’ as we do for ‘F’, we get these respectively:
And this:
Similar to our originals, but with less internal lines.
Finally, let’s look at a couple more variations. A wider initial stage can stretch our gasket:
Motif:
First Stage:
Result:
And a hex-bump creates a non-overlapping curve.
Motif:
First Stage:
Result:
All of these shapes were created from variations on a five-line motif. Hopefully you can see from this post how tiny variations in method can create huge changes in result.
Have a happy fractal friday!
*All images were created using L-System 6 from Chapter 4 of Fractals: A Programmer’s Approach available on Amazon. Download a docx file containing all of the XML data for these images here. Hi-res versions of the above images are available by clicking on each image.
Like cool fractal designs, maybe some you can color? Then check out my latest Adult Coloring Book: Fractals available on Amazon.