
Dissolve
An image or element smouldering in spots or burning away behind a glowing ember edge.
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 dissolve.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="dissolve" style="width: 100%; aspect-ratio: 16 / 10;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="dissolve" aria-hidden="true" style="width: 100%; aspect-ratio: 16 / 10; display: block"></canvas>
<script type="module">
import { dissolve } from './dissolve.js';
const canvas = document.getElementById('dissolve');
const effect = dissolve(canvas, {
showBackground: true,
showPicture: true,
showEmbers: true,
image: '/examples/still-life.webp',
mode: 'smoulder',
speed: 0.5,
progress: 0.5,
responsiveness: 0.6,
pattern: 'noise',
scale: 1,
edge: 0.5,
char: 0.5,
glow: '#ff7a1a',
background: '#0c0908',
// Performance
dpr: 2,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
A ragged front eats across the picture, white-hot at its leading line and cooling to ash, scorching the picture just ahead of it and leaving nothing behind. Burn in ragged patches, sweep upward or spread from the centre; play it on a loop, hold it at a point, or let the pointer burn through.
- Payload
- 6.9 KB brotli for dissolve.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 2.
- 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.