Skip to content
TypeScript
11.2 KB
Raw Blame
/**
 * Banner concept explorer (design spike). Generates 6 self-contained SVG banner
 * concepts in a spatial / universe / dot-pixel aesthetic for theseus, plus a
 * contact-sheet.html. Run: `node scripts/design-banners.mjs`. Pure (seeded RNG),
 * no deps. Outputs to assets/concepts/.
 */
import { mkdirSync, writeFileSync } from "node:fs";
import { join } from "node:path";

const OUT = "assets/concepts";
const W = 1200;
const H = 340;

// cosmic theseus palette
const C = {
  void: "#050a14",
  navy: "#0b2942",
  hull: "#15324f",
  foam: "#7fb2c9",
  rope: "#c08a3e",
  sail: "#f5f1e6",
  dim: "#33506e",
};

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

const bg = (extra = "") => `
  <defs>
    <radialGradient id="neb" cx="38%" cy="42%" r="75%">
      <stop offset="0" stop-color="${C.navy}"/>
      <stop offset="0.55" stop-color="#071d30"/>
      <stop offset="1" stop-color="${C.void}"/>
    </radialGradient>
    ${extra}
  </defs>
  <rect width="${W}" height="${H}" rx="20" fill="url(#neb)"/>`;

function starfield(seed, n, { maxR = 1.7, area = [0, 0, W, H] } = {}) {
  const r = rng(seed);
  const [x0, y0, x1, y1] = area;
  let s = "";
  for (let i = 0; i < n; i++) {
    const x = (x0 + r() * (x1 - x0)).toFixed(1);
    const y = (y0 + r() * (y1 - y0)).toFixed(1);
    const rad = (0.5 + r() * maxR).toFixed(2);
    const op = (0.25 + r() * 0.6).toFixed(2);
    const col = r() < 0.18 ? C.rope : r() < 0.5 ? C.foam : C.sail;
    s += `<circle cx="${x}" cy="${y}" r="${rad}" fill="${col}" opacity="${op}"/>`;
  }
  return s;
}

const wordmark = (x, y, size = 92, sub = true) => `
  <text x="${x}" y="${y}" font-family="ui-monospace,'SF Mono',Menlo,monospace" font-size="${size}" font-weight="800" fill="${C.sail}" letter-spacing="2">theseus</text>
  <rect x="${x + 4}" y="${y + 14}" width="${size * 3.6}" height="5" rx="2.5" fill="${C.rope}"/>
  ${sub ? `<text x="${x + 6}" y="${y + 48}" font-family="ui-sans-serif,system-ui,sans-serif" font-size="20" fill="${C.foam}">compare model × agent × harness — and judge the trade-offs</text>` : ""}`;

const svg = (inner) =>
  `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}" viewBox="0 0 ${W} ${H}" role="img" aria-label="theseus">${inner}</svg>\n`;

// ── C1 · constellation ship ──────────────────────────────
function c1() {
  // ship as a constellation of nodes joined by faint lines
  const P = {
    bowTop: [120, 150], stern: [330, 150], keel: [225, 210],
    mast: [225, 60], sailA: [225, 70], sailB: [225, 150], sailC: [310, 140],
  };
  const node = (p, r = 4) =>
    `<circle cx="${p[0]}" cy="${p[1]}" r="${r}" fill="${C.sail}"/><circle cx="${p[0]}" cy="${p[1]}" r="${r + 5}" fill="none" stroke="${C.foam}" stroke-width="0.8" opacity="0.5"/>`;
  const link = (a, b) =>
    `<line x1="${a[0]}" y1="${a[1]}" x2="${b[0]}" y2="${b[1]}" stroke="${C.rope}" stroke-width="1.3" opacity="0.7"/>`;
  return svg(
    bg() +
      starfield(11, 130) +
      link(P.bowTop, P.keel) + link(P.keel, P.stern) + link(P.bowTop, P.stern) +
      link(P.mast, P.keel) + link(P.sailC, P.mast) + link(P.sailC, P.keel) +
      Object.values(P).map((p) => node(p)).join("") +
      `<circle cx="225" cy="60" r="3" fill="${C.rope}"/>` +
      wordmark(430, 175),
  );
}

// ── C2 · 8-bit pixel ship ────────────────────────────────
function c2() {
  const cell = 13;
  const ox = 120;
  const oy = 70;
  // pixel map: .=empty s=sail m=mast h=hull w=wave
  const map = [
    "....s.....",
    "....ss....",
    "....sss...",
    "....ssss..",
    "....m.....",
    "....m.....",
    "..hhhhhhh.",
    "..hhhhhhh.",
    ".wwwwwwwww",
  ];
  const fill = { s: C.sail, m: C.rope, h: C.hull, w: C.foam };
  let px = "";
  map.forEach((row, y) => {
    [...row].forEach((ch, x) => {
      if (ch === ".") return;
      const op = ch === "w" ? 0.5 : 1;
      px += `<rect x="${ox + x * cell}" y="${oy + y * cell}" width="${cell - 1.5}" height="${cell - 1.5}" fill="${fill[ch]}" opacity="${op}"/>`;
    });
  });
  // pixel-ish starfield as tiny squares
  const r = rng(7);
  let st = "";
  for (let i = 0; i < 80; i++)
    st += `<rect x="${(r() * W).toFixed(0)}" y="${(r() * H).toFixed(0)}" width="2" height="2" fill="${r() < 0.3 ? C.rope : C.foam}" opacity="${(0.3 + r() * 0.5).toFixed(2)}"/>`;
  return svg(bg() + st + px + wordmark(430, 175));
}

// ── C3 · orbits (L0/L1/L2) ───────────────────────────────
function c3() {
  const cx = 235;
  const cy = 170;
  const orbit = (rx, ry, rot, col) =>
    `<ellipse cx="${cx}" cy="${cy}" rx="${rx}" ry="${ry}" fill="none" stroke="${col}" stroke-width="1.2" stroke-dasharray="3 5" opacity="0.7" transform="rotate(${rot} ${cx} ${cy})"/>`;
  const sat = (rx, ry, rot, ang, col, label) => {
    const a = (ang * Math.PI) / 180;
    const x = cx + rx * Math.cos(a) * Math.cos((rot * Math.PI) / 180) - ry * Math.sin(a) * Math.sin((rot * Math.PI) / 180);
    const y = cy + rx * Math.cos(a) * Math.sin((rot * Math.PI) / 180) + ry * Math.sin(a) * Math.cos((rot * Math.PI) / 180);
    return `<circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="6" fill="${col}"/><text x="${x.toFixed(1)}" y="${(y - 12).toFixed(1)}" font-family="ui-monospace,monospace" font-size="13" fill="${col}" text-anchor="middle">${label}</text>`;
  };
  return svg(
    bg() +
      starfield(23, 90) +
      `<circle cx="${cx}" cy="${cy}" r="30" fill="${C.rope}" opacity="0.18"/><circle cx="${cx}" cy="${cy}" r="9" fill="${C.sail}"/>` +
      orbit(120, 48, -18, C.rope) + orbit(170, 66, 12, C.foam) + orbit(210, 86, -6, C.sail) +
      sat(120, 48, -18, 20, C.rope, "L0 · model") +
      sat(170, 66, 12, 200, C.foam, "L1 · agent") +
      sat(210, 86, -6, 110, C.sail, "L2 · harness") +
      wordmark(480, 175),
  );
}

// ── C4 · dot-matrix wordmark ─────────────────────────────
function c4() {
  const FONT = {
    t: ["00100", "00100", "11111", "00100", "00100", "00100", "00110"],
    h: ["10000", "10000", "10000", "11110", "10001", "10001", "10001"],
    e: ["01110", "10001", "10000", "11110", "10000", "10001", "01110"],
    s: ["01111", "10000", "10000", "01110", "00001", "00001", "11110"],
    u: ["10001", "10001", "10001", "10001", "10001", "10001", "01110"],
  };
  const word = "theseus";
  const pitch = 15;
  const ox = 150;
  const oy = 110;
  let dots = "";
  let col = 0;
  for (const ch of word) {
    const g = FONT[ch];
    for (let y = 0; y < 7; y++)
      for (let x = 0; x < 5; x++)
        if (g[y][x] === "1") {
          const on = C.sail;
          dots += `<circle cx="${ox + (col + x) * pitch}" cy="${oy + y * pitch}" r="5.4" fill="${on}"/>`;
        }
    col += 6; // 5 + 1 gap
  }
  // accent: last column gold
  return svg(
    bg() +
      starfield(31, 110) +
      dots +
      `<rect x="${ox - 4}" y="${oy + 7 * pitch + 6}" width="${6 * 7 * pitch - pitch}" height="4" rx="2" fill="${C.rope}" opacity="0.85"/>` +
      `<text x="${ox}" y="${oy + 7 * pitch + 44}" font-family="ui-sans-serif,system-ui,sans-serif" font-size="19" fill="${C.foam}">compare model × agent × harness — and judge the trade-offs</text>`,
  );
}

// ── C5 · pareto galaxy ───────────────────────────────────
function c5() {
  const r = rng(5);
  const x0 = 90;
  const y0 = 250;
  const x1 = 360;
  const y1 = 70;
  const pts = [];
  for (let i = 0; i < 46; i++) {
    const x = x0 + r() * (x1 - x0);
    const y = y0 - r() * (y0 - y1);
    pts.push([x, y]);
  }
  // frontier: sort by x asc, keep points with strictly increasing "accuracy" (lower y)
  const sorted = [...pts].sort((a, b) => a[0] - b[0]);
  const front = [];
  let bestY = Infinity;
  for (const p of sorted) {
    if (p[1] < bestY) {
      front.push(p);
      bestY = p[1];
    }
  }
  const dotsAll = pts
    .map((p) => `<circle cx="${p[0].toFixed(1)}" cy="${p[1].toFixed(1)}" r="2.6" fill="${C.foam}" opacity="0.55"/>`)
    .join("");
  const frontDots = front
    .map((p) => `<circle cx="${p[0].toFixed(1)}" cy="${p[1].toFixed(1)}" r="4.5" fill="${C.rope}"/>`)
    .join("");
  const path = front.map((p, i) => `${i ? "L" : "M"}${p[0].toFixed(1)},${p[1].toFixed(1)}`).join(" ");
  const axes = `<line x1="${x0}" y1="${y0}" x2="${x1 + 10}" y2="${y0}" stroke="${C.dim}" stroke-width="1"/><line x1="${x0}" y1="${y0}" x2="${x0}" y2="${y1 - 10}" stroke="${C.dim}" stroke-width="1"/>
    <text x="${x1}" y="${y0 + 20}" font-size="11" fill="${C.dim}" text-anchor="end">cost →</text>
    <text x="${x0 - 8}" y="${y1}" font-size="11" fill="${C.dim}" text-anchor="end" transform="rotate(-90 ${x0 - 8} ${y1})">accuracy →</text>`;
  return svg(
    bg() +
      starfield(99, 70) +
      axes +
      `<path d="${path}" fill="none" stroke="${C.rope}" stroke-width="2.4" opacity="0.85"/>` +
      dotsAll +
      frontDots +
      wordmark(470, 165),
  );
}

// ── C6 · minimal node constellation ──────────────────────
function c6() {
  const main = [150, 175];
  const subs = [
    [250, 110],
    [285, 200],
    [205, 250],
    [330, 150],
  ];
  const edges = subs
    .map((s) => `<line x1="${main[0]}" y1="${main[1]}" x2="${s[0]}" y2="${s[1]}" stroke="${C.foam}" stroke-width="1.1" opacity="0.55"/>`)
    .join("");
  const subDots = subs
    .map((s) => `<circle cx="${s[0]}" cy="${s[1]}" r="5" fill="${C.foam}"/>`)
    .join("");
  return svg(
    bg() +
      starfield(42, 60, { maxR: 1.2 }) +
      edges +
      subDots +
      `<circle cx="${main[0]}" cy="${main[1]}" r="26" fill="${C.rope}" opacity="0.16"/><circle cx="${main[0]}" cy="${main[1]}" r="9" fill="${C.rope}"/>` +
      wordmark(430, 175),
  );
}

const concepts = [
  ["c1-constellation-ship", c1()],
  ["c2-pixel-ship", c2()],
  ["c3-orbits", c3()],
  ["c4-dot-matrix", c4()],
  ["c5-pareto-galaxy", c5()],
  ["c6-node-constellation", c6()],
];

mkdirSync(OUT, { recursive: true });
for (const [name, s] of concepts) writeFileSync(join(OUT, `${name}.svg`), s);

// contact sheet (HTML) for one-shot visual compare
const cards = concepts
  .map(
    ([name, s]) =>
      `<figure><figcaption>${name}</figcaption><div class="frame">${s}</div></figure>`,
  )
  .join("\n");
writeFileSync(
  join(OUT, "contact-sheet.html"),
  `<!doctype html><html><head><meta charset="utf-8"><style>
  body{margin:0;background:#0a0f1a;font-family:ui-sans-serif,system-ui,sans-serif;color:#f5f1e6;padding:24px}
  h1{font-size:18px;margin:0 0 16px;opacity:.8}
  .grid{display:grid;grid-template-columns:1fr;gap:22px;max-width:760px}
  figure{margin:0}
  figcaption{font-family:ui-monospace,monospace;font-size:13px;color:#c08a3e;margin-bottom:6px}
  .frame svg{width:100%;height:auto;border:1px solid rgba(255,255,255,.08);border-radius:14px;display:block}
  </style></head><body><h1>theseus — banner concepts (spatial · universe · dot/pixel)</h1>
  <div class="grid">${cards}</div></body></html>`,
);

process.stdout.write(`wrote ${concepts.length} concepts + contact-sheet.html → ${OUT}/\n`);