mcpField
A
algorithmic-art

algorithmic-art

github.com/moizibnyousafクリエイティブ・メディア1.2k117 回インストール6 週間前に更新
リポジトリ

algorithmic-art について

algorithmic-art は、p5.js で生成アートを作るクリエイター向けのスキルです。再現可能な乱数やノイズ、静止画・アニメーション向けの図案を扱います。

主な機能

  1. 01シードによる再現可能な乱数生成
  2. 02ノイズを使った有機的なパターン作成
  3. 03フローフィールドとパーティクルシステムの作成
  4. 04再帰による樹木パターンの生成
  5. 05パレット定義とレイヤー合成
  6. 06静止画やアニメーションの制作

活用シーン

  1. 01再現可能なビジュアル作品の生成
  2. 02フローフィールドやパーティクルアートの制作
  3. 03再帰的な樹木パターンの描画
  4. 04静止画の書き出しやアニメーション制作

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/moizibnyousaf/ai-agent-skills --skill algorithmic-art

インストール後、Claude Code で/algorithmic-artを入力して読み込まれたか確認します。

詳細

アルゴリズミックアート

p5.js を使用して、再現性を確保するためにシード付きの乱数を使ったジェネレーティブアートを作成します。

基本概念

シード付きの乱数
// Use seed for reproducible results
function setup() {
  randomSeed(42);
  noiseSeed(42);
}
ノイズ関数
// Perlin noise for organic patterns
let x = noise(frameCount * 0.01) * width;
let y = noise(frameCount * 0.01 + 1000) * height;

よく使われるパターン

フローフィールド
let cols, rows, scale = 20;
let particles = [];
let flowfield;

function setup() {
  createCanvas(800, 800);
  cols = floor(width / scale);
  rows = floor(height / scale);
  flowfield = new Array(cols * rows);

  for (let i = 0; i < 1000; i++) {
    particles.push(new Particle());
  }
}

function draw() {
  let yoff = 0;
  for (let y = 0; y < rows; y++) {
    let xoff = 0;
    for (let x = 0; x < cols; x++) {
      let angle = noise(xoff, yoff) * TWO_PI * 2;
      let v = p5.Vector.fromAngle(angle);
      flowfield[x + y * cols] = v;
      xoff += 0.1;
    }
    yoff += 0.1;
  }

  particles.forEach(p => {
    p.follow(flowfield);
    p.update();
    p.show();
  });
}
再帰的な木
function branch(len) {
  line(0, 0, 0, -len);
  translate(0, -len);

  if (len > 4) {
    push();
    rotate(PI / 6);
    branch(len * 0.67);
    pop();

    push();
    rotate(-PI / 6);
    branch(len * 0.67);
    pop();
  }
}
パーティクルシステム
class Particle {
  constructor() {
    this.pos = createVector(random(width), random(height));
    this.vel = createVector(0, 0);
    this.acc = createVector(0, 0);
    this.maxSpeed = 4;
  }

  follow(flowfield) {
    let x = floor(this.pos.x / scale);
    let y = floor(this.pos.y / scale);
    let force = flowfield[x + y * cols];
    this.acc.add(force);
  }

  update() {
    this.vel.add(this.acc);
    this.vel.limit(this.maxSpeed);
    this.pos.add(this.vel);
    this.acc.mult(0);
  }

  show() {
    stroke(255, 5);
    point(this.pos.x, this.pos.y);
  }
}

カラーパレット

// Define palette
const palette = ['#264653', '#2a9d8f', '#e9c46a', '#f4a261', '#e76f51'];

// Random from palette
fill(random(palette));

ベストプラクティス

  • 静止画では noLoop() を使用し、save('art.png') で保存します
  • ブレンドモードを試します:blendMode(ADD)
  • 透明度を重ねて奥行きを表現します
  • アニメーションには frameCount を使用します

コメント