Skip to content

Releases

v2.7.0

Choose a tag to compare

@github-actions github-actions released this 05 Oct 13:35

Bug fixes from a review of the effects, and a shading loop about twice as fast. Two beer defaults change, and both keep the look the effect was tuned to.

Faster frames

The shading pass every effect shares now writes one 32-bit word per pixel and blends each field row once per frame. The picture is the same to the byte. Median frame times at 1920×1080:

Effect 2.6.0 2.7.0
beer 4.35 ms 2.46 ms
mandelbrot 2.62 ms 1.25 ms
ridges 1.74 ms 0.74 ms
smoke 2.00 ms 1.22 ms
rain 0.80 ms 0.37 ms
metaballs 0.77 ms 0.31 ms
plasma 1.27 ms 0.57 ms
tunnel 2.68 ms 2.45 ms

The smoke solver and the plasma also do less work each frame, with the same output.

Fixes

  • fps: 0 painted the smoke as one flat grey. A rate of zero or less now means one frame a second in every effect, as the driver already did.
  • The Mandelbrot pauses lasted half of exploreFor. They now last the full time, so the zoom stops to look around for longer.
  • The Mandelbrot autopilot sometimes undid a decision it had made on the same frame, and gave up on a descent after scans that failed far apart rather than one after another.
  • After a window resize, smoke jets, smoke drags and rain ripples are now in the right place. Before, a jet could fire from the middle of the screen.
  • When the window narrows, beer bubbles past the new wall now go. Before, they piled up against it.
  • A fast smoke drag now drops its oldest strokes when the queue is full, so the push stays with the cursor.

Changed beer defaults

  • streaming is now 0.88, up from 0.65. The stray share of the fizz was taken twice, so 0.65 gave about an eighth of the fizz to no site. 0.88 now gives that same share.
  • spread is now 0.0011, down from 0.015. The head levelling had a cap, so any field wider than about 175 columns got only part of spread. At 1080p it got 0.0011. The levelling is now one implicit step with no cap, and spread means the same at every window size. Windows narrower than about 525 px got the full 0.015 before, so the head there is now lumpier.

If you set either option yourself, check the result. streaming now means what its documentation says, and spread now has its full effect on wide windows.

Also

  • fixedStep(fps) and wrapCell(n, size) are new exports.
  • The bundle is 23.7 kB minified and gzipped, up from 23.0 kB.

v2.6.0

Choose a tag to compare

@github-actions github-actions released this 13 Sep 09:45

A glass of beer

createBeerBackground is the eighth effect. It draws a glass of fizzing beer.

createBeerBackground(canvas, { pour: true });
  • Bubbles rise from fixed nucleation sites, grow as they rise and burst at the surface. The bubbles are metaballs, so two that pass close together join.
  • No code draws the head. Each burst adds foam, the foam drains and spreads, and the head is as thick as those two rates allow.
  • The surface is shallow water. Waves cross a full glass faster than a half-full one, and a crest driven too hard breaks into foam and spray.
  • Drag to stir it. The beer piles up against the wall and swings back. Click to splash it.
  • pour: true starts with an empty glass that fills itself.
  • A shading with a ramp colours it. The demo's amber terminal palette suits it.

Its defaults differ from the other effects: pixelSize 3, fieldScale 1 and 64 levels. Its parameters are in the beer group, with the type BeerParams. The simulation is exported and does not use the DOM, like the other effects.

Polar reverse

polar: { reverse: true } turns the polar picture inside out. The rain falls in towards the centre, and the beer pools round the centre with its head round it. A press or drag goes through the same transform.

If you build a complete polar object yourself (a Required<Polar>), add reverse. Spread POLAR_DEFAULTS and it is there. Code that passes a partial polar setting does not need a change.

Also

  • The bundle is 23.0 kB minified and gzipped, up from 17.9 kB. The beer is the difference.
  • The README, How it works, SECURITY.md and the demo text are rewritten in plain British English.
  • The development toolchain is updated. This fixes the Vitest advisory about path traversal through redirect mocks, and a brace-expansion denial-of-service advisory. Both affect development only. The published package has no runtime dependencies.

v2.5.0

Choose a tag to compare

@github-actions github-actions released this 02 Aug 15:51

Polar coordinates, on every effect

polar reads the field round a centre rather than straight across the canvas: one axis of the field becomes the angle about a point, the other the distance from it. The rain falls outwards from the middle of the page, the ridges stack into rings, the tunnel comes back round on itself.

createRainBackground(canvas, { polar: true });

createRidgesBackground(canvas, {
  polar: { turns: 3, centre: [0.5, 0], radius: 1.2 },
});

It bends the lookup rather than the field. Every effect goes on drawing its rectangle exactly as before and only the reading of it changes, which is why one option covers all seven and no effect had to learn anything.

Settings, all optional - true takes the defaults:

  • centre - the point it turns about, in fractions of the canvas. Outside 0..1 gives a fan rather than a wheel, and takes the sparkle at the middle off screen with it.
  • turns - copies of the field in one revolution. Keep it whole.
  • rotate - turns the picture clockwise.
  • radius - how far out the field reaches. 1 is exactly to the corners.
  • seam - 'mirror' folds the join away and is the default; 'wrap' keeps the field the right way round and shows it.
  • angleAxis - which axis carries the angle. 'x' sends the field's rows out as rings, 'y' its columns as spokes.

A press or drag is bent through the same transform, so an effect is still disturbed where it looks like it should be.

Two things worth knowing before turning it on. The centre is where the technique is weakest: one pixel there covers every angle at once, so the innermost cells read as a sparkle however fine the field is - move centre off the canvas to avoid it. And a polar lookup is not separable the way the plain one is, so it costs a table of two floats per rendered pixel, rebuilt on resize; about 1.3 MB at the default maxPixels. The frame itself costs what it did before.

If you use the middle layer

CommonBackgroundOptions has gained a polar field. Callers of mountBackground that hand-build a complete options object need to add it - spread COMMON_BACKGROUND_DEFAULTS and it is there. Everything that goes through createSmokeBackground and its six siblings takes a partial and is unaffected.

Also

  • The bundle claim is re-measured at 17.9 kB, up from 17.1 - the polar table's code is the difference. It is now pinned to a reproducible command rather than to history.
  • The demo has a Polar button and five dials beside the shading ones.

v2.4.0

Choose a tag to compare

@github-actions github-actions released this 31 Jul 15:35

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: 1 renders at native resolution on every effect. Raise maxPixels to suit, and note it is not cheap.
  • dither accepts 'auto' and defaults to it: on above one CSS pixel a cell, off at one. Existing true and false are unaffected.
  • levels runs to 256. Its real ceiling is amplitude, 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.

v2.3.0

Choose a tag to compare

@github-actions github-actions released this 27 Jul 13:36
Release 2.3.0

v2.2.0

Choose a tag to compare

@github-actions github-actions released this 27 Jul 00:18
Release 2.2.0