Interactive Art

Getting Started With Processing: Your First Interactive Sketch

Before TouchDesigner, before p5.js, there was Processing — the sketching language that taught a generation of artists to treat code as a drawing tool. Here's how to get a shape on screen and responding to the mouse in your first ten minutes.

Processing has been the on-ramp into interactive visual art for over two decades, built specifically for artists and designers rather than professional software engineers. Before p5.js brought the same ideas to the browser, Processing’s Java-based desktop IDE taught a generation of installation artists the core loop every interactive piece runs on: draw something, read an input, change what you draw. This tutorial gets you from a blank install to a sketch that actually responds to the mouse.

Install and open your first sketch

Download the Processing IDE free from processing.org — it runs on Windows, macOS, and Linux with no separate dependencies to install. Open it and you’ll see a blank sketch window with a text editor above and a black “canvas” area that appears when you run it. Every Processing program is called a sketch, and it lives in exactly two functions you’ll use constantly:

void setup() {
  size(600, 600);
}

void draw() {
  background(0);
}

setup() runs once, when the sketch starts — this is where you set the canvas size and any one-time configuration. draw() runs over and over, by default 60 times a second, which is what makes animation and interactivity possible: anything that needs to update continuously goes here.

Draw something, then make it move

Add a shape inside draw():

void draw() {
  background(0);
  fill(255, 100, 50);
  ellipse(300, 300, 80, 80);
}

That draws a fixed orange circle at the center every frame. To make it move, swap the fixed coordinates for mouseX and mouseY — two variables Processing updates automatically with the cursor’s live position:

void draw() {
  background(0);
  fill(255, 100, 50);
  ellipse(mouseX, mouseY, 80, 80);
}

Run it, and the circle now follows your cursor. This is the entire conceptual leap interactive art is built on: a visual element driven by a live input value instead of a hardcoded one. Everything from a motion-tracked projection to a sound-reactive light show is the same pattern at larger scale — read a value, draw based on it, every frame.

Add a real interaction: click to change state

Reading continuous input (the mouse position) is one pattern. Reacting to a discrete event — a click, a key press, a sensor trigger — is the other, and it needs a variable that persists across frames:

boolean isOn = false;

void draw() {
  background(0);
  if (isOn) {
    fill(255, 100, 50);
  } else {
    fill(50);
  }
  ellipse(mouseX, mouseY, 80, 80);
}

void mousePressed() {
  isOn = !isOn;
}

mousePressed() is a built-in function Processing calls automatically whenever the mouse is clicked — you never call it yourself. The isOn boolean, declared outside both functions, persists between frames, which is what lets a single click toggle the circle’s color permanently rather than just for one frame.

Where this goes next

That click-to-toggle pattern is the seed of every stateful interactive piece: swap mousePressed() for a serial-read from an Arduino sensor, or for an OSC message from a motion tracker, and the exact same if (isOn) logic drives a much larger installation. Processing’s own reference and the Processing Foundation’s examples library are the fastest way to go from here into motion, sound input (the Sound library), and exporting a sketch as a standalone application for gallery display.