kitbash Sign in Connect agent
Components

Tunnel heading

The signature: a canvas tunnel whose four walls are painted with rough condensed words in perspective, the back opening drifting on a 6s loop, with a flat extended word underneath. Beside it a pink band scrolls the wordmark and a black box holds a label, a narrow headline and short text.

Part of the style

Backroom Tunnel

6 parts that belong together, with their tokens, type and rules.

Preview

Code
<style>
/* Goes after the pack's base.css */
:root {
  --metal: #2b4bbc;
  --backstage: #f0f5ff;
  --spot: #203cac;
  --neon: #295be1;
  --echo: #c6233b;
}
</style>

<section class="hero" aria-label="Inkrun, the trades of the small press">
  <div class="hero__tunnel">
    <canvas class="hero__canvas" role="img" aria-label="Roll the ink, backroom press: words painted on the four walls of a tunnel that drifts, with PRESS set flat underneath"></canvas>
  </div>

  <div class="hero__side">
    <a class="hero__marquee" href="#" aria-label="Inkrun, home">
      <span class="hero__track">
        <span class="hero__mark">
          <svg class="hero__glyph" viewBox="0 0 24 24" aria-hidden="true">
            <rect x="2" y="4" width="15" height="7" rx="3.5"></rect>
            <path d="M17 7.5h3.2v5.8H11v3.2"></path>
            <rect x="9" y="16" width="4" height="6.5" rx="1.4"></rect>
          </svg>
          <span class="hero__word">Inkrun.org</span>
        </span>
        <span class="hero__mark" aria-hidden="true">
          <svg class="hero__glyph" viewBox="0 0 24 24" aria-hidden="true">
            <rect x="2" y="4" width="15" height="7" rx="3.5"></rect>
            <path d="M17 7.5h3.2v5.8H11v3.2"></path>
            <rect x="9" y="16" width="4" height="6.5" rx="1.4"></rect>
          </svg>
          <span class="hero__word">Inkrun.org</span>
        </span>
        <span class="hero__mark" aria-hidden="true">
          <svg class="hero__glyph" viewBox="0 0 24 24" aria-hidden="true">
            <rect x="2" y="4" width="15" height="7" rx="3.5"></rect>
            <path d="M17 7.5h3.2v5.8H11v3.2"></path>
            <rect x="9" y="16" width="4" height="6.5" rx="1.4"></rect>
          </svg>
          <span class="hero__word">Inkrun.org</span>
        </span>
        <span class="hero__mark" aria-hidden="true">
          <svg class="hero__glyph" viewBox="0 0 24 24" aria-hidden="true">
            <rect x="2" y="4" width="15" height="7" rx="3.5"></rect>
            <path d="M17 7.5h3.2v5.8H11v3.2"></path>
            <rect x="9" y="16" width="4" height="6.5" rx="1.4"></rect>
          </svg>
          <span class="hero__word">Inkrun.org</span>
        </span>
      </span>
    </a>

    <div class="hero__box">
      <h2 class="hero__label">What is it?</h2>
      <div class="hero__main">
        <h1 class="hero__heading">The trades and night classes that keep the small presses running.</h1>
        <div class="hero__text">
          <p>Behind every zine on a café shelf there is a backroom with a drum that needs cleaning, a guillotine that needs a steady hand and somebody who knows which paper drinks ink. Those rooms are hiring, and they would rather teach you than wait.</p>
          <p>Riso shops, screen benches, binderies, distro tables. Small rooms, real people, work you can hold. Pick a trade, try a night class, and leave with a print that has your name in the corner.</p>
          <p>A programme of the North Shore Small Press Guild, with help from the people who still own the machines.</p>
        </div>
      </div>
    </div>
  </div>
</section>

<style>
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--edge);
    padding: var(--edge);
    background: var(--metal);
    opacity: 0;
    transition: opacity var(--time) var(--ease);
  }
  .hero.is-ready { opacity: 1; }
  @media (min-width: 768px) {
    .hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

  .hero__tunnel { aspect-ratio: 1; }
  .hero__canvas {
    width: 100%;
    height: 100%;
    color: var(--backstage);
  }

  .hero__side {
    display: flex;
    flex-direction: column;
    gap: var(--edge);
    min-width: 0;
  }

  .hero__marquee {
    display: block;
    overflow: hidden;
    padding: 8px 0;
    border-radius: 8px;
    background: var(--neon);
    color: var(--backstage);
    text-decoration: none;
  }
  @media (min-width: 1024px) {
    .hero__marquee { padding: 16px 0; border-radius: var(--radius-main); }
  }
  .hero__marquee:focus-visible { outline: 3px solid var(--backstage); outline-offset: 3px; }
  .hero__track {
    display: flex;
    width: max-content;
    animation: hero-roll var(--hero-roll, 14.6s) linear infinite;
  }
  .hero.is-offscreen .hero__track { animation-play-state: paused; }
  .hero__mark {
    display: flex;
    flex: none;
    align-items: center;
    gap: 0.04em;
    padding-right: 0.32em;
    font: 800 clamp(44px, 5.83vw, 84px)/0.9 var(--font-poster);
    letter-spacing: -0.025em;
    text-transform: uppercase;
    white-space: nowrap;
  }
  .hero__glyph {
    width: 0.62em;
    height: 0.62em;
    fill: currentColor;
  }
  .hero__glyph path { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; }
  .hero__word { translate: 0 0.04em; }
  @keyframes hero-roll { to { transform: translateX(-50%); } }

  .hero__box {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: var(--space-4);
    border-radius: var(--radius-main);
    background: var(--backstage);
    color: var(--metal);
  }
  .hero__label {
    margin: 0 0 var(--space-8);
    font: 400 var(--t-c1)/1.1 var(--font-label);
    font-stretch: calc(var(--label-width) * 1%);
    text-transform: uppercase;
  }
  .hero__main { margin-top: auto; }
  .hero__heading {
    margin: 0 0 24px;
    font: 400 var(--t-h2)/0.94 var(--font-label);
    font-stretch: calc(var(--label-width) * 1%);
    letter-spacing: -0.014em;
    text-transform: uppercase;
    text-wrap: balance;
  }
  .hero__text {
    max-width: 400px;
    font: 400 var(--t-text)/1.2 var(--font-body);
  }
  .hero__text p { margin: 0 0 1.2em; }
  .hero__text p:last-child { margin-bottom: 0; }

  @media (prefers-reduced-motion: reduce) {
    .hero { opacity: 1; transition: none; }
    .hero__track { animation: none; }
  }
</style>

<script>
(() => {
  const still = matchMedia('(prefers-reduced-motion: reduce)');
  const LOOP = 6;
  const DEPTH = 3.2;
  const SLICES = 150;
  const ROLL_SPEED = 52;

  function seeded(seed) {
    let state = seed >>> 0;
    return () => {
      state = (state + 0x6d2b79f5) >>> 0;
      let t = Math.imul(state ^ (state >>> 15), 1 | state);
      t ^= t + Math.imul(t ^ (t >>> 7), 61 | t);
      return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
    };
  }

  function noiseField(width, height, cell, random) {
    const columns = Math.ceil(width / cell) + 2;
    const rows = Math.ceil(height / cell) + 2;
    const values = new Float32Array(columns * rows).map(() => random() * 2 - 1);
    return (x, y) => {
      const gx = x / cell;
      const gy = y / cell;
      const ix = gx | 0;
      const iy = gy | 0;
      const fx = gx - ix;
      const fy = gy - iy;
      const at = (cx, cy) => values[cy * columns + cx];
      const top = at(ix, iy) * (1 - fx) + at(ix + 1, iy) * fx;
      const bottom = at(ix, iy + 1) * (1 - fx) + at(ix + 1, iy + 1) * fx;
      return top * (1 - fy) + bottom * fy;
    };
  }

  function roughen(context, width, height, seed) {
    const random = seeded(seed);
    const fineX = noiseField(width, height, 2.5, random);
    const fineY = noiseField(width, height, 2.5, random);
    const broadX = noiseField(width, height, 26, random);
    const broadY = noiseField(width, height, 26, random);
    const source = context.getImageData(0, 0, width, height);
    const result = context.createImageData(width, height);
    const from = source.data;
    const to = result.data;
    for (let y = 0; y < height; y++) {
      for (let x = 0; x < width; x++) {
        const sx = Math.min(width - 1, Math.max(0, Math.round(x + fineX(x, y) * 1.4 + broadX(x, y) * 4.5)));
        const sy = Math.min(height - 1, Math.max(0, Math.round(y + fineY(x, y) * 1.4 + broadY(x, y) * 4.5)));
        const index = (y * width + x) * 4;
        to[index + 3] = Math.min(255, Math.max(0, (from[(sy * width + sx) * 4 + 3] - 96) * 4));
      }
    }
    context.putImageData(result, 0, 0);
  }

  function lettering(text, width, height, font, ink, seed) {
    const canvas = document.createElement('canvas');
    canvas.width = width;
    canvas.height = height;
    const context = canvas.getContext('2d');
    context.font = font;
    if ('fontStretch' in context && font.includes('Archivo')) context.fontStretch = 'expanded';
    const letters = [...text];
    const sizes = letters.map((letter) => context.measureText(letter));
    const gap = context.measureText('M').width * 0.06;
    const advance = sizes.reduce((sum, size) => sum + size.width, 0) + gap * (letters.length - 1);
    const ascent = Math.max(...sizes.map((size) => size.actualBoundingBoxAscent));
    const padX = width * 0.02;
    const padY = height * 0.035;
    const scaleX = (width - padX * 2) / advance;
    const scaleY = (height - padY * 2) / ascent;
    context.fillStyle = ink;
    context.setTransform(scaleX, 0, 0, scaleY, padX, height - padY);
    let x = 0;
    letters.forEach((letter, index) => {
      context.fillText(letter, x, 0);
      x += sizes[index].width + gap;
    });
    context.setTransform(1, 0, 0, 1, 0, 0);
    roughen(context, width, height, seed);
    return canvas;
  }

  function perspective(depth) {
    const z = 1 + depth * (DEPTH - 1);
    return (1 - 1 / z) / (1 - 1 / DEPTH);
  }
  const lerp = (a, b, t) => a + (b - a) * t;

  function backRoom(width, height, seconds) {
    const turn = ((seconds % LOOP) / LOOP) * Math.PI * 2;
    const roomWidth = width * (0.24 + 0.02 * Math.sin(turn * 2));
    const roomHeight = height * (0.26 + 0.02 * Math.sin(turn * 2 + 0.8));
    const centreX = width * (0.5 + 0.14 * Math.sin(turn));
    const centreY = height * (0.4 + 0.09 * Math.sin(turn * 2 + 1.1));
    return {
      left: centreX - roomWidth / 2,
      right: centreX + roomWidth / 2,
      top: centreY - roomHeight / 2,
      bottom: centreY + roomHeight / 2,
    };
  }

  function paintRows(context, texture, outerY, backY, outerLeft, outerRight, back, lettersFaceOut) {
    const tw = texture.width;
    const th = texture.height;
    for (let i = 0; i < SLICES; i++) {
      const d0 = i / SLICES;
      const d1 = (i + 1) / SLICES;
      const s0 = perspective(d0);
      const s1 = perspective(d1);
      const sMid = (s0 + s1) / 2;
      const y0 = lerp(outerY, backY, s0);
      const y1 = lerp(outerY, backY, s1);
      const left = lerp(outerLeft, back.left, sMid);
      const right = lerp(outerRight, back.right, sMid);
      const sourceY = lettersFaceOut ? d0 * th : (1 - d1) * th;
      const top = Math.min(y0, y1);
      context.drawImage(texture, 0, sourceY, tw, (d1 - d0) * th, left, top - 0.35, right - left, Math.abs(y1 - y0) + 0.7);
    }
  }

  function paintColumns(context, texture, outerX, backX, outerTop, outerBottom, back, readsInward) {
    const tw = texture.width;
    const th = texture.height;
    for (let i = 0; i < SLICES; i++) {
      const d0 = i / SLICES;
      const d1 = (i + 1) / SLICES;
      const s0 = perspective(d0);
      const s1 = perspective(d1);
      const sMid = (s0 + s1) / 2;
      const x0 = lerp(outerX, backX, s0);
      const x1 = lerp(outerX, backX, s1);
      const top = lerp(outerTop, back.top, sMid);
      const bottom = lerp(outerBottom, back.bottom, sMid);
      const sourceX = readsInward ? d0 * tw : (1 - d1) * tw;
      const left = Math.min(x0, x1);
      context.drawImage(texture, sourceX, 0, (d1 - d0) * tw, th, left - 0.35, top, Math.abs(x1 - x0) + 0.7, bottom - top);
    }
  }

  function paint(context, walls, width, height, seconds) {
    context.clearRect(0, 0, width, height);
    if (!walls) return;
    const tunnelHeight = height * 0.845;
    const back = backRoom(width, tunnelHeight, seconds);
    paintRows(context, walls.ceiling, 0, back.top, 0, width, back, true);
    paintRows(context, walls.floor, tunnelHeight, back.bottom, 0, width, back, false);
    paintColumns(context, walls.left, 0, back.left, 0, tunnelHeight, back, true);
    paintColumns(context, walls.right, width, back.right, 0, tunnelHeight, back, false);
    const baseTop = height * 0.87;
    context.drawImage(walls.base, 0, baseTop, width, height - baseTop);
  }

  function buildWalls(ink) {
    const poster = '900 200px "Big Shoulders Display"';
    return {
      ceiling: lettering('ROLL', 1000, 700, poster, ink, 11),
      left: lettering('THE', 1400, 640, poster, ink, 23),
      right: lettering('INK', 1400, 640, poster, ink, 37),
      floor: lettering('BACKROOM', 1300, 900, poster, ink, 41),
      base: lettering('PRESS', 1400, 220, '900 200px Archivo', ink, 53),
    };
  }

  function runTunnel(root) {
    const canvas = root.querySelector('.hero__canvas');
    const context = canvas.getContext('2d');
    let walls = null;
    let frame = 0;
    let visible = false;
    let started = performance.now();

    const draw = (now) => paint(context, walls, canvas.clientWidth, canvas.clientHeight, (now - started) / 1000);
    const fit = () => {
      const density = Math.min(2, devicePixelRatio || 1);
      canvas.width = Math.round(canvas.clientWidth * density);
      canvas.height = Math.round(canvas.clientHeight * density);
      context.setTransform(density, 0, 0, density, 0, 0);
      context.imageSmoothingQuality = 'high';
      draw(performance.now());
    };
    const tick = (now) => {
      draw(now);
      frame = requestAnimationFrame(tick);
    };
    const play = () => {
      cancelAnimationFrame(frame);
      if (visible && walls && !still.matches) frame = requestAnimationFrame(tick);
    };

    Promise.all([
      document.fonts.load('900 200px "Big Shoulders Display"'),
      document.fonts.load('900 200px Archivo'),
    ]).catch(() => null).then(() => {
      walls = buildWalls(getComputedStyle(canvas).color);
      started = performance.now() - 1200;
      fit();
      play();
    });

    new ResizeObserver(fit).observe(canvas);
    new IntersectionObserver(([entry]) => {
      visible = entry.isIntersecting;
      root.classList.toggle('is-offscreen', !visible);
      play();
    }).observe(root);
    still.addEventListener('change', play);
  }

  function runMarquee(root) {
    const track = root.querySelector('.hero__track');
    const measure = () => {
      const distance = track.scrollWidth / 2;
      root.style.setProperty('--hero-roll', `${(distance / ROLL_SPEED).toFixed(3)}s`);
    };
    new ResizeObserver(measure).observe(track);
    document.fonts.ready.then(measure);
  }

  function reveal(root) {
    requestAnimationFrame(() => requestAnimationFrame(() => root.classList.add('is-ready')));
  }

  document.querySelectorAll('.hero').forEach((root) => {
    runTunnel(root);
    runMarquee(root);
    reveal(root);
  });
})();
</script>

Similar components

Film reel

Film reel

Sticker headline hero

Sticker headline hero

Scanline lettering

Scanline lettering

Cut-out hero

Cut-out hero

Floating field hero

Floating field hero

Spring headline

Spring headline

Selection frame hero

Selection frame hero

Framed hero

Framed hero