Why are my ellipses not smooth?

/* Art program by: luke
*/

int w;
int h;

void setup()
{
  size(500,500);
  background(255);

}

void draw()
{
  smooth();
  w = width;
  h = height; 

  stroke(0);
  strokeWeight(1);
  noFill();

  ellipse(w / 2, h / 2, w / 10, h / 10);
  ellipse(w / 2, h / 2, w / 6, h / 6);
  ellipse(w / 2, h / 2, w / 4, h / 4);
  ellipse(w / 2, h / 2, w / 2, h / 2);
  ellipse(w / 2, h / 2, w, h);

  println(w, h);
}

I just need the circles to appear smooth, I have tried using smooth(); but I thought it was enabled by default. Feeling stupid..

Answers

  • Answer ✓

    Took me a minute to see the problem. You're going to kick yourself when you realize what's wrong.

    Your ellipses don't move. But they are redrawn every frame. But the previous frame is not cleared.

    Copy line 10 to line 19.

  • constantly redrawing the same object over itself means that the pixels with partial alpha, the ones on the edges drawn that way to help smooth out the object, get less and less transparent with each frame. meaning you lose the smoothing.

    if you're drawing a single frame of something a better solution is to use noLoop() so that you're not just wasting cpu redrawing the exact same unchanging object 60 times a second. but if it's animated or interactive you need to clear the background every frame like tfguy mentions.

Sign In or Register to comment.