Ellipse following mouse

What’s actually happening is you are not removing any of the previously drawn circles from previous frames.

You need to paint over them!

In setup(), you call background(0). This draws black over the ENTIRE sketch. This is why your sketch has a black background.

If you move (or copy) that call to background() into draw(), then you will paint black over any previous circles… and then you can draw just one circle on top of that fresh, clean slate of black.

You don’t need to call pushMatrix() or popMatrix() at all.

void setup () {
  size(400, 400, P3D);
}

void draw() {
  background(0);
  fill(255);
  ellipse(mouseX, mouseY, 40, 40);
}
3 Likes