Creative coding lab

Creative Coding and Interactive Media Art at Demos Lab

Demos Lab is an independent home for creative coding and interactive media art. It covers the tools, techniques and ideas behind work that responds to code, sound, light and people. The site is written for artists learning to program, developers moving toward art, and anyone curious how generative visuals and interactive installations actually get made.

Generated fresh every day

Sketch of the Day

Wednesday: Tilted Orbit Swarms

Seventy small bodies circle two to four glowing attractors on tilted, noise-wobbled ellipses. A translucent background wash each frame lets their trails fade, and today's date seeds every orbit and color.

Seed20261021

The seed is today's date, so this sketch draws a new piece every day and never repeats.

Try it

Change 70 to 300 in the bodies loop and random(18, 160) to random(5, 60) for tight, crowded swarms.

Learn p5.js with our guides
const SEED = 20261021; // today's date as YYYYMMDD
const REDUCED = matchMedia('(prefers-reduced-motion: reduce)').matches;

// Orbits: bodies on seeded elliptical paths around a few attractors
const COLORS = ['#ff6b5e', '#8b5cf6', '#3ee0d0', '#ffc857', '#f4f1ea'];
let attractors = [], bodies = [];

function setup() {
  createCanvas(640, 480);
  randomSeed(SEED);
  noiseSeed(SEED);
  // Today's palette: three colors, plus two to four attractors
  let pool = COLORS.slice(), pal = [];
  for (let i = 0; i < 3; i++) pal.push(pool.splice(floor(random(pool.length)), 1)[0]);
  for (let i = floor(random(2, 5)); i > 0; i--) {
    attractors.push(createVector(random(150, 490), random(130, 350)));
  }
  // Each body gets its own ellipse size, tilt, phase and color
  for (let i = 0; i < 70; i++) {
    let r = random(18, 160);
    bodies.push({
      home: random(attractors), a: r, b: r * random(0.35, 1), id: i,
      tilt: random(TWO_PI), t: random(TWO_PI), size: random(2, 4.5),
      // Smaller orbits move faster, like planets
      speed: (random(0.06, 0.12) / sqrt(r)) * random([-1, 1]),
      col: color(random(pal))
    });
  }
  background(12, 11, 18);
  if (REDUCED) {
    // Still mode: trace whole orbits faintly, mark the bodies, then stop
    for (let s = 0; s < 500; s++) step(20, 3, s === 499);
    glow();
    noLoop();
  }
}

function draw() {
  // A translucent background wash makes the trails fade
  background(12, 11, 18, 24);
  step(200, 1, true);
  glow();
}

// Point on a tilted ellipse, gently wobbled by noise
function pos(b) {
  let w = 1 + 0.25 * (noise(b.id, b.t * 0.2) - 0.5);
  return createVector(cos(b.t) * b.a * w, sin(b.t) * b.b * w).rotate(b.tilt).add(b.home);
}

// Move every body forward, draw its trail segment and optional head
function step(alpha, k, head) {
  for (let b of bodies) {
    let p = pos(b);
    b.t += b.speed * k;
    let q = pos(b);
    b.col.setAlpha(alpha);
    stroke(b.col);
    line(p.x, p.y, q.x, q.y);
    if (head) { b.col.setAlpha(255); fill(b.col); circle(q.x, q.y, b.size); }
  }
}

// Attractors as soft white glows
function glow() {
  noStroke();
  for (let a of attractors) {
    fill(244, 241, 234, 30);
    circle(a.x, a.y, 28);
    fill(244, 241, 234, 220);
    circle(a.x, a.y, 6);
  }
}

Browse by section

Which creative coding tool fits your project?

These seven tools fall into two groups: libraries where you write code, and node-based environments where you connect boxes visually. The table compares the language, cost and best use of each.

Tool Language or style Free or paid Best for
p5.js JavaScript library, runs in the browser Free, open source Beginners, web sketches, teaching
Processing Java-based sketchbook IDE Free, open source Learning to code, generative art, print work
TouchDesigner Node-based, Python scripting Free non-commercial (1280x1280 cap); Commercial $600, Pro $2,200 Installations, projection mapping, live visuals
openFrameworks C++ toolkit Free, open source (MIT) High-performance installations, hardware, computer vision
three.js JavaScript 3D library (WebGL, WebGPU) Free, open source (MIT) Interactive 3D on the web
vvvv Node-based, .NET (Windows) Free non-commercial; paid license for commercial use Large media environments, sensors, real-time graphics
Hydra Browser live coding, modular-synth style Free, open source Live-coded video synthesis, VJ sets

Bottom line: If you're just starting, begin with p5.js. Move to TouchDesigner or vvvv for installation work, and budget for a license once a client is paying.

Start here

Make Your First Generative Sketch in p5.js

The p5.js Web Editor runs entirely in your browser, so you can go from a blank page to evolving generative art in about five minutes with nothing to install.

  1. Open the editor: Go to editor.p5js.org. A starter sketch loads with setup(), which calls createCanvas(400, 400), and draw(), which calls background(220). You can run code without an account.
  2. Run the starter code: Press the Play button or use Ctrl+Enter (Cmd+Enter on Mac). A plain grey square appears in the preview pane.
  3. Add randomness: Move background(220) into setup() so frames build on each other. Then add fill(random(255), random(255), random(255), 80) and circle(random(width), random(height), random(10, 60)) inside draw().
  4. Watch it grow and tweak it: Run the sketch again. Translucent circles now pile up into a new composition every time you run it. Try noStroke(), different size ranges, or frameRate(10) to see how each choice changes the result.
  5. Save and export: Create a free account to save the sketch to your library and share it. To download a still image, call saveCanvas('my-sketch', 'png') from keyPressed() and press a key while the sketch runs.

Creative Coding Terms Explained in Plain Language

These are twelve terms you will meet in almost every creative coding tutorial.

Sketch
A small creative coding program; Processing and p5.js use the word because their projects are meant to be quick and experimental.
Canvas
The drawing surface your code paints onto, such as the HTML canvas element or a Processing window.
Draw loop
A function, like draw() in p5.js and Processing, that repeats continuously to redraw the canvas and create animation.
Frame rate
How many times per second the screen updates, measured in frames per second; p5.js targets 60 by default.
Perlin noise
An algorithm Ken Perlin developed in the early 1980s that generates smooth, natural-looking randomness for terrain, texture and motion.
Vector
A value with direction and magnitude, stored as x, y (and sometimes z) components to represent position, velocity and forces.
Shader
A small program that runs on the GPU and processes vertices or pixels in parallel for fast visual effects.
GLSL
The OpenGL Shading Language, a C-like language for writing shaders that runs in both OpenGL and WebGL.
Particle system
Many small elements, each with its own position, velocity and lifespan, animated together to simulate smoke, fire or swarms.
Flow field
A grid of vectors, often derived from Perlin noise, that steers particles into flowing, swirling paths.
Generative art
Art produced by a rule-based system, usually code, that runs with some autonomy, so the output can vary each time.
Projection mapping
Projecting video onto physical surfaces like buildings or sculptures, with the image warped to fit their shape.

Latest experiments

Frequently asked questions

What is creative coding?

Creative coding means writing software to make something expressive, like generative art, visuals that react to sound, or interactive installations. The code is part of the creative work itself. Common tools include p5.js, Processing, TouchDesigner, openFrameworks and shader languages such as GLSL.

Which version of p5.js should beginners learn?

Learn version 2. After more than a year of testing, the team switched the p5.js Editor to use 2.x latest as the default version at the end of July 2026. The 2.x releases added support for variable fonts, beginner-friendly shaders that can be written in JavaScript rather than GLSL, new color modes (including OKLCH).

Is TouchDesigner free?

It's free for unpaid work. The Non-Commercial edition costs nothing, but image resolution is limited to 1280x1280. Paid jobs need a paid license. TouchDesigner Price · No Charge · $300 USD · $600 USD · $2200 USD covers the Non-Commercial, Educational, Commercial and Pro tiers.

Can I use TouchDesigner Non-Commercial for a client project?

No. Derivative says if you or your organization are compensated for your work with TouchDesigner, you must have a Commercial or Pro license. The Educational license is no help here either, since it has the same features as Commercial, but only for non-commercial uses.

Should I use p5.js or TouchDesigner for an interactive installation?

Use p5.js for browser-based pieces, quick prototypes and work you want to share with a link. Pick TouchDesigner for gallery or event installations that combine projectors, cameras, sensors and live video. It's a node based visual programming language for real time interactive multimedia content, and it handles that kind of setup better.

What computer do I need to run TouchDesigner?

On a Mac, you'll need macOS 13 (Ventura) or higher, and Derivative highly recommend a Mac with Apple Silicon for TouchDesigner. For Intel-based Macs a model with a discrete AMD GPU is required. It also runs on Windows. For heavy installation work, the graphics card matters more than anything else in the machine.

Tools we cover