Skip to content

Lava

A lava lamp for any box: thick 3D wax glowing in a dark liquid, shot through a long lens.

v0.1.0MITGitHubnpm
npm install @cesarvenzac/lava
Colours
Wax rising from a pool on the bulb, drawing a thick neck out of it that parts, then drifting up as the light leaves it and sinking back. Pick its colours below.

Lava fills any box with a lava lamp: thick wax glowing in a dark liquid, rising from a pool lying on the bulb and sinking back to it. It's real 3D, lit from below, shot through a long lens with a shallow focus, its light blooming, then graded as film, so it reads as a photograph of a lamp rather than a pattern.

Use

import { Lava } from "@cesarvenzac/lava/react";

<Lava palette="magenta" style={{ height: 480 }} />;

Or without React:

import { lava } from "@cesarvenzac/lava";

lava(element, { palette: "magenta" });

Playground

Colours
1
1
0.12
1
1
1
1
0
1
1
The code for what's shown
import { Lava } from "@cesarvenzac/lava/react";

<Lava style={{ height: 480 }} />;
Every option that changes how it looks, beside the code that makes what's shown.

What it does

  • Thick wax. A blob rising from the pool draws a thick neck out of it, which heaves the pool up under it, thins to a waist and parts while still thick. Its halves ooze back, one into the blob, one into the pool. Nothing bounces or rings.
  • Real 3D. Each blob is solid, stretched along its climb with a lobe trailing it, run together with another only where they touch, passing in front of and behind the others.
  • Lit from the bulb. Each point of wax is lit by what reaches it through the wax beneath: undersides glow, tops fall into shade, thin wax glows toward its hot colour, and a soft light leaves a glossy highlight.
  • A lens. Wax in front of and behind the focus blurs as a macro lens draws it, wax further back sinks into the liquid, the brightest light blooms, and the picture is graded as film.
  • Five lamps, or yours. Amber, magenta, ember, acid and violet, each a wax on a dark liquid; or any colours of your own, your page's var(--…) included.
  • Seeded. The same seed lays out the same lamp, and any moment can be drawn on its own.
  • Any box. Sizes follow the box's shorter side and the number of blobs its shape: a banner, a card and a tall column each get a lamp in proportion. Content inside is drawn over it.
  • Well behaved. It moves only on screen, holds still under reduced motion, is drawn smaller if frames come slowly, and shows the liquid lit from below until it's drawn, on a server too.
  • Small and plain. TypeScript with no dependencies, one WebGL 2 render.

Docs