Newdaita
02 / 06

粒子の帳

2026 / GENERATIVE / CANVAS SKETCH

NOTES

(仮テキスト)作家本人による解説。

SOURCE


        import type { SketchFn } from "../lib/sketch-contract";

/**
 * サンプルスケッチ。1フレームを描く純粋関数のみを持ち、rAFループ・リサイズ・
 * canvas破棄はホスト (SketchRunner) の責務 (contracts/sketch-module.contract.md)。
 * 参照: docs/samples/portfolio-design-reference.html の同名スケッチを移植。
 */
const particleVeil: SketchFn = (ctx, w, h, t) => {
  ctx.fillStyle = "#101014";
  ctx.fillRect(0, 0, w, h);
  ctx.strokeStyle = "rgba(220, 220, 228, 0.55)";
  ctx.lineWidth = 1;
  for (let i = 0; i < 60; i++) {
    const x =
      w / 2 +
      Math.sin(t / 90 + i * 0.35) * w * 0.32 * Math.sin(i * 0.05 + t / 300);
    const y = h / 2 + Math.cos(t / 70 + i * 0.42) * h * 0.3;
    ctx.beginPath();
    ctx.arc(x, y, 14 + (i % 7) * 5, 0, Math.PI * 2);
    ctx.stroke();
  }
};

export default particleVeil;