Why does the persistence of vision remain

why does the persistence of vision remain in this program ?

int x = 0;
void setup(){
  size(400,400);
  noStroke();
}
void draw(){
  fill(255);
  ellipse(x,200,10,10);
  x++;
  fill(0);
  ellipse(x,200,10,10);
}
1 Like

What you drew in the previous frame remains drawn unless you clear it. This is most easily done with a call to background():

int x = 0;

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

void draw() {
  background(196);
  x++;
  fill(0);
  ellipse(x, 200, 10, 10);
}
1 Like

Thank you for your reply.
And sorry for my luck of explainning.
My question is why the vision remain although I overwrote an ellipse at exactlly same place and same size.

1 Like
  x++;
  ellipse(x, 200, 10, 10);

that gives a circle what moves 1 pix to the right every loop

without

background(0,200,200);

like @TfGuy44 said, you see them all.

thank you for your reply.
instead of
backrgound(255);

why I cannot use
fill(255);
ellipse(x,200,10,10); //x is the place where old ellipse written in previous loop.

Good question. Basically, your screen is made up of square pixels, and if you tried to draw a round circle made up of square pixels, it looks terrible. So instead, Processing automatically smooths out the edges. This means that the pixels at the edge of the circle might be a slightly different color from the circle itself.

You can tell Processing to stop doing this with the noSmooth() function:

int x = 0;

void setup(){
  size(400,400);
  noStroke();
  noSmooth();
}

void draw(){
  fill(255);
  ellipse(x,200,10,10);
  x++;
  fill(0);
  ellipse(x,200,10,10);
}

There was a thread about the same problem: Having a visual problem with overlapping ellipses (solved)

Thank you for your reply again.
finally I got it .
I did not know noSmooth() function.
Thanks a lot !

1 Like