Repository navigation
v2.4.0
A seventh effect, and a long look at what it takes to make a zoom read as smooth.
Mandelbrot
createMandelbrotBackground. A zoomer that magnifies into the boundary of the set for about two minutes, turns round where double precision gives out, and pulls back to the whole set before going somewhere else.
The interesting part is not the set. It is how you draw one in five greys at 126 cells across, which escape-time colouring cannot do: the bands crowd together without limit at the boundary and alias into noise exactly where the detail is. So it shades on a distance estimate taken from the picture's own gradient. The smooth escape count is the exterior potential on a log scale, so the distance to the set is a finite difference over a field already computed.
It steers itself, because a target picked in advance is empty space twenty doublings later. It pauses to trace sideways along the boundary at one magnification, and now and then gives up a couple of doublings for a wider look.
Sixteen new exports, all DOM-free and usable on their own.
The camera, over five rounds of refinement
- The timestep is the clock rather than a fixed step. At 24fps on a 60Hz display a fixed step means equal movement shown for alternating 33ms and 50ms frames, which is judder you can see.
- The view is a critically damped spring with velocity as state, worked in screen units so the same momentum means the same thing at every magnification.
- The zoom is anchored to its target. Magnifying about the screen centre pushes an off-centre target outwards faster than the spring closes on it, so it never arrived.
- The zoom rate is damped rather than lagged, so it accelerates and decelerates instead of switching between coasting and slowing.
- Cells no longer flicker between black and bright. The interior goes through the same distance estimate as everything else, so the classification stops being a cliff.
Frame-to-frame change in apparent motion, over a full cycle at 24fps on 60Hz: 48% to 1.2%.
Options
pixelSize: 1renders at native resolution on every effect. RaisemaxPixelsto suit, and note it is not cheap.ditheraccepts'auto'and defaults to it: on above one CSS pixel a cell, off at one. Existingtrueandfalseare unaffected.levelsruns to 256. Its real ceiling isamplitude, since the palette is bytes.
One thing to watch
dither widened from boolean to boolean | 'auto'. Passing a boolean still works. Assigning COMMON_BACKGROUND_DEFAULTS.dither to a boolean no longer type-checks.
All seven together are 15.6 kB minified and gzipped.