An advanced JavaFX application for exploring various fractal sets with real-time rendering, multiple calculation strategies, and extensive customization options.
Explore the infinite beauty of fractals with real-time navigation and customization
-
Multiple Fractal Types: Explore different fractal sets including:
- Mandelbrot Set
- Julia Sets with customizable parameters
- Burning Ship Fractal
- Tricorn (Mandelbar) Fractal
- Multibrot Fractals (power 3 and 4)
- Phoenix Fractal
-
Real-time Navigation:
- Click and drag to pan around the fractal
- Smooth zooming with mouse scroll wheel
- Double-click to zoom in at a specific point
- Pinch-to-zoom gesture support on trackpads
- Swipe gestures for quick navigation
-
Performance Options:
- Multi-threaded calculation using ExecutorService
- Fork/Join framework for parallel processing
- Single-threaded option for comparison
- Efficient pixel-by-pixel rendering
-
Visual Customization:
- Multiple color palettes (Smooth, Classic, Fire, Ocean, Rainbow, Grayscale, High Contrast)
- Adjustable iteration count (1-10000)
- Smooth color gradients for better visual quality
-
Image Export:
- Save current view as PNG/JPG
- Export high-resolution images (up to 4K and 8K)
- Batch export capabilities
-
Julia Set Parameters:
- Interactive parameter adjustment
- Preset famous Julia sets (Dragon, Dendrite, Rabbit, etc.)
- Real-time preview of parameter changes
-
User Interface:
- Clean menu-based interface
- Fullscreen support
- Status bar with coordinates and zoom level
- Progress indicator for long calculations
| Shortcut | Action |
|---|---|
+ / - |
Zoom in/out |
| Arrow Keys | Pan in direction |
R |
Reset to default view |
F |
Cycle through fractal types |
C |
Cycle through color palettes |
[ / ] |
Decrease/increase iterations |
Space |
Recalculate fractal |
S |
Save current image |
Shift+S |
Save high-resolution image |
H |
Show help/keyboard shortcuts |
Ctrl+R |
Reset view |
Ctrl+S |
Save image |
Ctrl+Shift+S |
Save HD image |
Ctrl+Q |
Exit application |
F11 |
Toggle fullscreen |
- Left Click + Drag: Pan around the fractal
- Double Click: Zoom in at clicked point
- Right Click: Zoom out at clicked point
- Scroll Wheel: Zoom in/out at cursor position
- Pinch Gesture: Zoom in/out (on supported trackpads)
- Two-finger Swipe: Quick pan in swipe direction
- Java Development Kit (JDK) 26
- JavaFX 26 (included via maven)
- Clone the repository:
git clone [email protected]:rokon12/Mandelbrot.git
cd Mandelbrot- Build the project:
mvn build- Run the application:
mvn javafx:runTo create a distributable package:
./gradlew distZipThe distribution will be created in build/distributions/.
- Select a Fractal Type: Use the dropdown menu to choose from available fractals
- Adjust Iterations: Higher values reveal more detail but take longer to compute
- Navigate: Click and drag to move around, scroll to zoom
- Change Colors: Select different palettes from the Color dropdown
- Save Your Discovery: Use File > Save Image to capture your view
When "Julia Set" is selected, additional controls appear:
- Preset Selection: Choose from famous Julia sets
- Custom Parameters: Enter your own complex number (c = real + imaginary*i)
- Apply Changes: Click Apply or press Enter to update the fractal
- For faster rendering, use lower iteration counts
- The Fork/Join calculator performs best on multi-core systems
- Use Executor Service for balanced performance
- Single-threaded mode is useful for debugging
Here are some stunning fractals captured using the Mandelbrot Explorer:
Deep zoom into the Mandelbrot set showing intricate spiral patterns
Another region revealing self-similar fractal structures
Vibrant colors highlighting the boundary complexity
The same region rendered with the Ocean color palette
Dramatic Fire gradient showing depth and detail
Incredibly detailed spiral formation at extreme magnification
Lightning-like tendrils reaching into the complex plane
A miniature Mandelbrot set found deep within the fractal
The Mandelbrot set contains infinite complexity. Some interesting coordinates to explore:
- Seahorse Valley: Center at (-0.75, 0.1), Zoom: 500
- Elephant Valley: Center at (0.275, 0), Zoom: 1000
- Triple Spiral: Center at (-0.1011, 0.9563), Zoom: 5000
- Mini Mandelbrot: Center at (-1.25066, 0.02012), Zoom: 100000
This application demonstrates the memory efficiency improvements from Project Valhalla's value types. The ComplexNumber class is implemented as a value record, which provides significant memory benefits for fractal calculations that create millions of complex number instances.
Analysis based on JFR (Java Flight Recorder) profiling of identical fractal rendering workloads:
| Metric | Valhalla (Value Record) | Pre-Valhalla (Simple Record) | Improvement |
|---|---|---|---|
| Object Allocations | 238 samples | 5,844 samples | 24x fewer allocations |
| GC Collections | 1 GC cycle | 143 GC cycles | 143x less GC pressure |
| GC Phase Events | 604 events | 86,339 events | 143x fewer GC events |
| Object Promotions | 104 promotions | 9,796 promotions | 94x fewer promotions |
| Recording Duration | 60 seconds | 46 seconds | 23% faster |
| Peak Heap Usage | ~40 MB | ~334 MB | 88% less memory |
Key Insights:
- Drastically Reduced Object Allocation: Value records enable stack allocation and flattening, eliminating heap allocations for short-lived
ComplexNumberinstances - Minimal GC Pressure: With 143x fewer GC cycles, the application spends more time computing fractals and less time managing memory
- Improved Cache Locality: Value types are stored inline, improving CPU cache utilization for hot fractal calculation loops
- Zero-Cost Abstraction: The elegant
ComplexNumberabstraction comes with no memory overhead
// ComplexNumber as a value record - stored inline on stack
public value record ComplexNumber(double real, double imaginary) {
public ComplexNumber square() {
return new ComplexNumber(
real * real - imaginary * imaginary,
2 * real * imaginary
);
}
}The value modifier enables:
- Stack allocation for short-lived instances
- Inline storage in arrays and objects
- Pass-by-value semantics without boxing overhead
- Zero object header memory overhead
- Strategy Pattern: For swappable calculation algorithms
- Observer Pattern: For UI updates and event handling
- Multi-threading: Parallel computation for performance
- Immutable Data: ComplexNumber value records for thread safety and performance
Each fractal implements the Fractal interface with its unique iteration formula:
- Mandelbrot: z(n+1) = z(n)² + c, where c is the pixel coordinate
- Julia: z(n+1) = z(n)² + c, where c is a fixed parameter
- Burning Ship: z(n+1) = (|Re(z)|+i|Im(z)|)² + c
- Tricorn: z(n+1) = conj(z(n))² + c
- Multibrot: z(n+1) = z(n)^d + c, where d is the power
- Phoenix: z(n+1) = z(n)² + c + p*z(n-1)
Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
This project is open source and available under the MIT License.
- JavaFX community for the excellent graphics framework
- Fractal mathematics community for the beautiful algorithms
- Contributors and testers who helped improve the application