Heatmap shader preview: A word or a photo seen through a thermal camera, radiating and shimmering.
ittybitty

Heatmap

A word or a photo seen through a thermal camera, radiating and shimmering.

Code

The usage always matches the preview, layers and performance settings included. No build step or package.

Use as
Code view

Copy embed gives one block to paste into any page or site builder, no setup. For your own code: add heatmap.js, ittybitty-shader.js, runtime.js, pointer.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="heatmap" style="width: 100%; height: 480px;"></ittybitty-shader>

<!-- Or with JavaScript, for full control: -->
<canvas id="heatmap" aria-hidden="true" style="width: 100%; height: 480px; display: block"></canvas>

<script type="module">
  import { heatmap } from './heatmap.js';

  const canvas = document.getElementById('heatmap');
  const effect = heatmap(canvas, {
    showBackground: true,
    source: 'text',
    text: 'itty',
    font: '900 ui-sans-serif, system-ui, sans-serif',
    image: '/examples/still-life.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']],
    // Performance
    dpr: 1,
    adaptive: true,
  });

  // Later: effect.set(…), 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
7.7 KB brotli for heatmap.js and ittybitty-shader.js and runtime.js and pointer.js and texture.js, measured at build time. See the method.
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.