Thank you for your interest in contributing! Whether you're fixing a typo, reporting a bug, or diving deep into SIMD optimizations — all contributions are welcome.
- Getting Started
- Project Structure
- Building the Project
- Running Tests
- Code Style
- Submitting Changes
- Areas of Interest
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/mandelbrot-c.git cd mandelbrot-c - Create a feature branch:
git checkout -b feat/your-feature-name
The codebase follows a strict Engine-Centric Architecture with clear Separation of Concerns:
src/
├── core/ # Pure math — no platform dependencies (SSOT)
│ # mandelbrot.c, julia.c, burning_ship.c, tricorn.c,
│ # celtic.c, buffalo.c, fractal.c, color.c
├── engine/ # Platform-agnostic logic
│ # renderer.c, tour.c, bookmark.c, app_state.c,
│ # camera.c, screenshot.c, input_handler.c, perturbation.c
└── app/ # Platform entry points (thin wrappers only)
# desktop_cpu_main.c, desktop_gpu_main.c,
# web_main.c, video_renderer_main.c
Key rule:
src/core/must never#includeanything fromsrc/engine/orsrc/app/. The core layer is the Single Source of Truth for all fractal mathematics.
# Interactive menu
./build.sh
# Or directly:
cmake -S . -B build_cpu -DBUILD_CPU=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build_cpuSee README.md for full prerequisites and platform-specific instructions.
emcmake cmake -S . -B build_web -DBUILD_WEB=ON
cmake --build build_web
python3 scripts/server.py # then open http://localhost:8081Always run the full test suite before submitting a PR:
cmake -S . -B build_cpu_test -DBUILD_CPU=ON
cmake --build build_cpu_test
ctest --test-dir build_cpu_test --output-on-failure| Test | What it checks |
|---|---|
test_math |
Mandelbrot/Julia/Burning Ship escape math, cardioid/bulb rejection, AVX2 vs scalar within 1e-7 |
test_simd_math |
Dedicated SIMD correctness — verifies AVX2/AVX-512/NEON outputs match scalar reference across all 6 fractal types |
test_renderer |
Thread pool dispatch — pixel output across all worker threads |
test_color |
All 22 palette functions produce valid ARGB values and gradient continuity |
test_bookmark |
Bookmark serialization and round-trip load/save |
test_tour |
Tour phase state machine and coordinate interpolation |
test_config |
settings.txt parsing and default fallback values |
test_app_state |
App state serialization and restoration |
test_perturbation |
Perturbation theory math consistency |
test_bignum |
Arbitrary-precision BigNum math |
AVX2 note: SIMD consistency tests are automatically skipped on machines without AVX2 support.
This project enforces formatting via clang-format. A .clang-format config file is included at the repo root.
Before committing, format all changed files:
# Format a single file
clang-format -i src/core/your_file.c
# Format all C source files
find src -name "*.c" -o -name "*.h" | xargs clang-format -iThe CI Formatting workflow will fail if any file is not properly formatted.
- C99 only — no C11/C23 features, no C++
- No external runtime dependencies in
src/core/— pure C math only - Keep functions focused and small — prefer extracting helpers over long functions
- AVX2/AVX512 intrinsic code must always have a scalar fallback path
This codebase enforces a specific, terse comment style:
- Block vs Inline: Use
/* ... */for explanations that are long, multi-line, or describe why something is done. Use//for short, single-line notes. - File Headers: Every
.cand.hfile must start with a block comment indicating its filename, followed by a short description. - No Redundancy: Do not add comments to lines that are self-explanatory from naming alone. Do not state the obvious.
For AI assistants (like Cursor, Gemini, Copilot) working on this repository:
- Read These Rules First: Always adhere to the architectural constraints and the strict commenting style above.
- Iterative Changes: Work file-by-file when making sweeping changes, showing a short diff-style summary before moving to the next file.
- Minimalism: Keep changes minimalistic and focused on the user's requirements. Do not over-engineer.
- Open an issue first for non-trivial changes — discuss the approach before writing code
- Keep commits focused and atomic — one logical change per commit
- Use descriptive commit messages:
feat(core): add tricorn variant with SIMD vectorization fix(web): restore fractal mode from URL parameter on load docs: update palette table in README to reflect 22 palettes - Open a Pull Request against
masterwith a clear description of:- What changed and why
- How to test it
- Any benchmarks if it's a performance-related change
Contributions are especially welcome in these areas:
| Area | Description |
|---|---|
| Memory safety | Catching leaks, use-after-free, or race conditions |
| SIMD optimization | AVX-512, NEON (ARM), or WASM-SIMD128 improvements |
| GPGPU | Shader precision, new GPU-only palette effects |
| Arbitrary precision | Research into infinite-zoom arithmetic (see Roadmap) |
| New fractal types | Additional variants pluggable into the fractal registry |
| Benchmarks | New benchmark scenarios in benchmarks/cpu/ or benchmarks/gpu/ |