A Python project that generates beautiful, animated visualizations of the Mandelbrot set fractal. Create stunning zoom animations and high-resolution static images of mathematical art.
This project generates animated zoom sequences into the Mandelbrot set, one of the most famous fractals in mathematics. The Mandelbrot set is defined by the iteration formula:
z_{n+1} = z_n² + c
where z starts at 0 and c is a point in the complex plane. The algorithm visualizes how different points behave under iteration, creating intricate and beautiful patterns.
- Animated Zoom Sequences: Generate smooth zoom animations into beautiful regions of the Mandelbrot set
- Rainbow Colorization: Beautiful RGB color gradients that highlight the fractal structure
- High-Resolution Output: Generate both animated GIFs and static high-res images
- Customizable Parameters: Adjust zoom factor, number of frames, resolution, and iteration count
- Progress Tracking: Real-time progress indicators during generation
- Python 3.11 or higher
- numpy
- matplotlib
- pillow (PIL)
git clone <your-repository-url>
cd "Frames based UI Generator"# Create virtual environment
python3 -m venv env
# Activate virtual environment
# On macOS/Linux:
source env/bin/activate
# On Windows:
# env\Scripts\activatepip install -r requirements.txtpython art.pyThe script will automatically:
- Generate 30 frames of zooming animation
- Create an animated GIF showing the zoom sequence
- Generate a high-resolution static image of the full Mandelbrot set
- Save all output in the
mandelbrot_frames/directory
mandelbrot_frames/mandelbrot_zoom_animation.gif- Animated zoom GIFmandelbrot_frames/mandelbrot_masterpiece.png- High-resolution static imagemandelbrot_frames/frame_*.png- Individual frames
You can customize the generation by modifying the parameters in art.py:
# In the main() function:
# Resolution settings
animator = MandelbrotAnimator(width=600, height=450, max_iter=80)
# Animation settings
animator.generate_zoom_sequence(
num_frames=30, # Number of frames
zoom_factor=1.15 # Zoom level per frame
)- width/height: Resolution of each frame (default: 600x450)
- max_iter: Maximum iteration count (higher = more detail, slower)
- num_frames: Number of frames in the animation
- zoom_factor: How much to zoom per frame (1.15 = 15% zoom per frame)
To explore different areas of the Mandelbrot set, modify the center point in generate_zoom_sequence():
center_x, center_y = -0.7269, 0.1889 # Interesting spiral regionTry these coordinates for different beautiful regions:
-0.5, 0- Main heart region-0.7269, 0.1889- Spiral region (default)-0.75, 0.11- Seahorse valley-1.543, 0- Elephant valley
Run the test suite to verify the Mandelbrot generator:
# Run all tests
python test_art.py
# Or use pytest for more detailed output
pytest test_art.py -vThe test suite includes:
- ✅ Initialization and configuration tests
- ✅ Mandelbrot calculation correctness
- ✅ Color generation validation
- ✅ Zoom sequence generation tests
- ✅ GIF and image file creation tests
- ✅ Mathematical correctness verification
- ✅ Boundary condition tests
- Mandelbrot Calculation: For each pixel in the complex plane, iterate the formula z = z² + c until |z| > 2 or max iterations reached
- Colorization: Map iteration counts to beautiful RGB gradients using sine waves
- Zoom Animation: Progressively zoom into a specific region over multiple frames
- Output Generation: Combine frames into animated GIF and save as PNG
Frames based UI Generator/
├── art.py # Main Mandelbrot generator
├── test_art.py # Test suite
├── requirements.txt # Python dependencies
├── README.md # This file
├── LICENSE # MIT License
├── .gitignore # Git ignore rules
└── env/ # Virtual environment (not in git)
The generator produces:
- A smooth zooming animation showing the infinite detail of the Mandelbrot set
- A high-resolution static image suitable for printing or wallpaper
- Individual frames that can be used for analysis or custom animations
This project is open source and available under the MIT License.
Contributions are welcome! Feel free to:
- Add new color schemes
- Implement different fractal types (Julia sets, etc.)
- Add interactive features
- Improve documentation
- Faster Generation: Reduce resolution or max_iter for quicker results
- Higher Quality: Increase resolution and max_iter for stunning details
- Custom Zooms: Experiment with different center coordinates to discover new patterns
- Smooth Animations: Use smaller zoom_factor values (1.1-1.2) for smoother zooms
The Mandelbrot set is named after mathematician Benoit Mandelbrot, who studied it in the 1970s. It's famous for:
- Self-similarity at all scales
- Infinitely detailed boundary
- Beautiful fractal geometry
- Connections to chaos theory
Each point in the set represents a complex number c where the iteration z = z² + c remains bounded.
If you encounter any issues or have questions, please open an issue on GitHub.
Enjoy exploring the infinite beauty of mathematics! 🎨✨