Film reel
The signature one-screen reel: a counting timecode, Client and Deliverables titles that roll and blur inside one-line windows, an index, a crossfading paragraph with a View project link, next and prev, and a column of drawn, graded film loops that slides to centre the current one. Clips, arrows, the wheel over the clips and swipes change film.
Part of the style
Heat Reel
6 parts that belong together, with their tokens, type and rules.
https://kitbash.me/components/heat-reel/reel/figma.html?palette=aff735f39fb71a31
Use the Figma MCP server (https://mcp.figma.com/mcp). Download https://kitbash.me/components/heat-reel/reel/figma.html?palette=aff735f39fb71a31 and pass that whole HTML document to the html_to_figma tool, so the part "Film reel" lands as editable layers in my open Figma file. Fonts come from Google Fonts: if a face is missing in Figma, pick the closest one.
Code
<style>
/* Goes after the pack's base.css */
:root {
--ink: #fff2f0;
--ink-soft: #b28568;
--paper: #834a20;
--night: #332321;
--night-ink: #c3855b;
--night-soft: #b08366;
--film: #fffffe;
--clay-deep: #f5d9d6;
--bone: #925d39;
--ember: #8c5f0e;
--clay: #8a6939;
--ember-hot: #945d12;
--glaze: #d4a68b;
--sage: #8c5f0e;
--lagoon: #e2a664;
}
</style>
<section class="reel" aria-label="Selected films" aria-roledescription="carousel" tabindex="0">
<div class="reel__copy">
<p class="reel__time" aria-live="off"><span class="reel__now">00:00</span> / <span class="reel__total">01:42</span></p>
<div class="reel__titles">
<p class="reel__label">Client</p>
<div class="reel__window reel__window--client"><div class="reel__track" data-reel="client"></div></div>
<p class="reel__label reel__label--second">Deliverables</p>
<div class="reel__window reel__window--work"><div class="reel__track" data-reel="work"></div></div>
</div>
<p class="reel__index" aria-live="polite"><span class="reel__count">01</span> / <span class="reel__of">06</span></p>
<div class="reel__stack reel__stack--about" data-stack="about"></div>
<div class="reel__steps">
<span class="reel__step-label">Next</span>
<div class="reel__stack reel__stack--next" data-stack="next"></div>
<span class="reel__step-label reel__step-label--prev">Prev</span>
<div class="reel__stack reel__stack--prev" data-stack="prev"></div>
</div>
</div>
<div class="reel__column">
<div class="reel__clips"></div>
</div>
</section>
<style>
.reel {
--reel-col: calc((100cqw - 2 * var(--edge) - 11 * var(--gutter)) / 12);
--reel-step: 56px;
container-type: inline-size;
--reel-h: calc(var(--text-title) * var(--leading-title));
--reel-small-h: calc(var(--text) * 1.3);
position: relative;
height: var(--stage);
overflow: hidden;
background: var(--paper);
color: var(--ink);
outline: none;
opacity: 0;
animation: reel-fade-in var(--time-fade) var(--ease-glide) var(--time-fade) forwards;
}
@keyframes reel-fade-in { to { opacity: 1; } }
.reel:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }
.reel p { margin: 0; }
.reel__copy {
position: absolute;
inset: 0 auto 0 var(--edge);
width: calc(var(--reel-col) * 8 + var(--gutter) * 7);
}
.reel__time {
position: absolute;
top: 36.67%;
left: 0;
width: calc(var(--reel-col) * 4 + var(--gutter) * 3);
color: var(--ink-soft);
text-align: center;
font-variant-numeric: tabular-nums;
}
/* Two title reels set as a staircase: each label sits where the line above starts. */
.reel__titles {
position: absolute;
top: calc(50% - var(--reel-h) - 4px);
left: 0;
right: 0;
display: grid;
grid-template-columns: max-content max-content minmax(0, 1fr);
column-gap: var(--space-s);
row-gap: 8px;
align-items: start;
}
.reel__label {
padding-top: 0.12em;
color: var(--ink-soft);
line-height: 1;
}
.reel__label--second { grid-column: 2; }
.reel__window {
height: var(--reel-h);
overflow: hidden;
}
.reel__window--client { grid-column: 2 / -1; }
.reel__window--work { grid-column: 3; }
.reel__track {
display: flex;
flex-direction: column;
transform: translate3d(0, calc(var(--reel-h) * var(--offset, 0) * -1), 0);
transition: transform var(--time-track) var(--ease-glide);
backface-visibility: hidden;
}
.reel__item {
flex: none;
height: var(--reel-h);
display: flex;
align-items: center;
margin: 0;
font-size: var(--text-title);
line-height: var(--leading-title);
letter-spacing: var(--tracking-title);
white-space: nowrap;
opacity: 0;
filter: blur(2px);
transition: opacity var(--time-fade) var(--ease-snap), filter var(--time-fade) var(--ease-snap);
}
.reel__item.is-active { opacity: 1; filter: blur(0); }
.reel.is-static .reel__track,
.reel.is-static .reel__item,
.reel.is-static .reel__clips { transition: none; }
.reel__index {
position: absolute;
top: calc(50% - 0.65em);
right: 0;
color: var(--ink-soft);
font-variant-numeric: tabular-nums;
}
/* Crossfading stacks: every panel shares one cell, only the active one is visible. */
.reel__stack { display: grid; }
.reel__panel {
grid-area: 1 / 1;
opacity: 0;
visibility: hidden;
pointer-events: none;
transition: opacity var(--time-swap) var(--ease-glide), visibility 0s linear var(--time-swap);
}
.reel__panel.is-active {
opacity: 1;
visibility: visible;
pointer-events: auto;
transition: opacity var(--time-swap) var(--ease-glide), visibility 0s linear 0s;
}
.reel__stack--about {
position: absolute;
top: 61.33%;
left: var(--reel-step);
width: clamp(240px, 24cqw, 346px);
align-items: start;
}
.reel__about { color: var(--ink-soft); text-wrap: pretty; }
.reel__link,
.reel__jump {
display: inline-flex;
align-items: center;
padding: 0;
border: 0;
background: none;
color: var(--ink);
font: inherit;
font-stretch: inherit;
text-transform: inherit;
text-decoration: none;
cursor: pointer;
transition: color var(--time-hover) var(--ease-glide);
}
.reel__link {
min-height: var(--tap);
margin-top: calc(var(--space-m) - (var(--tap) - 1lh) / 2);
margin-bottom: calc((var(--tap) - 1lh) / -2);
}
@media (hover: hover) {
.reel__link:hover,
.reel__jump:hover { color: var(--ink-soft); }
}
.reel__link:focus-visible,
.reel__jump:focus-visible {
text-decoration: underline;
text-decoration-thickness: 2px;
text-underline-offset: 3px;
outline: none;
}
.reel__clip:focus-visible {
outline: 2px solid var(--ink);
outline-offset: 2px;
}
.reel__steps {
position: absolute;
left: 0;
bottom: var(--edge);
display: grid;
grid-template-columns: max-content max-content max-content;
column-gap: 4px;
line-height: var(--leading);
}
.reel__step-label { color: var(--ink-soft); }
.reel__step-label--prev { grid-column: 2; }
.reel__stack--next { grid-column: 2 / -1; }
.reel__stack--prev { grid-column: 3; }
/* Footage column: drawn clips stacked down the right third, the active one centred on the titles. */
.reel__column {
position: absolute;
inset: 0 var(--edge) 0 auto;
width: calc(var(--reel-col) * 4 + var(--gutter) * 3);
overflow: hidden;
}
.reel__clips {
display: flex;
flex-direction: column;
gap: var(--gutter);
transform: translate3d(0, var(--shift, 0px), 0);
transition: transform var(--time-track) var(--ease-glide);
will-change: transform;
}
.reel__clip {
position: relative;
display: block;
flex: none;
width: 100%;
padding: 0;
border: 0;
background: var(--film);
cursor: pointer;
}
.reel__clip canvas { width: 100%; height: 100%; }
.reel__veil {
position: absolute;
inset: 0;
background: var(--ink-soft);
pointer-events: none;
transition: opacity var(--time-hover) var(--ease-glide) var(--time-swap);
}
.reel__clip.is-loaded .reel__veil { opacity: 0; }
/* Phones and narrow tablets: one column, the clips become a sideways strip under the titles. */
@media (max-width: 54.6rem) {
.reel {
--reel-h: calc(var(--text-title) * 0.92);
--reel-indent: 54px;
height: auto;
display: flex;
flex-direction: column;
padding: var(--space-l) 0 var(--edge);
}
.reel__copy { display: contents; }
.reel__time,
.reel__titles,
.reel__index,
.reel__stack--about,
.reel__steps,
.reel__column {
position: static;
width: auto;
inset: auto;
}
.reel__time { order: 1; text-align: center; }
.reel__titles { order: 2; margin: var(--space-l) var(--edge) 0; }
.reel__window--work {
height: var(--reel-small-h);
--reel-h: var(--reel-small-h);
}
.reel__window--work .reel__item {
font-size: var(--text);
letter-spacing: 0;
}
.reel__column { order: 3; margin: var(--space-l) 0 0; overflow: hidden; clip-path: inset(0 0 0 var(--reel-indent)); }
.reel__clips {
flex-direction: row;
align-items: center;
padding-left: var(--reel-indent);
transform: translate3d(var(--shift, 0px), 0, 0);
}
.reel__clip { width: calc(100vw - 2 * var(--reel-indent)); }
.reel__stack--about { order: 4; margin: var(--space-l) var(--reel-indent) 0; max-width: 34ch; }
.reel__steps { order: 5; margin: var(--space-l) var(--edge) 0; row-gap: 0; }
.reel__jump { min-height: var(--tap); }
.reel__step-label { align-self: center; }
.reel__index { order: 6; margin-top: var(--space-m); text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
.reel { animation: none; opacity: 1; }
.reel__item { filter: none; }
}
</style>
<script>
(() => {
const FILMS = [
{ client: 'Ostra Ceramics', work: 'Direction + Film + Sound', seconds: 102, ratio: 16 / 9, scene: 'wheel',
about: 'A slow film for a three-person pottery on the salt marsh, cut to the turn of the wheel and fired in one long take.' },
{ client: 'Vell Foundry', work: 'Creative + Production + Post', seconds: 130, ratio: 2, scene: 'pour',
about: 'Pour-day footage for a bell foundry, shot at a hundred and twenty frames over one night of casting.' },
{ client: 'Pale Glassworks', work: 'Film + Stills', seconds: 48, ratio: 4 / 3, scene: 'glass',
about: 'Short loops of the gather, the blow and the slow cool, made for the studio shop and its winter catalogue.' },
{ client: 'Brisa Tileworks', work: 'Strategy + Campaign + Edit', seconds: 65, ratio: 16 / 9, scene: 'tiles',
about: 'An overhead series for a tile maker, one glaze to a film, built to sit quietly behind every product page.' },
{ client: 'Marrow Forge', work: 'Production + Post', seconds: 380, ratio: 2.1, scene: 'forge',
about: 'A short documentary on a smith who still makes every hinge and latch for the old town by hand.' },
{ client: 'Low Tide Bakehouse', work: 'Creative + Production + Post', seconds: 36, ratio: 3 / 2, scene: 'oven',
about: 'Morning films from a wood-fired bakery, made to open the shop site before the first loaf is out.' },
];
const COPIES = 3;
const FPS = 24;
const still = matchMedia('(prefers-reduced-motion: reduce)');
const narrow = matchMedia('(max-width: 54.6rem)');
const pad = (n) => String(n).padStart(2, '0');
const clock = (s) => `${pad(Math.floor(s / 60))}:${pad(Math.floor(s % 60))}`;
const hash = (n) => { const x = Math.sin(n * 127.1 + 311.7) * 43758.5453; return x - Math.floor(x); };
/* ---------- drawn footage: every clip is a small graded film loop ---------- */
function makeGrain() {
const tile = document.createElement('canvas');
tile.width = tile.height = 128;
const g = tile.getContext('2d');
const img = g.createImageData(128, 128);
for (let i = 0; i < img.data.length; i += 4) {
const v = Math.random() * 255;
img.data[i] = img.data[i + 1] = img.data[i + 2] = v;
img.data[i + 3] = 255;
}
g.putImageData(img, 0, 0);
return tile;
}
const GRAIN = makeGrain();
function glow(c, x, y, r, stops) {
const g = c.createRadialGradient(x, y, 0, x, y, r);
stops.forEach(([at, color]) => g.addColorStop(at, color));
c.fillStyle = g;
c.fillRect(x - r, y - r, r * 2, r * 2);
}
function finish(c, w, h, t, warmth) {
c.globalCompositeOperation = 'source-over';
const v = c.createRadialGradient(w / 2, h / 2, Math.min(w, h) * 0.25, w / 2, h / 2, Math.hypot(w, h) * 0.62);
v.addColorStop(0, 'rgba(0,0,0,0)');
v.addColorStop(1, 'rgba(0,0,0,0.55)');
c.fillStyle = v;
c.fillRect(0, 0, w, h);
c.globalCompositeOperation = 'soft-light';
c.fillStyle = warmth;
c.fillRect(0, 0, w, h);
c.save();
c.globalCompositeOperation = 'overlay';
c.globalAlpha = 0.13;
const frame = Math.floor(t * FPS);
c.translate(-hash(frame) * 128, -hash(frame + 9) * 128);
c.fillStyle = c.createPattern(GRAIN, 'repeat');
c.fillRect(0, 0, w + 128, h + 128);
c.restore();
}
const SCENES = {
wheel(c, w, h, t) {
const bg = c.createRadialGradient(w * 0.5, h * 0.55, 0, w * 0.5, h * 0.55, w * 0.7);
bg.addColorStop(0, '#5a463a'); bg.addColorStop(1, '#1b1410');
c.fillStyle = bg; c.fillRect(0, 0, w, h);
const cx = w * 0.52, cy = h * 0.56, R = h * 0.78, spin = t * 2.2;
const head = c.createRadialGradient(cx - R * 0.2, cy - R * 0.3, R * 0.1, cx, cy, R);
head.addColorStop(0, '#6c5647'); head.addColorStop(1, '#2e231d');
c.fillStyle = head; c.beginPath(); c.arc(cx, cy, R, 0, Math.PI * 2); c.fill();
for (let k = 0; k < 46; k++) {
const r = R * (0.32 + hash(k) * 0.66), a = hash(k + 50) * 6.283 + spin * (1 - r / R * 0.15);
c.strokeStyle = `rgba(214,180,150,${0.05 + hash(k + 90) * 0.12})`;
c.lineWidth = 0.6 + hash(k + 7) * 2.2;
c.beginPath(); c.arc(cx, cy, r, a, a + 0.25 + hash(k + 3) * 1.1); c.stroke();
}
const wob = Math.sin(spin) * h * 0.004, px = cx + wob, py = cy + Math.cos(spin) * h * 0.003;
const outer = h * 0.3, inner = h * 0.205;
const body = c.createRadialGradient(px - outer * 0.4, py - outer * 0.5, outer * 0.1, px, py, outer);
body.addColorStop(0, '#d98a60'); body.addColorStop(0.7, '#b8603e'); body.addColorStop(1, '#6f3520');
c.fillStyle = body; c.beginPath(); c.arc(px, py, outer, 0, Math.PI * 2); c.fill();
const well = c.createRadialGradient(px + inner * 0.25, py + inner * 0.3, inner * 0.1, px, py, inner);
well.addColorStop(0, '#2a1710'); well.addColorStop(0.75, '#4b2616'); well.addColorStop(1, '#8d4a2c');
c.fillStyle = well; c.beginPath(); c.arc(px, py, inner, 0, Math.PI * 2); c.fill();
for (let k = 0; k < 7; k++) {
c.strokeStyle = `rgba(255,214,180,${0.07 + (k % 2) * 0.05})`; c.lineWidth = 1;
c.beginPath(); c.arc(px, py, inner + (outer - inner) * (k + 0.5) / 7, 0, Math.PI * 2); c.stroke();
}
c.strokeStyle = 'rgba(255,236,214,0.55)'; c.lineWidth = h * 0.012; c.lineCap = 'round';
c.beginPath(); c.arc(px, py, outer * 0.93, 3.6, 4.5); c.stroke();
c.lineWidth = h * 0.006; c.beginPath(); c.arc(px, py, inner * 1.04, 0.5, 1.3); c.stroke();
glow(c, w * 0.95, -h * 0.1, w * 0.6, [[0, 'rgba(255,190,130,0.22)'], [1, 'rgba(255,190,130,0)']]);
finish(c, w, h, t, 'rgba(255,170,110,0.25)');
},
pour(c, w, h, t) {
c.fillStyle = '#0d0b0a'; c.fillRect(0, 0, w, h);
glow(c, w * 0.52, h * 0.9, w * 0.55, [[0, 'rgba(255,110,30,0.35)'], [1, 'rgba(255,110,30,0)']]);
c.fillStyle = '#1a1411';
c.beginPath(); c.moveTo(w * 0.1, -h * 0.05); c.lineTo(w * 0.36, h * 0.08); c.lineTo(w * 0.33, h * 0.2); c.lineTo(w * 0.05, h * 0.12); c.fill();
c.strokeStyle = 'rgba(255,140,60,0.5)'; c.lineWidth = 2;
c.beginPath(); c.moveTo(w * 0.36, h * 0.08); c.lineTo(w * 0.33, h * 0.2); c.stroke();
c.globalCompositeOperation = 'lighter';
const sway = Math.sin(t * 3.1) * w * 0.006;
const stream = (width, color) => {
c.strokeStyle = color; c.lineWidth = width; c.lineCap = 'round';
c.beginPath(); c.moveTo(w * 0.345, h * 0.15);
c.bezierCurveTo(w * 0.4, h * 0.2, w * 0.5 + sway, h * 0.4, w * 0.505 + sway, h * 0.8); c.stroke();
};
stream(h * 0.075, 'rgba(255,90,20,0.22)');
stream(h * 0.04, 'rgba(255,140,50,0.6)');
stream(h * 0.016, 'rgba(255,230,170,0.95)');
glow(c, w * 0.505, h * 0.82, h * 0.32, [[0, 'rgba(255,240,200,0.95)'], [0.3, 'rgba(255,140,40,0.6)'], [1, 'rgba(255,80,20,0)']]);
for (let i = 0; i < 80; i++) {
const life = 0.6 + hash(i) * 0.9, p = ((t / life) + hash(i + 40)) % 1;
const vx = (hash(i + 80) - 0.5) * w * 0.9, vy = -(0.4 + hash(i + 120)) * h * 1.3;
const x = w * 0.505 + vx * p, y = h * 0.8 + vy * p + h * 1.6 * p * p;
const dx = vx * 0.03, dy = (vy + h * 3.2 * p) * 0.03;
c.strokeStyle = `rgba(255,${190 + hash(i + 3) * 60},120,${(1 - p) * 0.9})`;
c.lineWidth = 1 + hash(i + 5) * 1.2;
c.beginPath(); c.moveTo(x, y); c.lineTo(x - dx, y - dy); c.stroke();
}
c.globalCompositeOperation = 'source-over';
c.fillStyle = '#120d0b';
c.beginPath(); c.ellipse(w * 0.505, h * 0.98, w * 0.3, h * 0.12, 0, 0, Math.PI * 2); c.fill();
c.strokeStyle = 'rgba(255,150,70,0.6)'; c.lineWidth = 1.5;
c.beginPath(); c.ellipse(w * 0.505, h * 0.98, w * 0.3, h * 0.12, 0, Math.PI * 1.08, Math.PI * 1.92); c.stroke();
for (let k = 0; k < 3; k++) {
const p = ((t * 0.08) + k / 3) % 1;
glow(c, w * (0.4 + k * 0.12), h * (0.7 - p * 0.9), h * (0.3 + p * 0.3), [[0, `rgba(140,120,110,${0.08 * (1 - p)})`], [1, 'rgba(140,120,110,0)']]);
}
finish(c, w, h, t, 'rgba(255,120,40,0.18)');
},
glass(c, w, h, t) {
const bg = c.createLinearGradient(0, 0, w, h);
bg.addColorStop(0, '#0c2427'); bg.addColorStop(1, '#1d4a4b');
c.fillStyle = bg; c.fillRect(0, 0, w, h);
for (let i = 0; i < 16; i++) {
const x = (hash(i) * 1.2 - 0.1) * w + Math.sin(t * 0.3 + i) * w * 0.02;
const y = (hash(i + 20) * 1.1 - 0.05) * h - ((t * 6 * (0.5 + hash(i + 4))) % (h * 1.2)) + h * 0.1;
const r = h * (0.04 + hash(i + 30) * 0.1);
c.fillStyle = `rgba(160,214,207,${0.04 + hash(i + 60) * 0.08})`;
c.beginPath(); c.arc(x, (y + h * 1.2) % (h * 1.2) - h * 0.1, r, 0, Math.PI * 2); c.fill();
}
const ox = w * 0.6, oy = h * 0.48, breathe = 1 + Math.sin(t * 1.6) * 0.035;
c.strokeStyle = '#07141a'; c.lineWidth = h * 0.045; c.lineCap = 'round';
c.beginPath(); c.moveTo(-w * 0.05, h * 0.92); c.lineTo(ox - h * 0.12, oy + h * 0.06); c.stroke();
c.strokeStyle = 'rgba(190,230,226,0.45)'; c.lineWidth = h * 0.008;
c.beginPath(); c.moveTo(-w * 0.05, h * 0.9); c.lineTo(ox - h * 0.13, oy + h * 0.04); c.stroke();
c.globalCompositeOperation = 'lighter';
glow(c, ox, oy, h * 0.55 * breathe, [[0, 'rgba(255,150,60,0.4)'], [1, 'rgba(255,120,40,0)']]);
c.save(); c.translate(ox, oy); c.rotate(Math.sin(t * 0.7) * 0.15); c.scale(1.12 * breathe, 0.94 / breathe);
const orb = c.createRadialGradient(-h * 0.04, -h * 0.05, 0, 0, 0, h * 0.19);
orb.addColorStop(0, 'rgba(255,248,224,1)'); orb.addColorStop(0.35, 'rgba(255,207,122,0.95)');
orb.addColorStop(0.8, 'rgba(255,120,40,0.75)'); orb.addColorStop(1, 'rgba(200,60,20,0)');
c.fillStyle = orb; c.beginPath(); c.arc(0, 0, h * 0.19, 0, Math.PI * 2); c.fill();
c.restore();
c.globalCompositeOperation = 'source-over';
c.strokeStyle = 'rgba(255,255,255,0.5)'; c.lineWidth = h * 0.01; c.lineCap = 'round';
c.beginPath(); c.arc(ox, oy, h * 0.15 * breathe, 3.7, 4.3); c.stroke();
finish(c, w, h, t, 'rgba(120,200,190,0.16)');
},
tiles(c, w, h, t) {
const glazes = ['#24408e', '#e9dfc8', '#8aa08a', '#c99a3e', '#e9dfc8', '#e9dfc8'];
c.fillStyle = '#d6cfbf'; c.fillRect(0, 0, w, h);
const s = h / 2.6, gap = Math.max(2, h * 0.012), ox = -((t * h * 0.05) % s), oy = -((t * h * 0.025) % s);
const base = Math.floor(t * h * 0.05 / s), baseY = Math.floor(t * h * 0.025 / s);
for (let gy = -1; gy < h / s + 2; gy++) {
for (let gx = -1; gx < w / s + 2; gx++) {
const id = (gx + base) * 31 + (gy + baseY) * 17;
const color = glazes[Math.floor(hash(id) * glazes.length)];
const x = ox + gx * s + gap / 2, y = oy + gy * s + gap / 2, size = s - gap;
c.fillStyle = color; c.fillRect(x, y, size, size);
const sheen = c.createLinearGradient(x, y, x + size, y + size);
sheen.addColorStop(0, 'rgba(255,255,255,0.22)'); sheen.addColorStop(0.5, 'rgba(255,255,255,0)'); sheen.addColorStop(1, 'rgba(0,0,0,0.12)');
c.fillStyle = sheen; c.fillRect(x, y, size, size);
const motif = hash(id + 3);
if (color === '#e9dfc8' && motif < 0.55) {
c.fillStyle = motif < 0.3 ? '#24408e' : '#b8603e';
const corner = Math.floor(hash(id + 7) * 4), cxp = x + (corner % 2) * size, cyp = y + Math.floor(corner / 2) * size;
c.save(); c.beginPath(); c.rect(x, y, size, size); c.clip();
c.beginPath(); c.arc(cxp, cyp, size * 0.62, 0, Math.PI * 2); c.fill();
c.fillStyle = '#e9dfc8'; c.beginPath(); c.arc(cxp, cyp, size * 0.38, 0, Math.PI * 2); c.fill();
c.restore();
}
}
}
const sweep = ((t * 0.09) % 1.8 - 0.4) * w;
const band = c.createLinearGradient(sweep - w * 0.3, 0, sweep + w * 0.3, h * 0.3);
band.addColorStop(0, 'rgba(255,250,235,0)'); band.addColorStop(0.5, 'rgba(255,250,235,0.28)'); band.addColorStop(1, 'rgba(255,250,235,0)');
c.fillStyle = band; c.fillRect(0, 0, w, h);
finish(c, w, h, t, 'rgba(255,220,170,0.2)');
},
forge(c, w, h, t) {
c.fillStyle = '#0b0908'; c.fillRect(0, 0, w, h);
const beat = (t % 2.2) / 2.2, flash = Math.exp(-beat * 9);
const heat = 0.85 + Math.sin(t * 2.3) * 0.08 + flash * 0.2;
glow(c, w * 0.66, h * 0.5, w * 0.6, [[0, `rgba(255,90,20,${0.28 * heat})`], [1, 'rgba(255,90,20,0)']]);
c.fillStyle = '#16110e';
c.beginPath(); c.moveTo(w * 0.32, h * 0.62); c.lineTo(w * 0.98, h * 0.62); c.lineTo(w * 0.86, h * 0.76); c.lineTo(w * 0.78, h * 0.76);
c.lineTo(w * 0.78, h * 1.05); c.lineTo(w * 0.5, h * 1.05); c.lineTo(w * 0.5, h * 0.76); c.lineTo(w * 0.42, h * 0.76); c.closePath(); c.fill();
c.strokeStyle = `rgba(255,140,60,${0.55 * heat})`; c.lineWidth = 1.5;
c.beginPath(); c.moveTo(w * 0.32, h * 0.62); c.lineTo(w * 0.98, h * 0.62); c.stroke();
const y = h * 0.555, thick = h * 0.07;
const bar = c.createLinearGradient(0, 0, w * 0.74, 0);
bar.addColorStop(0, '#2a0904'); bar.addColorStop(0.45, '#9e2512'); bar.addColorStop(0.8, '#ff7a1a'); bar.addColorStop(1, '#ffe3a3');
c.fillStyle = bar; c.globalAlpha = Math.min(1, heat);
c.beginPath(); c.roundRect(-w * 0.02, y - thick / 2, w * 0.76, thick, thick / 2); c.fill();
c.globalAlpha = 1;
c.strokeStyle = '#050403'; c.lineWidth = h * 0.03; c.lineCap = 'round';
c.beginPath(); c.moveTo(-w * 0.02, y - thick * 0.9); c.lineTo(w * 0.2, y - thick * 0.45); c.stroke();
c.beginPath(); c.moveTo(-w * 0.02, y + thick * 0.9); c.lineTo(w * 0.2, y + thick * 0.45); c.stroke();
c.globalCompositeOperation = 'lighter';
glow(c, w * 0.7, y, h * (0.25 + flash * 0.5), [[0, `rgba(255,240,200,${0.5 + flash * 0.5})`], [0.4, `rgba(255,140,40,${0.25 + flash * 0.4})`], [1, 'rgba(255,90,20,0)']]);
if (beat < 0.5) {
for (let i = 0; i < 46; i++) {
const a = hash(i + Math.floor(t / 2.2) * 7) * Math.PI * 2, speed = (0.3 + hash(i + 11) * 0.9) * w;
const p = beat * 2, x = w * 0.7 + Math.cos(a) * speed * p * 0.5, yy = y + Math.sin(a) * speed * p * 0.35 + h * 0.6 * p * p;
c.strokeStyle = `rgba(255,${200 + hash(i) * 55},140,${(1 - p) * 0.95})`; c.lineWidth = 1.2;
c.beginPath(); c.moveTo(x, yy); c.lineTo(x - Math.cos(a) * 6, yy - Math.sin(a) * 4); c.stroke();
}
}
c.globalCompositeOperation = 'source-over';
finish(c, w, h, t, 'rgba(255,110,40,0.2)');
},
oven(c, w, h, t) {
c.fillStyle = '#24160f'; c.fillRect(0, 0, w, h);
const rows = 9, bh = h / rows;
for (let r = 0; r < rows; r++) {
for (let k = -1; k < w / (bh * 2.2) + 1; k++) {
const x = k * bh * 2.2 + (r % 2) * bh * 1.1, shade = 22 + hash(r * 40 + k) * 16;
c.fillStyle = `rgb(${shade + 22},${shade},${shade - 6})`;
c.fillRect(x + 1.5, r * bh + 1.5, bh * 2.2 - 3, bh - 3);
}
}
const flick = 0.82 + Math.sin(t * 7.3) * 0.06 + Math.sin(t * 13.1) * 0.05 + Math.sin(t * 2.1) * 0.07;
const ax = w * 0.5, base = h * 0.92, aw = w * 0.31, ah = h * 0.62;
c.save();
c.beginPath(); c.moveTo(ax - aw, base); c.lineTo(ax - aw, base - ah * 0.45);
c.ellipse(ax, base - ah * 0.45, aw, ah * 0.55, 0, Math.PI, 0); c.lineTo(ax + aw, base); c.closePath();
c.fillStyle = '#120a06'; c.fill();
c.clip();
const fire = c.createRadialGradient(ax + aw * 0.35, base - ah * 0.3, 0, ax + aw * 0.1, base - ah * 0.3, aw * 1.05);
fire.addColorStop(0, `rgba(255,226,160,${flick})`); fire.addColorStop(0.28, `rgba(246,128,38,${flick * 0.9})`);
fire.addColorStop(0.62, `rgba(140,40,10,${0.85 + flick * 0.1})`); fire.addColorStop(1, 'rgba(26,8,3,1)');
c.fillStyle = fire; c.fillRect(ax - aw, base - ah * 1.1, aw * 2, ah * 1.1);
c.globalCompositeOperation = 'lighter';
for (let i = 0; i < 9; i++) {
const p = ((t * (0.35 + hash(i) * 0.3)) + hash(i + 9)) % 1;
const fx = ax + aw * (0.1 + hash(i + 3) * 0.7), fy = base - ah * (0.35 + p * 0.6);
glow(c, fx, fy, aw * (0.18 + hash(i + 5) * 0.12) * (1 - p * 0.5), [[0, `rgba(255,170,70,${0.4 * (1 - p)})`], [1, 'rgba(255,120,40,0)']]);
}
c.globalCompositeOperation = 'source-over';
for (let i = 0; i < 4; i++) {
const lx = ax - aw * 0.66 + i * aw * 0.42, ly = base - ah * 0.08, lw = aw * 0.17, lh = ah * 0.16;
c.fillStyle = '#4a2a14'; c.beginPath(); c.ellipse(lx, ly, lw, lh, 0, Math.PI, 0); c.fill();
c.strokeStyle = `rgba(255,196,120,${0.75 * flick})`; c.lineWidth = h * 0.012;
c.beginPath(); c.ellipse(lx, ly, lw * 0.96, lh * 0.94, 0, Math.PI * 1.15, Math.PI * 1.75); c.stroke();
c.strokeStyle = 'rgba(30,14,6,0.6)'; c.lineWidth = h * 0.006;
c.beginPath(); c.moveTo(lx - lw * 0.4, ly - lh * 0.55); c.lineTo(lx + lw * 0.2, ly - lh * 0.75); c.stroke();
}
c.restore();
c.fillStyle = '#0d0805'; c.fillRect(0, base, w, h - base);
glow(c, ax, base, aw * 1.4, [[0, `rgba(255,140,60,${0.25 * flick})`], [1, 'rgba(255,140,60,0)']]);
finish(c, w, h, t, 'rgba(255,160,90,0.22)');
},
};
/* ---------- the reel ---------- */
function buildTrack(track, key) {
for (let copy = 0; copy < COPIES; copy++) {
for (const film of FILMS) {
const item = document.createElement('p');
item.className = 'reel__item';
item.textContent = film[key];
if (copy !== 1) item.setAttribute('aria-hidden', 'true');
track.append(item);
}
}
}
function buildStacks(root) {
const about = root.querySelector('[data-stack="about"]');
const next = root.querySelector('[data-stack="next"]');
const prev = root.querySelector('[data-stack="prev"]');
FILMS.forEach((film, i) => {
const panel = document.createElement('div');
panel.className = 'reel__panel';
panel.innerHTML = `<p class="reel__about"></p><a class="reel__link" href="#">View project</a>`;
panel.querySelector('.reel__about').textContent = film.about;
about.append(panel);
for (const [stack, step] of [[next, 1], [prev, -1]]) {
const target = (i + step + FILMS.length) % FILMS.length;
const jump = document.createElement('div');
jump.className = 'reel__panel';
jump.innerHTML = `<button class="reel__jump" type="button"></button>`;
jump.firstChild.textContent = FILMS[target].client;
jump.firstChild.dataset.step = step;
stack.append(jump);
}
});
}
function buildClips(root) {
const holder = root.querySelector('.reel__clips');
const clips = [];
for (let copy = 0; copy < COPIES; copy++) {
FILMS.forEach((film, i) => {
const clip = document.createElement('button');
clip.type = 'button';
clip.className = 'reel__clip';
clip.style.aspectRatio = film.ratio;
clip.setAttribute('aria-label', `${film.client}, film`);
if (copy !== 1) clip.tabIndex = -1;
clip.innerHTML = '<canvas aria-hidden="true"></canvas><span class="reel__veil"></span>';
clip.dataset.film = i;
clip.dataset.slot = copy * FILMS.length + i;
holder.append(clip);
clips.push(clip);
});
}
return clips;
}
function setUp(root) {
const n = FILMS.length;
const tracks = [...root.querySelectorAll('.reel__track')];
tracks.forEach((track) => buildTrack(track, track.dataset.reel === 'client' ? 'client' : 'work'));
buildStacks(root);
const clips = buildClips(root);
const column = root.querySelector('.reel__column');
const holder = root.querySelector('.reel__clips');
const now = root.querySelector('.reel__now');
const total = root.querySelector('.reel__total');
const count = root.querySelector('.reel__count');
root.querySelector('.reel__of').textContent = pad(n);
let slot = n; // position in the tripled list; the middle copy is the real one
let playedFrom = performance.now();
let locked = false;
const film = () => ((slot % n) + n) % n;
const label = root.querySelector('.reel__label');
const measureStep = () => root.style.setProperty('--reel-step', `${label.offsetWidth + parseFloat(getComputedStyle(label.parentElement).columnGap)}px`);
measureStep();
document.fonts.ready.then(measureStep);
function centreClips() {
const clip = clips[slot];
if (narrow.matches) {
holder.style.setProperty('--shift', `${-clip.offsetLeft + parseFloat(getComputedStyle(holder).paddingLeft)}px`);
} else {
holder.style.setProperty('--shift', `${column.clientHeight / 2 - clip.offsetTop - clip.offsetHeight / 2}px`);
}
}
function render() {
const i = film();
for (const track of tracks) {
track.style.setProperty('--offset', slot);
[...track.children].forEach((item, k) => item.classList.toggle('is-active', k === slot));
}
for (const stack of root.querySelectorAll('.reel__stack')) {
[...stack.children].forEach((panel, k) => {
panel.classList.toggle('is-active', k === i);
panel.inert = k !== i;
});
}
count.textContent = pad(i + 1);
total.textContent = clock(FILMS[i].seconds);
centreClips();
}
function settle() {
if (slot >= n && slot < 2 * n) return;
root.classList.add('is-static');
slot = film() + n;
render();
root.offsetHeight;
root.classList.remove('is-static');
}
function go(step) {
if (locked || step === 0) return;
locked = true;
slot += step;
playedFrom = performance.now();
now.textContent = '00:00';
render();
setTimeout(() => { settle(); locked = false; }, still.matches ? 30 : 640);
}
root.addEventListener('click', (event) => {
const jump = event.target.closest('.reel__jump');
if (jump) { go(Number(jump.dataset.step)); return; }
const clip = event.target.closest('.reel__clip');
if (clip) {
const target = Number(clip.dataset.slot);
if (target !== slot) go(target - slot);
}
if (event.target.closest('.reel__link')) event.preventDefault();
});
root.addEventListener('keydown', (event) => {
const keys = { ArrowDown: 1, ArrowRight: 1, ArrowUp: -1, ArrowLeft: -1 };
if (!(event.key in keys)) return;
event.preventDefault();
go(keys[event.key]);
});
let wheel = 0;
column.addEventListener('wheel', (event) => {
event.preventDefault();
wheel += Math.abs(event.deltaY) > Math.abs(event.deltaX) ? event.deltaY : event.deltaX;
if (Math.abs(wheel) < 40) return;
go(Math.sign(wheel));
wheel = 0;
}, { passive: false });
let touchX = null;
column.addEventListener('touchstart', (event) => { touchX = event.touches[0].clientX; }, { passive: true });
column.addEventListener('touchend', (event) => {
if (touchX === null) return;
const dx = event.changedTouches[0].clientX - touchX;
if (Math.abs(dx) > 40) go(dx < 0 ? 1 : -1);
touchX = null;
});
new ResizeObserver(() => { root.classList.add('is-static'); centreClips(); root.offsetHeight; root.classList.remove('is-static'); }).observe(column);
narrow.addEventListener('change', render);
root.classList.add('is-static');
render();
root.offsetHeight;
root.classList.remove('is-static');
/* footage: paint only clips on screen, at film cadence */
const visible = new Set();
const watch = new IntersectionObserver((entries) => {
for (const entry of entries) entry.isIntersecting ? visible.add(entry.target) : visible.delete(entry.target);
}, { root: column });
const sizes = new Map();
function fit(canvas) {
const density = Math.min(2, devicePixelRatio || 1);
const w = canvas.clientWidth, h = canvas.clientHeight;
canvas.width = Math.round(w * density);
canvas.height = Math.round(h * density);
sizes.set(canvas, { w, h, density });
}
function paint(clip, seconds) {
const canvas = clip.firstChild;
if (!sizes.has(canvas)) fit(canvas);
const { w, h, density } = sizes.get(canvas);
const c = canvas.getContext('2d');
c.setTransform(density, 0, 0, density, 0, 0);
c.save();
const frame = Math.floor(seconds * FPS);
c.translate((hash(frame) - 0.5) * 0.6, (hash(frame + 3) - 0.5) * 0.6);
SCENES[FILMS[clip.dataset.film].scene](c, w, h, seconds + Number(clip.dataset.film) * 7);
c.restore();
}
const resize = new ResizeObserver((entries) => {
for (const entry of entries) { fit(entry.target); paint(entry.target.parentElement, performance.now() / 1000); }
});
clips.forEach((clip, k) => {
watch.observe(clip);
resize.observe(clip.firstChild);
const order = Math.abs(k - slot);
setTimeout(() => clip.classList.add('is-loaded'), still.matches ? 0 : 520 + Math.min(order, 4) * 130);
});
let frame = 0, last = 0, running = false;
function tick(ms) {
frame = requestAnimationFrame(tick);
if (ms - last < 1000 / FPS) return;
last = ms;
for (const clip of visible) paint(clip, ms / 1000);
const played = (ms - playedFrom) / 1000;
now.textContent = clock(played % FILMS[film()].seconds);
}
function start() { if (!running && !still.matches) { running = true; frame = requestAnimationFrame(tick); } }
function stop() { running = false; cancelAnimationFrame(frame); }
new IntersectionObserver(([entry]) => {
if (entry.isIntersecting) { start(); requestAnimationFrame(() => visible.forEach((clip) => paint(clip, performance.now() / 1000))); }
else stop();
}).observe(root);
requestAnimationFrame(() => visible.forEach((clip) => paint(clip, 4)));
}
document.querySelectorAll('.reel').forEach(setUp);
})();
</script>