SuperAPI AI Directory

algorithmic-art

Design & creation

View repository

Updated 10-15 21:04

About this skill

Algorithmic Art Skill

This skill generates generative art using p5.js.

Overview

It combines algorithms and randomness to create unique visual art.

Main Features

  • Generative Design: Patterns, Fractals, Particles
  • Seed Values: Reproducible random art
  • Animation: Dynamic visual effects
  • Interactive: Mouse and keyboard input
  • Export: PNG、SVG、GIF

How to Use

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

Generation Examples

Flow Field

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;
  }
}

Recursive fractal tree

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();
  }
}

Art Style

  • Flow Field: Perlin noise-based flow lines
  • Fractal: Recursive patterns
  • Particle System: Dynamic particles
  • Geometric patterns: Regular shapes
  • Organic: Mimicking nature

Version Information

  • Skill version: 1.0.0
  • Last updated: 2025-01-22