Dreamlike Fractals. Worlds of Unimaginable and Infinite Beauty.
"Technosphere at the service of the Biosphere." — Peace Is The Way.
Fractals are visual proof of how surprisingly simple mathematical rules can generate worlds of infinite complexity. However, bringing that mathematical beauty into a fluid and safe web browser poses two classic engineering challenges: blocking the main thread and safe expression execution.
Today I want to introduce Fractal / Mathematical Core (Fractales de Ensueño), an open-source, zero-dependency rendering engine designed for students, teachers, and scientific computing enthusiasts.
🔗 Try the Live Demo: https://amurlaniakea.github.io/fractal/
💻 Source Code (AGPL-3.0): https://github.com/amurlaniakea/fractal
🧠 Architecture: Real 60 FPS Without Frameworks
When you increase the zoom level or raise the iterations per pixel in a Mandelbrot set, floating-point calculation (Float64) becomes intensive. If you run that loop on the browser's main thread, the interface freezes.
To prevent this, the project completely separates the visual layer from the computation layer:
-
Reactive Interface (
index.html+ui-overlay.css): Manages real-time controls (zoom, color palettes, iterations, and PNG image export) while maintaining a smooth 60 FPS response. -
Asynchronous Core (
worker.js+fractals.js): All heavy computation takes place in a dedicated background Web Worker, sending back ready-to-paint image buffers without interrupting the user experience. - Zero Dependencies: No bundlers, no heavy external packages, and no vulnerable supply chains. Code audited line by line.
📚 9 Implemented Fractal Families
The engine allows you to explore and compare different recurrences on the complex plane from a single bilingual panel (Spanish / English):
-
Mandelbrot Set: The classic quadratic recurrence:
- Julia Set: Interactive exploration by fixing the complex parameter .
- Burning Ship: Variant with absolute values that generates structures resembling burning ships.
- Tricorn (Mandelbar): Uses the complex conjugate .
- Celtic: Applies the absolute value solely to the real component.
- Buffalo: Applies the absolute value to both components.
- Multibrot and : Higher-order generalizations with multiple symmetries.
- Phoenix: Two-step recurrence with memory of the previous state ( ).
🛡 Security Note: Why I Disabled Custom Equations
In software architecture, security must always come ahead of a flashy feature.
In early versions of the engine, I allowed users to enter custom formulas via dynamic evaluation (new Function). After auditing the design, I decided to completely disable this feature.
The reason? new Function (just like eval) does not constitute a true sandbox in the browser and opens the door to code injection vectors. Until I implement a safe, isolated AST (Abstract Syntax Tree) parser that exclusively evaluates permitted mathematical operations, the engine prioritizes the integrity of the user's environment.
🚀 Run It on Your Machine in 30 Seconds
If you want to study the code or experiment locally, remember that browsers block Web Workers if you open the file directly with file://. Serve it via local HTTP:
git clone https://github.com.git
cd fractal
python3 -m http.server 8080
Then, open http://localhost:8080 in your browser. (Tip: use Ctrl + Shift + R if you make changes to the worker to clear the cache).
🤝 Contributions and Next Steps
The project is published under the AGPL-3.0 license and is open to community improvements. Upcoming lines of work include:
- Implementation of an AST-based mathematical parser to safely re-enable custom formulas.
- Arbitrary-precision emulation (Deep Zoom) to overcome the standard
Float64limit. - New dynamic color palettes inspired by astronomical spectroscopy.
If you are passionate about visual mathematics, pure JavaScript performance, or secure software design, stop by the repository, try the demo, and tell me which fractal surprised you the most.
👇 What do you think of the security approach, or which fractal algorithm would you add to the engine? I'll read you in the comments.
I hope you really enjoy the fractals repo—Julia is especially spectacular... it takes time to play around with the controls; if you go over by just a single decimal, the landscape changes radically, and you can find a truly special spot. When you find it, take pictures :) (using the built-in PNG download button!) and if you want, send them to me or share them right here in the comments. Thank you for dreaming beautifully (ensoñar bonito). Aloha and a good life. Do good and nothing else. :)
Written by **Pedro Sordo Martínez* (MagoPredator SPAIN)*
Top comments (0)