Fractals have always fascinated me, no matter which shape or size they come in, no matter what patterns they resemble within them. For the ones who are still in the dark, fractals are just a self replication of a particular pattern.
There are many fractals that are found in nature. One such fractal curve is known as Heighway Dragon, or simply the Dragon Curve. Because this is a fractal, hence it requires an IFS (Iterated Function System). In simple words, we make a simple pattern, put it into a recursive function, before running a loop and calling the function over and over again until our objective is accomplished. This is the route that I took. Of course this can be done without recursion(using loops) which I will put as the other solution.
I used Python with Turtle package for both the methods, which simplifies my work down by a ton. Had I done it in C++, I would have had to write functions, and classes for drawing, painting, iterating and putting everything into a window. However, I do have plans for that, and if I can come up with a nice and easy working C++ code, I will put it up here. For now, let’s get cracking with Python.
P.S. The logic behind the code can be found in the documentation folder of this repository.
- Python
- Turtle Module