
Ship something
people remember.
A button that wakes up when you reach for it.
Heatmap
A word or a photo seen through a thermal camera, radiating and shimmering.
This browser cannot run WebGL2, so this is a still image. The code below works wherever WebGL2 is available.
Code
For your own build, add heatmap.js, layers.js, container.js, runtime.js, ittybitty-shader.js, pointer.js and texture.js next to this page. Highlighted values follow the controls.
<!-- Quickest: one element. Size it with CSS; it fills its box, in its shape. -->
<script type="module" src="./ittybitty-shader.js"></script>
<ittybitty-shader effect="heatmap" shape="text" shape-text="itty" style="width: 100%; height: 220px;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="heatmap" aria-hidden="true" style="display: block; width: 100%; height: 220px"></canvas>
<script type="module">
import { layers } from './layers.js';
import { spec as heatmap } from './heatmap.js';
const canvas = document.getElementById('heatmap');
const effect = layers(canvas, [
{ effect: heatmap, options: {
showBackground: true,
source: 'image',
image: '/examples/heatmap.webp',
amount: 1,
speed: 0.6,
spread: 0.6,
turbulence: 0.5,
contrast: 1.1,
style: 'thermal',
interactive: true,
responsiveness: 0.5,
palette: [[0, '#07051a'], [0.25, '#3a0ca3'], [0.5, '#d62f6b'], [0.75, '#ff9f1c'], [1, '#fff4c2']],
} },
], {
dpr: 1, adaptive: true,
// The whole stack fills this shape.
shape: { kind: 'text', text: 'itty' },
});
// Later: effect.set(…), effect.shape(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
Heat comes from a word, or from a picture, where brightness is heat. It is read at a few levels of blur, which mipmaps provide for free, so it radiates and rises; a shimmer runs through it like hot air, and the result maps through a thermal palette. From a picture it can sit over the photo as an overlay, and as a layer it heats everything beneath it.
- Payload
- 14.4 KB brotli for heatmap.js, layers.js, container.js, runtime.js, ittybitty-shader.js, pointer.js and texture.js, measured at build time.
- Resolution
- Device pixel ratio capped at 1; heat is soft.
- 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.
- Source
- heatmap.js on GitHub, in a public repo that logs every change.