diff --git a/examples/mandelbrot/README.md b/examples/mandelbrot/README.md new file mode 100644 index 000000000..09297dd4d --- /dev/null +++ b/examples/mandelbrot/README.md @@ -0,0 +1,34 @@ +# Mandelbrot Set Renderer + +A single-file, dependency-free HTML/JavaScript renderer for everyone's +favorite infinitely-zoomable blob of math: the Mandelbrot set. + +![Mandelbrot set screenshot](./screenshot.png) + +## Usage + +Open `index.html` in a browser. That's it - no `npm install`, no build +step, no bundler to configure. Just double-click the file and go stare +into the fractal abyss. + +## Controls + +- **Click** to zoom in, **Shift+Click** to zoom back out +- **Drag** to lasso a region and zoom into it +- **Scroll** to zoom in/out under the cursor +- **Reset View** when you get lost (you will get lost) +- **Cycle Palette** to switch up the vibe (classic / fire / grayscale) + +Iteration count quietly ramps up the deeper you zoom, so the edges stay +crisp instead of turning into a blurry mess. + +## How it works + +Every pixel becomes a point `c` on the complex plane. Starting from +`z = 0`, we repeatedly compute `z = z^2 + c` and count how many +iterations it survives before `|z|` blows past 2 and "escapes." Points +that never escape belong to the set and get colored black; everything +else gets shaded by how fast it fled. A couple of early-out checks +(the main cardioid and period-2 bulb formulas) let us skip the math +entirely for points we already know are staying put, which is the +closest thing this renderer has to a shortcut. diff --git a/examples/mandelbrot/index.html b/examples/mandelbrot/index.html new file mode 100644 index 000000000..01c921347 --- /dev/null +++ b/examples/mandelbrot/index.html @@ -0,0 +1,258 @@ + + + + +Mandelbrot Set Renderer + + + + +
+ +
+ Mandelbrot Set
+ Click to zoom in · Shift+Click to zoom out
+ Drag to select a zoom region
+ + +
iterations: 0
+
+
+ + + + diff --git a/examples/mandelbrot/screenshot.png b/examples/mandelbrot/screenshot.png new file mode 100644 index 000000000..c1e8815fc Binary files /dev/null and b/examples/mandelbrot/screenshot.png differ