Skip to contentCREATIVE·CODE·ART
p5.js

Generative Art Using Random Colors

Licence: CC BY-NC-SA 4.0: remix with credit, non-commercial, share alike

View the code
let numLines = 200;
let maxRadius = 200;

function setup() {
  createCanvas(400, 400);
  background(255);
  noFill();
  strokeWeight(2);
}

function draw() {
  translate(width / 2, height / 2);

  for (let i = 0; i < numLines; i++) {
    let angle = map(i, 0, numLines, 0, TWO_PI);
    let x1 = cos(angle) * maxRadius;
    let y1 = sin(angle) * maxRadius;
    let x2 = cos(angle + frameCount * 0.01) * maxRadius;
    let y2 = sin(angle + frameCount * 0.01) * maxRadius;

    let r = random(255);
    let g = random(255);
    let b = random(255);
    stroke(r, g, b);
    line(x1, y1, x2, y2);
  }
}