We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsWebsite,  Documentation,  Book Bugs › smooth() function on the Reference
Page Index Toggle Pages: 1
smooth() function on the Reference (Read 978 times)
smooth() function on the Reference
Aug 18th, 2006, 6:00pm
 
the example on the reference for the smooth function work in "Basic Mode".

I've tried to use it in "Continuous Mode" using Processing 0115 on OS X 10.3.9

Code:

void setup() {
size(200, 200);
background(255);
smooth();
}

void draw() {

fill(0);
ellipse(70, 48, 36, 36);
}


and it doesn't work as i expected ... i need to move the background and smooth function into the draw function

Code:

void setup() {
size(200, 200);

}

void draw() {
background(255);
smooth();

fill(0);
ellipse(70, 48, 36, 36);
}

why ?
Re: smooth() function on the Reference
Reply #1 - Aug 18th, 2006, 6:25pm
 
In your first example, what you are doing is drawing a smoothed circle ontop of itself over and over and over and over.  It shouldnt matter where you put the smooth call, but I would suggest keeping it in the setup loop.  All you need to do is move the background() call into the beginning of your draw loop.  That way, you never get overlapping ellipses.

Make sense?
Re: smooth() function on the Reference
Reply #2 - Aug 18th, 2006, 7:16pm
 
Ok, it work, thanks

but i don't fully understand why overlapping always the same ellipse give me a non smooth ellipse
Re: smooth() function on the Reference
Reply #3 - Aug 19th, 2006, 12:23am
 
It is because the pixels on the outside of the ellipse are anti-aliased, so that they can give the impression of being smooth with no jagged pixel edges.  Constantly drawing that smooth ellipse on top of itself will have the effect of drawing over the anti-aliased edge over and over.

Remember, if you dont call background() in the draw loop, you will constantly be drawing ontop of what you drew since the applet started.  Not unlike a painting.

If you add background() to the draw loop, it will wipe the canvas clean every time the draw method loops.
Re: smooth() function on the Reference
Reply #4 - Aug 19th, 2006, 5:02am
 
cavva wrote on Aug 18th, 2006, 7:16pm:
but i don't fully understand why overlapping always the same ellipse give me a non smooth ellipse


To expand on what flight404 said (in case it's not clear) an anti-aliased pixel is semi-transparent. If you draw a whole bunch of semi-transparent things of the same colour on top of eachother, eventually it will become opaque.
So if you have a white background, it anti-aliases the black circle by placing grey pixels around the edge. Once you do that a few times, they will all be black.
Re: smooth() function on the Reference
Reply #5 - Aug 19th, 2006, 12:40pm
 
thanks
Page Index Toggle Pages: 1