home / skills / plurigrid / asi / algorithmic-art

algorithmic-art skill

This skill helps you generate reproducible algorithmic art with seeded randomness in p5.js, offering flow fields, recursive trees, and particle systems.

npx playbooks add skill plurigrid/asi --skill algorithmic-art

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

Files (1)
SKILL.md
3.6 KB
---
name: algorithmic-art
description: Creating algorithmic art using p5.js with seeded randomness and interactive
version: 1.0.0
---


# Algorithmic Art

Create generative art with code using p5.js, featuring seeded randomness for reproducibility.

## Core Concepts

### Seeded Randomness
```javascript
// Use seed for reproducible results
function setup() {
  randomSeed(42);
  noiseSeed(42);
}
```

### Noise Functions
```javascript
// Perlin noise for organic patterns
let x = noise(frameCount * 0.01) * width;
let y = noise(frameCount * 0.01 + 1000) * height;
```

## Common Patterns

### Flow Fields
```javascript
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();
  });
}
```

### Recursive Trees
```javascript
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();
  }
}
```

### Particle Systems
```javascript
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);
  }
}
```

## Color Palettes

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

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

## Best Practices

- Use `noLoop()` for static pieces, save with `save('art.png')`
- Experiment with blend modes: `blendMode(ADD)`
- Layer transparency for depth
- Use frameCount for animation



## Scientific Skill Interleaving

This skill connects to the K-Dense-AI/claude-scientific-skills ecosystem:

### Graph Theory
- **networkx** [○] via bicomodule
  - Universal graph hub

### Bibliography References

- `algorithms`: 19 citations in bib.duckdb



## SDF Interleaving

This skill connects to **Software Design for Flexibility** (Hanson & Sussman, 2021):

### Primary Chapter: 4. Pattern Matching

**Concepts**: unification, match, segment variables, pattern

### GF(3) Balanced Triad

```
algorithmic-art (+) + SDF.Ch4 (+) + [balancer] (+) = 0
```

**Skill Trit**: 1 (PLUS - generation)

### Secondary Chapters

- Ch6: Layering

### Connection Pattern

Pattern matching extracts structure. This skill recognizes and transforms patterns.
## Cat# Integration

This skill maps to **Cat# = Comod(P)** as a bicomodule in the equipment structure:

```
Trit: 0 (ERGODIC)
Home: Prof
Poly Op: ⊗
Kan Role: Adj
Color: #26D826
```

### GF(3) Naturality

The skill participates in triads satisfying:
```
(-1) + (0) + (+1) ≡ 0 (mod 3)
```

This ensures compositional coherence in the Cat# equipment structure.

Overview

This skill teaches creating algorithmic art with p5.js using seeded randomness, noise, flow fields, recursive structures, and particle systems. It emphasizes reproducibility through seeds and practical techniques for building interactive and static generative pieces. The material focuses on concrete code patterns, color palettes, and export tips for production-ready images.

How this skill works

The skill inspects common generative patterns (flow fields, particle systems, recursive trees) and shows how to seed randomness and noise for reproducible results. It explains how to convert Perlin noise to vectors, build and apply flow fields, manage particle physics, and compose layered color palettes. The guidance covers both interactive animation (frameCount-driven) and static outputs using noLoop() and save().

When to use it

  • When you want reproducible random visuals using randomSeed() and noiseSeed()
  • When building organic motion or textures with Perlin noise and flow fields
  • When creating branching structures or generative botanical forms with recursion
  • When you need dense particle effects with simple physics and vector fields
  • When producing static, high-resolution images for export or print

Best practices

  • Set randomSeed() and noiseSeed() at setup for reproducibility
  • Use noLoop() and save() for static pieces or frame-based export
  • Layer transparent strokes/fills and experiment with blendMode(ADD) for depth
  • Keep scale/grid resolution coarse for global flow, fine for details to balance performance
  • Limit particle count or update frequency to maintain real-time interactivity

Example use cases

  • Generative wallpapers: seed a composition and export a high-res PNG
  • Interactive installation: map mouse or MIDI input to noise offsets for real-time control
  • Data-driven aesthetics: map dataset values to flow field angles or branch lengths
  • Procedural backgrounds for games or VJ loops using looping noise and seeded variations
  • Print-ready art series: generate variations by iterating seed values and palette swaps

FAQ

How do I get identical results on different runs?

Call randomSeed(seed) and noiseSeed(seed) inside setup() with the same numeric seed before drawing. Avoid nondeterministic inputs like current time if you want exact repeats.

When should I use flow fields versus particle systems?

Use flow fields to create directional, field-driven motion for many particles; use particle systems for independent agents with custom forces and lifetime behavior. They pair well together: flow fields can drive particle systems.