Some Pretty fractals in C + SDL2
If you’ve ever wanted to draw fractals in C, here’s some code for you. These come from Misha on his(her?) GitHub page. There are three as you can see. Each has their own program – barnsley.c, sierpinski.c and y-fractal.c. All three programs create an SDL2 window then display the image.
Note that this was coded for Linux. I modified the programs so they would run on Windows and the screenshot was done from my machine. I know these images are on the GitHub page.
If you want to compile and run, then on all three programs change the SDL include from
Also with the barnsley.c you need to give initial values to mx and my in the renderFractals() function (lines 88 and 89) and change these two lines: (114 and 115). No other changes are needed to let them compile.
mx_c = mx - win_w / 2; my_c = my - win_h / 2;to
mx_c = mx - WIDTH / 2; my_c = my - HEIGHT / 2;