https://github.com/schmonz/c-mandelbrot
Draw Mandelbrot set in C, for fun
https://github.com/schmonz/c-mandelbrot
c cairo gd imlib2 libcairo libgd mandelbrot mandelbrot-fractal mandelbrot-renderer mandelbrot-set
Last synced: about 2 months ago
JSON representation
Draw Mandelbrot set in C, for fun
- Host: GitHub
- URL: https://github.com/schmonz/c-mandelbrot
- Owner: schmonz
- Created: 2016-07-05T19:31:43.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2025-08-11T15:36:34.000Z (10 months ago)
- Last Synced: 2025-08-11T17:28:26.142Z (10 months ago)
- Topics: c, cairo, gd, imlib2, libcairo, libgd, mandelbrot, mandelbrot-fractal, mandelbrot-renderer, mandelbrot-set
- Language: C
- Homepage: https://schmonz.com/2016/07/08/how-to-learn-c-part-1/
- Size: 135 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# c-mandelbrot
[](https://github.com/schmonz/c-mandelbrot/actions/workflows/c-cpp.yml)
Lately I've been
[learning C](http://www.schmonz.com/2016/06/18/training-tdd-for-embedded-c/).
Recently I shared the story of
[how I got hooked on programming](http://www.schmonz.com/2007/06/29/when-programming-chose-me/)
on
[Developer on Fire 139](http://www.schmonz.com/talk/20160616-developer-on-fire/).
In so doing, I seem to have revived my own interest in the
[Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set).
Now I'm drawing it in C:

## TODO
7. Extract math backends: native C real math, native C complex math, GNU MPC.
7. Add performance tests for math and graphics.
7. Add math backend: [GNU Scientific Library](https://www.gnu.org/software/gsl/gsl.html).
7. Add a graphics backend that draws to a window on screen.
7. Profile: where are we spending our time?
7. Choose colormap size at runtime.
7. Compute escape times in parallel threads.
7. Improve safety and style of `graph_t.image` declaration.
7. Determine whether arbitrary-precision complex math can be made faster.
7. Determine when arbitrary-precision complex math is worth doing.
7. Use GNU Automake, Autoconf, Libtool.
7. If iterating over every pixel is slow, try:
- parallelizing computation in multiple threads (with OpenMP or similar)
- offloading to a GPU (with OpenCL or similar)
- tracing the boundary
7. Auto-scale number of iterations with zoom level.
7. Fix Valgrind errors.
7. On OS X, try
[Guard Malloc](https://developer.apple.com/library/mac/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html).
7. Try using
[C++ ApprovalTests](https://github.com/approvals/ApprovalTests.cpp)
to check the generated image.
7. Try `astyle`.
7. Try `cppcheck`.
7. In a Mac GUI, display the initial image (then maybe add features).
7. In an iPhone app, pinch to zoom (then maybe port to iPad).
7. Get ideas from [XaoS](http://matek.hu/xaos) or [Fractint](http://fractint.org).
7. Get optimization ideas from [mandelbrot-js](https://github.com/cslarsen/mandelbrot-js).