home / skills / ntaksh42 / agents / algorithmic-art

algorithmic-art skill

/.claude/skills/algorithmic-art

This skill generates generative art using p5.js, offering interactive, animated patterns with seeds for reproducibility and export options.

npx playbooks add skill ntaksh42/agents --skill algorithmic-art

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.4 KB
---
name: algorithmic-art
description: Generate creative coding art using Canvas, SVG, WebGL, and generative algorithms. Use when creating algorithmic art or generative designs.
---

# Algorithmic Art Skill

p5.jsを使ったジェネラティブアートを生成するスキルです。

## 概要

アルゴリズムとランダム性を組み合わせて、ユニークな視覚芸術を創造します。

## 主な機能

- **生成的デザイン**: パターン、フラクタル、パーティクル
- **シード値**: 再現可能なランダムアート
- **アニメーション**: 動的な視覚効果
- **インタラクティブ**: マウス・キーボード入力
- **エクスポート**: PNG、SVG、GIF

## 使用方法

```
p5.jsで以下のアートを生成:
- タイプ: パーティクルシステム
- 色: 青系グラデーション
- アニメーション: あり
```

## 生成例

### フローフィールド

```javascript
let particles = [];
let flowfield;
let cols, rows;
let scale = 20;

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

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

  background(255);
}

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

  for (let particle of particles) {
    particle.follow(flowfield);
    particle.update();
    particle.edges();
    particle.show();
  }
}

class Particle {
  constructor() {
    this.pos = createVector(random(width), random(height));
    this.vel = createVector(0, 0);
    this.acc = createVector(0, 0);
    this.maxspeed = 4;
  }

  follow(vectors) {
    let x = floor(this.pos.x / scale);
    let y = floor(this.pos.y / scale);
    let index = x + y * cols;
    let force = vectors[index];
    this.applyForce(force);
  }

  applyForce(force) {
    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(0, 5);
    strokeWeight(1);
    point(this.pos.x, this.pos.y);
  }

  edges() {
    if (this.pos.x > width) this.pos.x = 0;
    if (this.pos.x < 0) this.pos.x = width;
    if (this.pos.y > height) this.pos.y = 0;
    if (this.pos.y < 0) this.pos.y = height;
  }
}
```

### 再帰的なフラクタルツリー

```javascript
function setup() {
  createCanvas(800, 800);
  background(255);
}

function draw() {
  background(255);
  translate(width / 2, height);
  stroke(0);
  branch(100);
}

function branch(len) {
  line(0, 0, 0, -len);
  translate(0, -len);

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

    push();
    rotate(-PI / 4);
    branch(len * 0.67);
    pop();
  }
}
```

## アートスタイル

- **フローフィールド**: パーリンノイズベースの流線
- **フラクタル**: 再帰的なパターン
- **パーティクルシステム**: 動的な粒子
- **幾何学パターン**: 規則的な図形
- **オーガニック**: 自然を模倣

## バージョン情報

- スキルバージョン: 1.0.0
- 最終更新: 2025-01-22

Overview

This skill generates algorithmic and generative art using Canvas, SVG, WebGL, and common generative libraries like p5.js. It combines deterministic seeds, procedural algorithms, and randomness to produce reproducible, animated, and interactive visuals. Use it to prototype visual ideas, create prints, or produce live visuals for web and installations.

How this skill works

The skill exposes generative templates (flow fields, particle systems, fractal trees, geometric tilings) and parameters such as seed, color palettes, noise scales, and animation controls. It renders to Canvas or SVG and can export frames as PNG, SVG, or animated GIFs. Interactive inputs (mouse, keyboard) and configurable seeds let you reproduce or iterate on outputs consistently.

When to use it

  • Prototyping creative coding visuals for web or installations
  • Generating reproducible art with seed-controlled randomness
  • Creating animated backgrounds or live visuals for events
  • Producing exportable assets (PNG, SVG, GIF) for prints or social media
  • Exploring generative design concepts like flow fields, particles, and fractals

Best practices

  • Start with a fixed seed when you want reproducible results; randomize only for variations
  • Parameterize color, scale, and noise frequency so compositions are easy to tweak
  • Limit particle counts and canvas size for real-time interactivity; increase for final exports
  • Use layered rendering (multiple canvases or SVG groups) to separate animation from static elements
  • Export high-resolution frames/SVGs for print and lower-res for web delivery

Example use cases

  • Create a Perlin-noise-based flow field particle animation for a website hero section
  • Generate a family of print-ready fractal tree prints using different seeds and palettes
  • Build an interactive demo where mouse input changes noise direction and particle behavior
  • Produce looping GIFs by rendering frames from a p5.js sketch and stitching them into an animation
  • Experiment with geometric tilings and SVG export for scalable vector artwork

FAQ

Can I reproduce the same output later?

Yes. Use the seed parameter and deterministic noise settings to reproduce identical results across runs.

What export formats are supported?

Common outputs include PNG, SVG and animated GIF. Canvas-based sketches export PNG/GIF; SVG templates export scalable vector files.