kitbash Sign in Connect agent
Components

Picture collage

Loose asymmetric grid of public domain photographs dithered on canvas, and an isometric line drawing; each dithered photo resolves into smooth tone on hover. Becomes a swipe strip on phones.

Part of the style

Wireframe Ledger

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

Preview

Code
<style>
/* Goes after the pack's base.css */
@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400..700&family=Fraunces:ital,opsz,wght@1,9..144,400..600&display=swap");
:root {
  --paper: #ffb39d;
  --ink: #1d0c08;
  --ink-mid: rgba(29, 12, 8, 0.6);
  --ink-soft: rgba(29, 12, 8, 0.45);
  --rule: rgba(29, 12, 8, 0.16);
  --rule-strong: #1d0c08;
  --mist: #eba490;
  --fog: #d79582;
  --sand: #e8a28e;
  --on-wine: #ffb39d;
  --wine: #553b34;
  --signal: #895a4a;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mark: "Fraunces", Georgia, serif;
}
</style>

<section class="collage" aria-label="Fleet record">
  <p class="collage__label"><span class="collage__tick" aria-hidden="true"></span>Fleet record, 2026</p>
  <div class="collage__grid">
    <figure class="collage__tile collage__tile--bow" data-picture="assets/ferry-bow.jpg" tabindex="0">
      <canvas class="collage__tone" aria-hidden="true"></canvas>
      <canvas class="collage__dots" role="img" aria-label="Dithered photo of a ferry bow at the quay"></canvas>
      <figcaption class="collage__caption">Hull 02, bow</figcaption>
    </figure>
    <figure class="collage__tile collage__tile--prop" data-picture="assets/propellers.jpg" tabindex="0">
      <canvas class="collage__tone" aria-hidden="true"></canvas>
      <canvas class="collage__dots" role="img" aria-label="Dithered photo of a hull and its propellers in dry dock"></canvas>
      <figcaption class="collage__caption">Drive units, dry dock</figcaption>
    </figure>
    <figure class="collage__tile collage__tile--mast" data-picture="assets/quay-crane.jpg" tabindex="0">
      <canvas class="collage__tone" aria-hidden="true"></canvas>
      <canvas class="collage__dots" role="img" aria-label="Dithered photo of a harbour crane"></canvas>
      <figcaption class="collage__caption">Quay crane</figcaption>
    </figure>
    <figure class="collage__tile collage__tile--plan">
      <svg class="collage__iso" role="img" aria-label="Isometric line drawing of a boat shed, a pier and a docked ferry"></svg>
      <figcaption class="collage__caption">Yard plan, north quay</figcaption>
    </figure>
    <figure class="collage__tile collage__tile--cells" data-picture="assets/battery-cells.jpg" tabindex="0">
      <canvas class="collage__tone" aria-hidden="true"></canvas>
      <canvas class="collage__dots" role="img" aria-label="Dithered photo of a button cell on a bench"></canvas>
      <figcaption class="collage__caption">Cell 07, test bench</figcaption>
    </figure>
  </div>
</section>

<style>
  .collage {
    padding: var(--space-l) var(--gutter) var(--section-space);
    background: var(--paper);
    color: var(--ink);
  }
  .collage__label {
    display: flex;
    align-items: center;
    margin: 0 0 var(--space-m);
    padding-top: var(--space-s);
    border-top: var(--hairline) solid var(--rule);
    font-size: var(--text-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
  }
  .collage__tick {
    width: 2.25rem;
    height: 10px;
    background:
      linear-gradient(var(--ink), var(--ink)) left / var(--hairline) 100% no-repeat,
      linear-gradient(var(--ink), var(--ink)) left center / 10px var(--hairline) no-repeat;
  }
  .collage__grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: clamp(2.25rem, 4.6vw, 4.5rem);
    gap: var(--space-s) var(--space-m);
  }
  .collage__tile {
    position: relative;
    margin: 0;
    overflow: hidden;
    --dither-paper: var(--sand);
    --dither-ink: var(--ink);
  }
  .collage__tile--bow { grid-column: 1 / 6; grid-row: 1 / 5; }
  .collage__tile--prop { grid-column: 8 / 12; grid-row: 1 / 6; --dither-paper: var(--fog); }
  .collage__tile--mast { grid-column: 4 / 7; grid-row: 5 / 9; }
  .collage__tile--plan { grid-column: 8 / 13; grid-row: 7 / 11; border: var(--hairline) solid var(--rule); background: var(--paper); }
  .collage__tile--cells { grid-column: 1 / 4; grid-row: 8 / 11; --dither-paper: var(--ink); --dither-ink: var(--fog); }

  .collage__tone,
  .collage__dots {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
  .collage__dots {
    image-rendering: pixelated;
    transition: opacity var(--mid) var(--ease-colour);
  }
  .collage__tile:hover .collage__dots,
  .collage__tile:focus-visible .collage__dots {
    opacity: 0;
  }
  .collage__iso {
    position: absolute;
    inset: 8%;
    width: 84%;
    height: 84%;
    fill: var(--paper);
    stroke: var(--ink);
    stroke-width: 0.6;
    stroke-linejoin: round;
  }
  .collage__caption {
    position: absolute;
    left: var(--space-xs);
    bottom: var(--space-xs);
    padding: 0.125rem 0.375rem;
    background: var(--paper);
    color: var(--ink);
    font-size: 0.5625rem;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    opacity: 0;
    transition: opacity var(--quick) var(--ease-colour);
  }
  .collage__tile--plan .collage__caption,
  .collage__tile:hover .collage__caption,
  .collage__tile:focus-visible .collage__caption {
    opacity: 1;
  }

  @media (max-width: 40rem) {
    .collage__grid {
      display: flex;
      gap: var(--space-s);
      margin: 0 calc(var(--gutter) * -1);
      padding: 0 var(--gutter);
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      scrollbar-width: none;
    }
    .collage__tile {
      flex: 0 0 72%;
      aspect-ratio: 4 / 5;
      scroll-snap-align: start;
    }
    .collage__caption { opacity: 1; }
  }
</style>

<script>
(() => {
  const bayer = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5].map((value) => (value + 0.5) / 16);
  const dotSize = 2;

  const contrast = 1.7;
  const pictures = new Map();

  // Photographs from open collections (public domain, credits in assets/credits.json), loaded once per tile.
  function picture(tile) {
    if (!pictures.has(tile)) {
      const image = new Image();
      image.src = tile.dataset.picture;
      pictures.set(tile, image.decode().then(() => image));
    }
    return pictures.get(tile);
  }

  function cover(g, image, w, h) {
    const scale = Math.max(w / image.naturalWidth, h / image.naturalHeight);
    const width = image.naturalWidth * scale;
    const height = image.naturalHeight * scale;
    g.drawImage(image, (w - width) / 2, (h - height) / 2, width, height);
  }

  function lightness(data, i) {
    const grey = (data[i] * 0.3 + data[i + 1] * 0.59 + data[i + 2] * 0.11) / 255;
    return Math.min(1, Math.max(0, (grey - 0.5) * contrast + 0.5));
  }

  function rgb(context, colour) {
    context.fillStyle = colour;
    const hex = context.fillStyle.replace('#', '');
    return [0, 2, 4].map((at) => parseInt(hex.slice(at, at + 2), 16));
  }

  async function draw(tile) {
    const image = await picture(tile);
    const tone = tile.querySelector('.collage__tone');
    const dots = tile.querySelector('.collage__dots');
    const width = Math.max(1, Math.round(tile.clientWidth / dotSize));
    const height = Math.max(1, Math.round(tile.clientHeight / dotSize));
    const style = getComputedStyle(tile);
    for (const canvas of [tone, dots]) { canvas.width = width; canvas.height = height; }

    const grey = tone.getContext('2d');
    cover(grey, image, width, height);
    const source = grey.getImageData(0, 0, width, height);
    const paper = rgb(grey, style.getPropertyValue('--dither-paper').trim());
    const ink = rgb(grey, style.getPropertyValue('--dither-ink').trim());
    const smooth = grey.createImageData(width, height);
    const dithered = grey.createImageData(width, height);

    for (let i = 0; i < source.data.length; i += 4) {
      const light = lightness(source.data, i);
      const pixel = i / 4;
      const threshold = bayer[(pixel % width % 4) + (Math.floor(pixel / width) % 4) * 4];
      const dot = light > threshold ? paper : ink;
      for (let channel = 0; channel < 3; channel += 1) {
        smooth.data[i + channel] = ink[channel] + (paper[channel] - ink[channel]) * light;
        dithered.data[i + channel] = dot[channel];
      }
      smooth.data[i + 3] = 255;
      dithered.data[i + 3] = 255;
    }
    grey.putImageData(smooth, 0, 0);
    dots.getContext('2d').putImageData(dithered, 0, 0);
  }

  function isoPlan(svg) {
    const s = 10;
    const cos = Math.cos(Math.PI / 6);
    const point = (x, y, z) => [(x - y) * cos * s, ((x + y) * 0.5 - z) * s];
    const boxes = [
      [0, 0, 0, 11, 6, 0.3],
      [0, 6.6, 0, 11, 1.2, 0.25],
      [6, 1, 0.3, 3, 2.5, 1.4],
      [1, 1, 0.3, 4, 3.4, 2.6],
      [9.4, 4, 0.3, 0.3, 0.3, 3.4],
      [2, 8.4, -0.3, 6, 1.8, 0.7],
      [3.4, 8.7, 0.4, 2.4, 1.2, 0.8],
    ];
    const faces = [];
    for (const [x, y, z, w, d, h] of boxes) {
      const top = z + h;
      faces.push([[x, y, top], [x + w, y, top], [x + w, y + d, top], [x, y + d, top]]);
      faces.push([[x + w, y, z], [x + w, y + d, z], [x + w, y + d, top], [x + w, y, top]]);
      faces.push([[x, y + d, z], [x + w, y + d, z], [x + w, y + d, top], [x, y + d, top]]);
    }
    const all = faces.flat().map(([x, y, z]) => point(x, y, z));
    const xs = all.map(([x]) => x); const ys = all.map(([, y]) => y);
    const pad = 4;
    svg.setAttribute('viewBox', `${Math.min(...xs) - pad} ${Math.min(...ys) - pad} ${Math.max(...xs) - Math.min(...xs) + pad * 2} ${Math.max(...ys) - Math.min(...ys) + pad * 2}`);
    svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
    const grid = [];
    for (let i = 1; i < 11; i += 1) grid.push(`M${point(i, 0, 0.3)}L${point(i, 6, 0.3)}`);
    for (let j = 1; j < 6; j += 1) grid.push(`M${point(0, j, 0.3)}L${point(11, j, 0.3)}`);
    svg.innerHTML = faces.slice(0, 3).map((face) => `<path d="M${face.map(([x, y, z]) => point(x, y, z)).join('L')}Z"/>`).join('')
      + `<path d="${grid.join('')}" stroke-opacity="0.3" fill="none"/>`
      + faces.slice(3).map((face) => `<path d="M${face.map(([x, y, z]) => point(x, y, z)).join('L')}Z"/>`).join('');
  }

  document.querySelectorAll('.collage').forEach((root) => {
    root.querySelectorAll('.collage__iso').forEach(isoPlan);
    const tiles = root.querySelectorAll('.collage__tile[data-picture]');
    const redraw = new ResizeObserver((entries) => entries.forEach((entry) => draw(entry.target)));
    tiles.forEach((tile) => redraw.observe(tile));
  });
})();
</script>

Similar components

Collage stage

Collage stage

Feed row

Feed row

Book shelf

Book shelf

Scrapbook board

Scrapbook board

Archive tiles

Archive tiles

Project windows

Project windows

Artefact scatter

Artefact scatter

Work grid with pill

Work grid with pill