[Rod Stephens Books]
Index Books Python Examples About Rod Contact
[Mastodon] [Bluesky]
[Build Your Own Ray Tracer With Python]

[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

Title: Draw L-system fractals interactively in Python

[A fractal tree drawn interactively using an L-System]

This example builds upon the two previous examples:

This example lets you enter L-system parameters interactively to draw fractals.

The changes are fairly involved (because the program uses tkinter) but they're not very interesting so I won't show them here. Download the example to explore them for yourself.

If you pick a fractal from the dropdown list, the program populates its text boxes with that fractal's L-system parameters. You can modify those parameters if you like. Then click Draw to draw the fractal.

Two interesting features of this program involve ferns and spirals. If you start with a fern fractal and modify the parameters, you'll often get something fern-like, as in the picture on the left below. Because it's asymmetrical, its shape can change quite a bit at different depths.

The picture on the right below shows a spiral. It's not completely obvious whether spirals are fractals. They do have self-similarity and appear the same at different scales but they don't show much in the way of complexity. I don't know if they have fractional dimension. Some online posts say definitely yes and others say definitely no. The former seem more authoritative so my guess is at least some are. In particular, I suspect this one is fractal.

[A fern fractal drawn interactively using an L-System] [A spiral drawn interactively using an L-System]

Download the example to see additional details.

© 2024 Rocky Mountain Computer Consulting, Inc. All rights reserved.