---
title: "Hallway · Playground · Drew Minns"
description: "A corridor of colour frames that passes by at one fixed angle."
url: https://reallygood.work/playground/hallway/
---

Playground · 08

# Hallway

A corridor of rigid colour frames, held at one angle while the room passes by.

Live piece: A corridor of glowing colour frames moving toward the viewer; move over it to look around.

Move across it to look around, just a little.

Speed

0.38

Frame spacing

0.13

Taper

0.980

Look around

3°

Grain

0.15

How it works

Thirty frames, each a little narrower than the one in front, so they nest like a telescope. A frame’s size depends only on how far down the hall it sits, so no frame can pass through another.

The colour is Plate G’s. The soft heat map is unrolled onto the walls, so you travel through its bands. Each frame steps the colour at its seam, as Plate G’s strips do, and all of it prints through the same six noise tiles.

The view is locked. The far end stays on the left edge and the room passes by. The cursor can only turn your head three degrees in any direction, and it settles back when you leave.

```js
// the angle is a constant; the cursor only adds a small turn on top of it
const reach = Math.hypot(cx, cy), keep = reach > 1 ? 1 / reach : 1;
look.x += (cx * keep * LOOK_AROUND - look.x) * ease;
look.y += (cy * keep * LOOK_AROUND - look.y) * ease;
```

Make it yourself

The same hall on a 2D canvas, in one file with no libraries: four walls per frame drawn in perspective toward a fixed far end, with the same heat colours, grain and small look-around. Save it as an .html file and open it. The settings at the top follow the controls above.

hallway.html

```html
<!doctype html>
<meta charset="utf-8">
<title>Hallway</title>
<style>
  body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: #f4f1ea; }
  canvas { width: min(92vw, 960px); aspect-ratio: 16 / 9; border-radius: 16px; background: #030208; }
</style>
<canvas id="hall"></canvas>
<script>
const settings = {
  speed: 0.38,      // frames passed per second
  spacing: 0.13,  // how far apart the frames sit down the hall
  taper: 0.98,      // each frame is this much narrower than the one in front (1 = straight walls)
  look: 3,        // degrees the cursor can turn your head
  grain: 0.15,      // strength of the noise printed over everything
};

const RINGS = 30, PERIOD = 11;                   // frames alive at once; frames between heat bands
const NEAREST = 0.3;                             // depth of the closest frame, already past the edge of the screen
const WALL_X = 1.55, WALL_Y = 1;                 // half the hall's width and height
const VANISH = { x: -0.92, y: -0.08 };           // where the far end sits, -1 to 1 across the canvas: near the left edge
// cold and dark at the far end, up through blue and lilac to a red core
const RAMP = [[0, '#07030c'], [.12, '#101a78'], [.26, '#1c4ae4'], [.42, '#b28df2'], [.56, '#f0bcd4'], [.7, '#ffa14d'], [.86, '#ff4016'], [1, '#e3090c']].map(([t, h]) => [t, [1, 3, 5].map(i => parseInt(h.slice(i, i + 2), 16))]);
function colour(t, dim) {
  let i = 0; while (i < RAMP.length - 2 && t > RAMP[i + 1][0]) i++;
  const [t0, a] = RAMP[i], [t1, b] = RAMP[i + 1], f = Math.min(1, Math.max(0, (t - t0) / (t1 - t0)));
  return `rgb(${a.map((v, c) => Math.round((v + (b[c] - v) * f) * dim)).join(',')})`;
}
// heat peaks every PERIOD frames, so you travel through bands of colour
const heat = k => { const d = (((k / PERIOD) % 1) + 1) % 1 * PERIOD - PERIOD / 2; return Math.exp(-(d * d) / 9); };

// floor, right, ceiling, left: each wall a little lighter or darker, so the corners read
const SHADE = [0.78, 1, 0.9, 1.08], CX = [-1, 1, 1, -1], CY = [-1, -1, 1, 1];

const canvas = document.getElementById('hall'), ctx = canvas.getContext('2d');

// a small tile of noise, reshuffled now and then and laid over the whole picture
const noise = document.createElement('canvas'); noise.width = noise.height = 128;
const nctx = noise.getContext('2d');
function shuffleNoise() {
  const img = nctx.createImageData(128, 128);
  for (let i = 0; i < img.data.length; i += 4) { const v = 128 + (Math.random() + Math.random() + Math.random() - 1.5) * 120; img.data[i] = img.data[i + 1] = img.data[i + 2] = v; img.data[i + 3] = 255; }
  nctx.putImageData(img, 0, 0);
}

const look = { x: 0, y: 0 }, cursor = { x: 0, y: 0, on: false };
canvas.addEventListener('pointermove', e => { const r = canvas.getBoundingClientRect(); cursor.x = (e.clientX - r.left) / r.width * 2 - 1; cursor.y = (e.clientY - r.top) / r.height * 2 - 1; cursor.on = true; });
canvas.addEventListener('pointerleave', () => { cursor.on = false; });

let flow = 40, last = performance.now(), tick = 0;
function draw(now) {
  const dt = Math.min(0.05, (now - last) / 1000); last = now;
  flow += dt * settings.speed;

  // ease the head toward the cursor, kept inside a circle of `look` degrees; with no cursor, settle back
  const reach = Math.max(1, Math.hypot(cursor.x, cursor.y)), aim = cursor.on ? settings.look / reach : 0;
  look.x += (cursor.x * aim - look.x) * Math.min(1, dt * 5);
  look.y += (cursor.y * aim - look.y) * Math.min(1, dt * 5);

  const dpr = Math.min(2, devicePixelRatio || 1), W = canvas.width = canvas.clientWidth * dpr, H = canvas.height = canvas.clientHeight * dpr;
  const focal = H * 0.8;
  // the far end of the hall lands here; turning your head right slides it left
  const vx = W / 2 * (1 + VANISH.x) - Math.tan(look.x * Math.PI / 180) * focal;
  const vy = H / 2 * (1 - VANISH.y) + Math.tan(look.y * Math.PI / 180) * focal;
  // perspective: a point on the hall's centre line runs off to (vx, vy); everything else spreads out by 1 / depth
  const project = (x, y, z) => [vx + x * focal / z, vy - y * focal / z];

  // frame k sits `u` slots down the hall. Its depth and its size depend only on u, so no frame can pass through another
  const whole = Math.floor(flow), frac = flow - whole;
  const ring = i => { const u = i - frac; return { z: Math.max(0.02, NEAREST / Math.pow(1 - settings.spacing, u)), s: Math.pow(settings.taper, u), u }; };

  const quad = (pts, fill) => { ctx.fillStyle = fill; ctx.beginPath(); pts.forEach(([x, y], n) => (n ? ctx.lineTo(x, y) : ctx.moveTo(x, y))); ctx.closePath(); ctx.fill(); };

  // far to near, so nearer frames paint over what they hide
  for (let i = RINGS - 1; i >= 0; i--) {
    const A = ring(i), B = ring(i + 1);
    const fog = 1 - Math.min(1, Math.max(0, (A.u / RINGS - 0.35) / 0.45));
    const h = heat(whole + i), hFar = heat(whole + i + 1.35);   // the wall runs a little warmer at its far end, so colour steps at every seam
    for (let s = 0; s < 4; s++) {
      const e = (s + 1) % 4;
      const corner = (R, k, z) => project(CX[k] * WALL_X * R.s, CY[k] * WALL_Y * R.s, z);
      // the wall: this frame's size, from its own depth to the next frame's depth
      quad([corner(A, s, A.z), corner(A, e, A.z), corner(A, e, B.z), corner(A, s, B.z)], colour((h + hFar) / 2, fog * SHADE[s]));
      // the lip: a flat step at the far edge, from this frame's size in to the next one's (only shows when there's taper)
      quad([corner(A, s, B.z), corner(A, e, B.z), corner(B, e, B.z), corner(B, s, B.z)], colour(hFar, fog * SHADE[s] * 0.9));
    }
  }

  // grain, overlay-blended, reshuffled about twelve times a second
  if (tick++ % 5 === 0) shuffleNoise();
  ctx.globalCompositeOperation = 'overlay'; ctx.globalAlpha = settings.grain;
  ctx.fillStyle = ctx.createPattern(noise, 'repeat'); ctx.fillRect(0, 0, W, H);
  ctx.globalCompositeOperation = 'source-over'; ctx.globalAlpha = 1;

  requestAnimationFrame(draw);
}
requestAnimationFrame(draw);
</script>
```

-   [Previous piece — Type Bands](https://reallygood.work/playground/type-bands/)
-   [Next piece — Kaboomers](https://reallygood.work/playground/kaboomers/)
