---
title: "Type Bands · Drew Minns"
description: "A corner of colour-blocked type you can throw around."
url: https://reallygood.work/playground/type-bands/
---

Playground · 07

# Type Bands

Two walls of colour-blocked words meeting in a corner, each band running and warping its own way.

Hover a band to lift it. Drag one to throw it.

Speed

1.00×

Warp

1.00×

Corner

1.00×

Lift

0.17

How it works

The words are drawn once, into one tall texture with a row for each band. After that a single shader draws the whole wall. For every pixel it works out which of the two walls it's on, turns that into a point on the wall, finds the band, and reads the row at that band's own offset.

Each band has its own speed, and neighbours run opposite ways. Each one warps its own way too: a wave, a swing into italic, a tall squash, a rippling baseline, a slow breath. The name only sways, so it stays readable.

Hovering lifts a band: it grows past its edges and shades the bands next to it. Drag one and let go, and it coasts back to its own pace.

```js
// two walls meeting in a corner: each is a plane turned away from us about the crease
float x = s.x - uCx, th = x < 0. ? uThL : uThR, den = uD * cos(th) - x * sin(th);
float w = x * uD / den, z = (uD + w * sin(th)) / uD;   // where on the wall, and how far away
col = front(w, (s.y - res.y * .5) * z, z, s.x / res.x);
```

Make it yourself

The whole thing in one file, with no libraries. Save it as an .html file and open it. The settings at the top follow the controls above, so tune it there, then copy.

type-bands.html

```html
<!doctype html>
<meta charset="utf-8">
<title>Type Bands</title>
<style>
  body { margin: 0; height: 100vh; overflow: hidden; background: #fff7e8; }
  .room { height: 100%; display: grid; place-items: center; perspective: 1100px; overflow: hidden; }
  .corner { display: flex; transform-style: preserve-3d; }
  .wall { display: grid; }
  .left { width: 46vw; transform-origin: right center; filter: brightness(.86); }   /* the two walls catch the light differently */
  .right { width: 58vw; transform-origin: left center; }
  .band { position: relative; height: 12vh; overflow: hidden; cursor: grab; transition: transform 160ms ease-out, box-shadow 160ms; }
  .band.up { z-index: 1; box-shadow: 0 1.4vh 2vh rgba(21, 19, 15, .35); }
  .band:active { cursor: grabbing; }
  .track { display: flex; height: 100%; width: max-content; }
  .word { display: flex; align-items: center; padding: 0 .18em; font: 800 12.4vh/1 "Arial Narrow", "Helvetica Neue", Arial, sans-serif; letter-spacing: -.03em; white-space: nowrap; user-select: none; }
</style>
<div class="room"><div class="corner"><div class="wall left"></div><div class="wall right"></div></div></div>
<script>
const settings = {
  speed: 1,   // how fast the bands run (1 = their own pace, 0 = still)
  warp: 1,     // how far each band leans into italic and back (0 = upright)
  fold: 1,     // how far the two walls turn away at the corner (0 = one flat wall)
  lift: 0.17,     // how much a band grows when you hover it, in bands
};

// one run of words per band; it repeats to fill the band
const COPY = [
  ['MAKE THINGS', 'PLAY', 'ON PURPOSE', 'LOUD'],
  ['PIXELS', 'SHADERS', 'TYPE', 'MOTION', 'GRAIN'],
  ['FEEL IT', 'SHIP IT', 'BREAK IT', 'AGAIN'],
  ['WRITING', 'EXPERIMENTS', 'PLAYGROUND'],
  ['SAY HI', 'STAY WEIRD', 'HAVE FUN', 'YES'],
  ['BEHIND GLASS', 'SOFT', 'FAST', 'TOGETHER'],
  ['SKETCH', 'CODE', 'REPEAT', 'BY HAND'],
];
// block colour and type colour: loud pairs, the way a flyer would put them
const PAIRS = [['#b4ff1f', '#ff2bd6'], ['#fff7e8', '#0044ff'], ['#ff2d2d', '#ffe600'], ['#0044ff', '#b4ff1f'], ['#ffe600', '#0044ff'],
  ['#ff2bd6', '#fff7e8'], ['#ff8a00', '#0044ff'], ['#39ff6a', '#15130f'], ['#ffe600', '#15130f']];
// band speeds in px a second: neighbours run opposite ways, and no two are alike
const BASE = [70, -22, 92, -64, 38, -84, 58];

const walls = [...document.querySelectorAll('.wall')];
let seed = 7; const rnd = () => (seed = (seed * 16807) % 2147483647) / 2147483647;

// build each band twice, once per wall. The right wall's copy starts where the left one ends, so the words turn the corner
const bands = COPY.map((words, r) => {
  const run = [];
  for (let i = 0; i < 12; i++) run.push([words[i % words.length], PAIRS[Math.floor(rnd() * PAIRS.length)]]);
  const els = walls.map(wall => {
    const band = document.createElement('div'), track = document.createElement('div');
    band.className = 'band'; track.className = 'track';
    for (let copy = 0; copy < 2; copy++) for (const [word, [bg, fg]] of run) {   // two copies, so the track can wrap with no gap
      const w = document.createElement('span'); w.className = 'word'; w.textContent = word;
      w.style.background = bg; w.style.color = fg; track.appendChild(w);
    }
    band.appendChild(track); wall.appendChild(band);
    return { band, track };
  });
  return { r, els, off: rnd() * 2000, vel: BASE[r], held: false, up: false };
});
const tile = b => b.els[0].track.scrollWidth / 2;   // the width of one copy of the run

// hover lifts a band on both walls; drag throws it, and it coasts back to its own pace
bands.forEach(b => b.els.forEach(({ band }) => {
  band.addEventListener('pointerenter', () => { b.up = true; });
  band.addEventListener('pointerleave', () => { b.up = b.held; });
  band.addEventListener('pointerdown', e => {
    band.setPointerCapture(e.pointerId); b.held = true;
    let x = e.clientX, t = performance.now(), v = 0;
    const move = e => { const now = performance.now(), dx = e.clientX - x; b.off -= dx; v = v * 0.3 + (-dx / Math.max(0.008, (now - t) / 1000)) * 0.7; x = e.clientX; t = now; };
    const up = () => { b.held = false; b.up = false; b.vel = Math.max(-6000, Math.min(6000, v)); band.removeEventListener('pointermove', move); };
    band.addEventListener('pointermove', move);
    band.addEventListener('pointerup', up, { once: true });
  });
}));

let last = performance.now();
(function frame(now) {
  const dt = Math.min(0.05, (now - last) / 1000), t = now / 1000; last = now;
  // the corner: each wall turns away from us about the crease
  walls[0].style.transform = `rotateY(${-56 * settings.fold}deg)`;
  walls[1].style.transform = `rotateY(${9 * settings.fold}deg)`;
  const leftW = walls[0].offsetWidth;
  for (const b of bands) {
    if (!b.held) {
      const pace = BASE[b.r] * settings.speed * (b.up ? 0.35 : 1);   // a lifted band slows down, so you can catch it
      b.vel += (pace - b.vel) * Math.min(1, dt * 1.4);
      b.off += b.vel * dt;
    }
    const T = tile(b), lean = Math.sin(t * 0.7 + b.r * 1.7) * 14 * settings.warp;
    b.els.forEach(({ band, track }, side) => {
      const x = ((b.off + side * leftW) % T + T) % T;   // the right wall carries on from where the left wall stops
      track.style.transform = `translateX(${-x}px) skewX(${lean}deg)`;
      band.style.transform = b.up ? `scaleY(${1 + 2 * settings.lift})` : '';
      band.classList.toggle('up', b.up);
    });
  }
  requestAnimationFrame(frame);
})(last);
</script>
```

-   [Previous piece — Isometric Diagrams](https://reallygood.work/playground/isometric-diagrams/)
-   [Next piece — Hallway](https://reallygood.work/playground/hallway/)
