Creating a beautiful fractal using L-system. For rendering I've used Qt framework. You can see the result in the following image:
For a higher resolution gif you can use this. I've used the following recurisve rules:
S → X
X → F[−X][X]F[−X]+FX
F → FF
F
means "draw forward", −
means "turn left 25 degree", and +
means "turn right 25 degree". X
does nothing during rendering. [
means push the current position and angle into stack and ]
means to retreive the top value of stack (pop operation). in each level we use both rules X → F[−X][X]F[−X]+FX
and F → FF
. For example:
- level 0:
X
- level 1:
FF[−X][X]FF[−X]+FFX
It is interesting this simple recursive formula can draw a beautiful tree!
- C++
- Qt >= 4.0.0
- qmake
You can use Qt creator IDE to make the entire project or use a terminal. In Fedora 25 You need to use the following commands:
$ mkdir build
$ cd build
$ qmake-qt5 ..
$ make
$ ./FractalPlantApp