
Iridescence
Oil-slick and holographic foil colours that shift as you move.
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 iridescence.js, ittybitty-shader.js, runtime.js, container.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="iridescence" style="width: 100%; height: 480px;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="iridescence" aria-hidden="true" style="width: 100%; height: 480px; display: block"></canvas>
<script type="module">
import { iridescence } from './iridescence.js';
const canvas = document.getElementById('iridescence');
const effect = iridescence(canvas, {
speed: 0.3,
scale: 1,
thickness: 0.5,
range: 0.7,
intensity: 0.85,
style: 'oil',
interactive: true,
responsiveness: 0.5,
tilt: 0.6,
base: '#1b1d2a',
container: 'off',
outline: 'itty',
edgeLight: 0.6,
rim: 0.6,
gloss: 0.5,
innerShadow: 0.5,
// Performance
dpr: 1,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
Thin-film interference: a film of varying thickness turns light into pearlescent bands, strongest where the surface catches the light. Moving the pointer tilts the surface, so colours slide past like a card turned in the hand.
- Payload
- 8.1 KB brotli for iridescence.js and ittybitty-shader.js and runtime.js and container.js and pointer.js and shape.js and texture.js, measured at build time. See the method.
- Resolution
- Device pixel ratio capped at 1; the film 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
- Holds a still frame; moving the pointer still tilts 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.