See image and diagram below
A fast, extensible Mandelbrot fractal generator written in Go.
Supports multiple color palettes, configurable image dimensions,
iteration limits, and automatic image preview using feh on Linux.
- High‑performance Mandelbrot set renderer in Go
- Multiple color palettes (e.g.,
MonochromeSlate,NebulaSpectre,AuroraArc,ThermalHeat, etc.) - Custom image sizing and iteration depth
- PNG output
- Optional automatic preview via
feh - Clean and simple CLI interface (working on this)
🦀 go run main.go -palette MonochromeSlate -outfile /outfile/monochrome_mandlebrot.pngThe application will:
- Parse flags\
- Generate the fractal\
- Apply the selected palette\
- Save the PNG to the output file\
- Automatically open it in
feh(if available)
Flag Type Description
-palette string Selects a named color palette (e.g.,
MonochromeSlate)
-outfile string Path where the generated PNG will be
written
-width int Image width in pixels
-height int Image height in pixels
Example:
go run main.go -width 1920 -height 1080 -iters 1500 -palette Inferno -outfile fractal.pngflowchart TD
A[Start main.go] --> B[Parse Flags]
B --> C[Initialize Bounds & Constants]
C --> D[Allocate RGBA Canvas]
D --> E[For Each Pixel: Map to Complex Plane]
E --> F[Run Mandelbrot Iterations]
F --> G[Color Mapping via Palette]
G --> H[Write to RGBA Buffer]
H --> I[Encode PNG]
I --> J{feh Installed?}
J -->|Yes| K[Open Image with feh]
J -->|No| L[Exit]
e.g. go run main.go -palette "NebulaSpectre" -outfile /nebspec.png

- Go 1.21+\
- (Optional)
fehfor image preview on Linux
Install feh on Fedora:
sudo dnf install fehIf you prefer not to open the file automatically, either uninstall feh
or modify the code block that triggers:
exec.Command("feh", outfile).Start()Once rendered, the program will generate a high-resolution PNG such as:
/outfile/monochrome_mandlebrot.png
Suggested palettes for stylish renders:
- MonochromeSlate
- NebulaSpectre
- BlueInferno
- Nebula
- MetallicChrome
- ThermalHeat
- AuroraArc
mandlebrot/
│
├── README.md
├── /palette/palettes.go
├── outfile/nebula_mandlebrot.png
├── go.mod
└── main.go
MIT License.
Feel free to modify, extend, or incorporate this renderer into your own
projects.
whalelogic / Keith Thomson
Developer, cloud engineer, and fractal enthusiast.