
ittybitty
Liquid Metal
Molten chrome folding slowly under studio softboxes.
This browser cannot run WebGL2, so this is a still image. The code below works wherever WebGL2 is available.
Code
The usage always matches the preview, layers and performance settings included. No build step or package.
Copy embed gives one block to paste into any page or site builder, no setup. For your own code: add liquid-metal.js, ittybitty-shader.js, runtime.js, pointer.js, shape.js, texture.js next to this page. Highlighted values follow the controls.
<!-- Quickest: one element. Size it with CSS; it fills its box. -->
<script type="module" src="./ittybitty-shader.js"></script>
<ittybitty-shader effect="liquid-metal" style="width: 100%; height: 480px;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="liquid-metal" aria-hidden="true" style="width: 100%; height: 480px; display: block"></canvas>
<script type="module">
import { liquidMetal } from './liquid-metal.js';
const canvas = document.getElementById('liquid-metal');
const effect = liquidMetal(canvas, {
speed: 0.35,
scale: 1,
flow: 0.9,
contrast: 1.1,
warmth: 0.5,
form: 'fill',
vector: 'itty',
font: '',
finish: 'chrome',
interactive: true,
responsiveness: 0.5,
palette: [[0, '#10131f'], [0.5, '#6a4bff'], [1, '#ffd9f0']],
tint: '#c9ccd6',
// Performance
dpr: 1.25,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
A viscous metal surface reflecting a small, invented photo studio: a dark floor, a bright ceiling and long softboxes whose highlights roll across every fold. Tint it for gold, copper or anodised colours.
- Payload
- 7.5 KB brotli for liquid-metal.js and ittybitty-shader.js and runtime.js and pointer.js and shape.js and texture.js, measured at build time. See the method.
- Resolution
- Device pixel ratio capped at 1.25; reflections are smooth enough not to need more.
- Frame rate
- Display rate.
- When unseen
- Stops rendering when the canvas leaves the viewport or the tab is hidden, and resumes where it left off.
- Reduced motion
- Shows a single still frame. Controls still update it.
- Layers
- Up to five effects fuse into one shader and one draw call. Filters such as dithering and halftone process the layers beneath them.
- Browsers
- Any browser with WebGL2: Chrome and Edge 56+, Firefox 51+, Safari 15+.
- Licence
- MIT. Copy it, change it, ship it.