Claude Opus 5.5

index.html

<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>土谷大地</title>
<style>
  :root { --wall: #e7e2d9; --ink: #3b3732; --sub: #8a837a; --line: rgba(60, 55, 50, .22); --shadow: rgba(40, 30, 20, .28); }
  @media (prefers-color-scheme: dark) { :root { --wall: #1f1e1c; --ink: #e6e1d8; --sub: #8e877d; --line: rgba(230, 225, 216, .22); --shadow: rgba(0, 0, 0, .6); } }
  * { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  body { background: var(--wall); color: var(--ink); font-family: "Noto Serif CJK JP", "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 28px 16px; min-height: 100%; }
  .sheet { position: relative; width: min(94vw, calc((100vh - 150px) * 24 / 17)); aspect-ratio: 24 / 17; box-shadow: 0 1px 2px var(--shadow), 0 14px 40px -12px var(--shadow); background: #f8f5ee; cursor: zoom-in; }
  .sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
  #wet { opacity: 0; }
  body.zoom { display: block; padding: 0; overflow: auto; }
  body.zoom .sheet { width: auto; aspect-ratio: auto; margin: 0; cursor: zoom-out; box-shadow: none; }
  body.zoom .sheet canvas { position: static; width: auto; height: auto; }
  body.zoom #wet, body.zoom .label { display: none; }
  .label { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; justify-content: center; text-align: center; }
  .label h1 { font-size: 19px; font-weight: 500; letter-spacing: .32em; margin: 0 -.32em 0 0; }
  .label .meta { font-size: 12.5px; color: var(--sub); letter-spacing: .08em; min-width: 15em; text-align: left; }
  .label button { font: inherit; font-size: 12.5px; color: var(--sub); background: none; border: 0; border-bottom: 1px solid var(--line); padding: 2px 1px; cursor: pointer; letter-spacing: .08em; }
  .label button:hover { color: var(--ink); border-color: var(--ink); }
  .label button:disabled { opacity: .35; cursor: default; }
</style>
</head>
<body>
  <div class="sheet" id="sheet" title="クリックで原寸表示">
    <canvas id="base"></canvas>
    <canvas id="wet"></canvas>
  </div>
  <div class="label">
    <h1>土谷大地</h1>
    <span class="meta" id="meta">透明水彩(JavaScript)</span>
    <button id="again" disabled>もう一度描く</button>
    <button id="save" disabled>PNG を保存</button>
  </div>
<script src="paint.js"></script>
<script>
(() => {
  const q = new URLSearchParams(location.search);
  const fast = q.has('fast'), width = Math.min(4800, Math.max(600, +q.get('w') || 2400)), seed = +q.get('seed') || undefined;
  const base = document.getElementById('base'), wet = document.getElementById('wet'), meta = document.getElementById('meta');
  const again = document.getElementById('again'), save = document.getElementById('save'), sheet = document.getElementById('sheet');
  const sleep = ms => new Promise(r => setTimeout(r, ms));
  const frame = () => new Promise(r => requestAnimationFrame(() => r()));
  let run = 0;

  async function paint() {
    const me = ++run;
    again.disabled = save.disabled = true;
    meta.textContent = '紙を張る…';
    await frame(); await frame();
    const p = Suisai.createPainting({ width, seed });
    for (const c of [base, wet]) { c.width = p.W; c.height = p.H; }
    const bctx = base.getContext('2d'), wctx = wet.getContext('2d');
    const img = new ImageData(p.W, p.H);
    let first = true;
    for (const step of p.run()) {
      if (me !== run) return;
      if (first) { p.compose(img.data); bctx.putImageData(img, 0, 0); first = false; }
      else {
        const [x0, y0, x1, y1] = step.rect;
        if (x1 > x0 && y1 > y0) {
          p.compose(img.data, step.rect);
          if (fast) bctx.putImageData(img, 0, 0, x0, y0, x1 - x0, y1 - y0);
          else {
            // 塗ったばかりの層を上のキャンバスに置き、乾いていくように重ねる
            wctx.clearRect(0, 0, p.W, p.H); wctx.putImageData(img, 0, 0, x0, y0, x1 - x0, y1 - y0);
            wet.style.transition = 'none'; wet.style.opacity = 0; await frame();
            wet.style.transition = 'opacity .55s ease-out'; wet.style.opacity = 1;
            meta.textContent = step.label + ' …';
            await sleep(620);
            if (me !== run) return;
            bctx.putImageData(img, 0, 0, x0, y0, x1 - x0, y1 - y0);
            wet.style.transition = 'none'; wet.style.opacity = 0;
          }
        }
      }
      meta.textContent = step.label + ' …';
      await frame();
    }
    meta.textContent = `透明水彩(JavaScript) ${p.W} × ${p.H}`;
    again.disabled = save.disabled = false;
    document.body.dataset.done = '1';
  }

  again.onclick = () => { delete document.body.dataset.done; paint(); };
  save.onclick = () => base.toBlob(b => { const a = document.createElement('a'); a.href = URL.createObjectURL(b); a.download = '土谷大地.png'; a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 5000); }, 'image/png');
  sheet.onclick = e => {
    const r = base.getBoundingClientRect(), fx = (e.clientX - r.left) / r.width, fy = (e.clientY - r.top) / r.height;
    const z = document.body.classList.toggle('zoom');
    if (z) scrollTo(fx * base.width - innerWidth / 2, fy * base.height - innerHeight / 2); else scrollTo(0, 0);
  };
  paint();
})();
</script>
</body>
</html>