
Ship something
people remember.
A button that wakes up when you reach for it.
Holo Card
Any image as a holographic trading card that tilts towards the pointer, its foil flashing in the light.
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 holo-card.js, ittybitty-shader.js, runtime.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. -->
<script type="module" src="./ittybitty-shader.js"></script>
<ittybitty-shader effect="holo-card" style="width: 100%; aspect-ratio: 16 / 10;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="holo-card" aria-hidden="true" style="width: 100%; aspect-ratio: 16 / 10; display: block"></canvas>
<script type="module">
import { holoCard } from './holo-card.js';
const canvas = document.getElementById('holo-card');
const effect = holoCard(canvas, {
showBackground: true,
showBorder: true,
showShadow: true,
image: '/examples/still-life.webp',
foil: 'rainbow',
reverse: false,
strength: 0.8,
glare: 0.6,
tilt: 20,
scale: 1,
etch: 0.4,
hue: 0,
size: 0.8,
radius: 0.3,
border: 0.35,
borderColour: '#f1cf55',
background: '#0e0f14',
speed: 1,
interactive: true,
responsiveness: 0.5,
// Performance
dpr: 2,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
The picture becomes a trading card, drawn in perspective with a soft shadow, that tilts as if pressed where the pointer is. A foil layer catches the light: its colours come from the angle between the light, the card and the eye, so they slide past as the card turns, and it shows most in the mid-tones, as printed foil does. Choose diagonal rainbow, a starfield, glitter, sun pillars, a diamond crosshatch, cracked ice or etched gold, on the picture or, reverse holo, on the frame. With no pointer it sways gently.
- Payload
- 12.3 KB brotli for holo-card.js, ittybitty-shader.js, runtime.js, pointer.js and texture.js, measured at build time.
- Resolution
- Device pixel ratio capped at 2, so glitter and fine foil stay crisp.
- 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. The card still tilts with the pointer.
- 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.