Repository navigation
v2.6.0
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: truestarts with an empty glass that fills itself.- A
shadingwith arampcolours 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.