Kamel Ghabte · Course · Free

Visual Feedback

Create visual feedback loops in p5.js.

The concept

Visual feedback reinjects the produced image as input for the next frame. By not fully clearing the background (fill with low alpha), shapes leave trails. Applying slight zoom or rotation to the buffer creates tunnel, kaleidoscope, or infinite recursion effects.

The code

// Visual feedback: trail + rotation
function setup() { createCanvas(400, 280); }
function draw() {
  // Semi-transparent background = trail
  fill(11, 15, 20, 20); noStroke(); rect(0,0,width,height);
  translate(width/2, height/2);
  rotate(frameCount * 0.01);
  let r = 60 + sin(frameCount * 0.03) * 30;
  noFill(); stroke(55, 227, 195, 180); strokeWeight(2);
  ellipse(r * cos(frameCount*0.05), r * sin(frameCount*0.07), 20, 20);
}

Going further

Explore other free courses on the Learn page, or book a call to discuss your project.

Want to go further?

Book a discovery call →