Swoosh shader preview: Satin ribbons of light sweeping through the dark, finished with film grain.
ittybitty

Swoosh

Satin ribbons of light sweeping through the dark, finished with film grain.

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 swoosh.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="swoosh" style="width: 100%; height: 100svh;"></ittybitty-shader>

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

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

  const canvas = document.getElementById('swoosh');
  const effect = swoosh(canvas, {
    showBackground: true,
    speed: 0.25,
    zoom: 1,
    ribbons: 3,
    width: 0.075,
    flow: 1,
    twist: 1,
    glow: 0.5,
    grain: 0.5,
    angle: -18,
    interactive: true,
    responsiveness: 0.5,
    color: '#ff3d00',
    highlight: '#ffb27a',
    background: '#0c0908',
    container: 'off',
    outline: 'itty',
    edgeLight: 0.6,
    rim: 0.6,
    gloss: 0.5,
    innerShadow: 0.5,
    // Performance
    dpr: 1.5,
    adaptive: true,
  });

  // Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>

Details

Ribbons swing across the canvas and twist as they go, narrowing to a bright edge and opening out again. A hot highlight rides the curve of each one, a soft glow spills onto the dark, and a fixed film grain gives the whole thing texture. It is the background of the ittybitty homepage.

Payload
8.6 KB brotli for swoosh.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.5. The homepage runs it at 1, at 30 fps.
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.