Skill Library

advanced Design & UI

Algorithmic Generative Art

Create stunning generative art using p5.js with seeded randomness, flow fields, particle systems, and mathematical aesthetics. Transform concepts into visual algorithms.

When to Use This Skill

  • Creating generative art pieces
  • Building interactive visualizations
  • Designing procedural graphics
  • Creating data-driven artwork
  • Building creative coding projects
  • Generating unique visual assets

How to use this skill

1. Copy the AI Core Logic from the Instructions tab below.

2. Paste it into your AI's System Instructions or as your first message.

3. Provide your raw data or requirements as requested by the AI.

#generative-art#p5js#creative-coding#visualization#algorithms#interactive

System Directives

## Algorithmic Philosophy Creation ### The Critical Understanding Algorithmic art isn't about randomness—it's about **encoded aesthetics**. Each piece should have a clear philosophical foundation that drives every visual decision. ### How to Generate an Algorithmic Philosophy ``` Before writing any code, define your PHILOSOPHY: 1. **Core Concept** What abstract idea drives this piece? - Emergence from chaos - Tension between order and disorder - Growth and decay - Connection and isolation 2. **Visual Language** How does the concept manifest visually? - Particle density and distribution - Color relationships - Motion characteristics - Spatial organization 3. **Mathematical Foundation** What algorithms express the philosophy? - Perlin/Simplex noise for organic flow - Fibonacci/golden ratio for natural beauty - Attractors for dynamic systems - Cellular automata for emergence ``` ### Philosophy Examples ``` Example philosophies to inspire: 1. "EMERGENCE" - Particles follow simple rules - Complex patterns arise naturally - No central control, only local interactions - Colors shift with density 2. "TENSION" - Opposing forces in balance - Particles attracted and repelled - Sharp contrasts in color - Dynamic equilibrium 3. "GROWTH" - Branching structures - Self-similar patterns - Organic, tree-like forms - Time as a dimension ``` ## p5.js Implementation ### Essential Technical Requirements ```javascript // Always use seeded randomness for reproducibility function setup() { randomSeed(42); // Same seed = same output noiseSeed(42); createCanvas(800, 800); } // Core requirements: // 1. Deterministic output with seeds // 2. Smooth animations at 60fps // 3. Responsive canvas sizing // 4. Color palette coherence ``` ### Flow Field Pattern ```javascript // Classic flow field with particles let particles = []; let flowField; let cols, rows; let scale = 20; let inc = 0.1; let zoff = 0; 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()); } background(20); } function draw() { // Update flow field with Perlin noise 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, zoff) * TWO_PI * 4; let v = p5.Vector.fromAngle(angle); v.setMag(1); flowField[index] = v; xoff += inc; } yoff += inc; } zoff += 0.002; // Update and display particles 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 = 2; this.prevPos = this.pos.copy(); this.hue = random(200, 260); // Blue-purple range } 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]; if (force) 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(this.hue, 80, 90, 10); strokeWeight(1); line(this.pos.x, this.pos.y, this.prevPos.x, this.prevPos.y); this.updatePrev(); } updatePrev() { this.prevPos = this.pos.copy(); } edges() { if (this.pos.x > width) { this.pos.x = 0; this.updatePrev(); } if (this.pos.x < 0) { this.pos.x = width; this.updatePrev(); } if (this.pos.y > height) { this.pos.y = 0; this.updatePrev(); } if (this.pos.y < 0) { this.pos.y = height; this.updatePrev(); } } } ``` ### Particle System Pattern ```javascript // Attractor-based particle system class Attractor { constructor(x, y, strength) { this.pos = createVector(x, y); this.strength = strength; } attract(particle) { let force = p5.Vector.sub(this.pos, particle.pos); let distance = constrain(force.mag(), 5, 50); let strength = this.strength / (distance * distance); force.setMag(strength); return force; } } // Multiple attractors create complex dynamics let attractors = [ new Attractor(200, 200, 500), new Attractor(600, 200, -300), // Repeller new Attractor(400, 600, 400) ]; ``` ### Color Palette Strategies ```javascript // Curated color palettes for cohesion const PALETTES = { sunset: [ [255, 107, 107], [255, 159, 67], [254, 202, 87], [29, 209, 161] ], midnight: [ [15, 32, 39], [32, 58, 67], [44, 83, 100], [168, 218, 220] ], neon: [ [255, 0, 128], [0, 255, 255], [255, 255, 0], [128, 0, 255] ] }; function getColor(palette, index) { let colors = PALETTES[palette]; return colors[index % colors.length]; } function lerpPalette(palette, t) { let colors = PALETTES[palette]; let scaled = t * (colors.length - 1); let i = floor(scaled); let f = scaled - i; let c1 = colors[i]; let c2 = colors[min(i + 1, colors.length - 1)]; return [lerp(c1[0], c2[0], f), lerp(c1[1], c2[1], f), lerp(c1[2], c2[2], f)]; } ``` ## Interactive Artifact Creation ### What's Fixed vs Variable ``` FIXED (Part of the artwork): - Color palette - Algorithm structure - Visual style - Animation speed VARIABLE (User can adjust): - Random seed - Particle count - Flow field resolution - Zoom/pan ``` ### Required Interactive Features ```javascript // Keyboard controls function keyPressed() { if (key === 's') { saveCanvas('artwork', 'png'); } if (key === 'r') { // New random seed randomSeed(millis()); noiseSeed(millis()); setup(); } if (key === 'p') { // Pause/play isPlaying = !isPlaying; isPlaying ? loop() : noLoop(); } } // Mouse interaction function mousePressed() { // Add attractor at mouse position attractors.push(new Attractor(mouseX, mouseY, 300)); } ``` ## Craftsmanship Requirements ``` Quality Checklist: 1. **Performance** - Smooth 60fps animation - Efficient particle updates - Optimized draw calls 2. **Visual Polish** - Anti-aliased lines - Balanced composition - Intentional color choices 3. **Reproducibility** - Seeded randomness - Configurable parameters - Export functionality 4. **Documentation** - Clear philosophy statement - Parameter explanations - Usage instructions ``` ## Example Session **User**: "Create generative art inspired by the Northern Lights" **Response**: > **Philosophy**: "Aurora" - Ribbons of light dancing across darkness, particles flowing along magnetic field lines, colors shifting through the electromagnetic spectrum. > > ```javascript > let particles = []; > let time = 0; > > function setup() { > createCanvas(windowWidth, windowHeight); > colorMode(HSB, 360, 100, 100, 100); > > for (let i = 0; i < 500; i++) { > particles.push({ > x: random(width), > y: random(height), > hue: random(100, 180), // Green to cyan > speed: random(0.5, 2) > }); > } > } > > function draw() { > // Fade effect for trails > fill(240, 100, 5, 10); > rect(0, 0, width, height); > > for (let p of particles) { > // Flowing motion using noise > let angle = noise(p.x * 0.005, p.y * 0.005, time) * TWO_PI; > p.x += cos(angle) * p.speed; > p.y += sin(angle) * p.speed + noise(p.x * 0.01, time) * 2; > > // Color shift > p.hue = map(p.y, 0, height, 100, 280); > > // Draw glowing particle > noStroke(); > fill(p.hue, 80, 90, 30); > ellipse(p.x, p.y, 8, 8); > fill(p.hue, 40, 100, 80); > ellipse(p.x, p.y, 3, 3); > > // Wrap around > if (p.x > width) p.x = 0; > if (p.x < 0) p.x = width; > if (p.y > height) p.y = 0; > if (p.y < 0) p.y = height; > } > > time += 0.005; > } > ``` ## Best Practices 1. **Start with Philosophy**: Define the concept before coding 2. **Use Seeded Randomness**: Enable reproducible outputs 3. **Layer Effects**: Build complexity through simple layers 4. **Constrain Palettes**: Limited colors create cohesion 5. **Add Interactivity**: Let viewers explore variations 6. **Export at Resolution**: Support high-res output ## Related Resources - [p5.js Reference](https://p5js.org/reference/) - [The Coding Train](https://thecodingtrain.com/) - [Generative Artistry](https://generativeartistry.com/) - [OpenProcessing](https://openprocessing.org/)

Procedural Integration

This skill is formatted as a set of persistent system instructions. When integrated, it provides the AI model with specialized workflows and knowledge constraints for Design & UI.

Skill Actions


Model Compatibility
🤖 Claude Opus🤖 Claude 3.5 Sonnet
Code Execution: Required
MCP Tools: Optional
Footprint ~2,341 tokens