
Slats
Light falling across long diagonal slats, fading into grain at their ends.
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 slats.js, ittybitty-shader.js, runtime.js, pointer.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="slats" style="width: 100%; aspect-ratio: 16 / 10;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="slats" aria-hidden="true" style="width: 100%; aspect-ratio: 16 / 10; display: block"></canvas>
<script type="module">
import { slats } from './slats.js';
const canvas = document.getElementById('slats');
const effect = slats(canvas, {
showBackground: true,
showSlats: true,
showEdges: true,
showGrain: true,
speed: 0.4,
zoom: 1,
angle: -50,
count: 13,
width: 0.5,
softness: 0.35,
glow: 0.25,
grain: 0.6,
interactive: true,
responsiveness: 0.5,
colour: '#d8122c',
highlight: '#ff9aa8',
shadow: '#16223e',
background: '#07080b',
// Performance
dpr: 1.5,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
A row of slats catches a soft pool of light that drifts along them. Each slat is lit along its own stretch, sliding in and out of the dark, and where the light fades it breaks into fine grain through a cool shadow tone, as a launcher homepage made famous. The unlit slats keep a hairline edge, and the pointer carries the light. One pass, no textures.
- Payload
- 6.4 KB brotli for slats.js and ittybitty-shader.js and runtime.js and pointer.js, measured at build time. See the method.
- Resolution
- Device pixel ratio capped at 1.5.
- 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.