Reference+
Name
smooth()
Description
Draws all geometry with smooth (anti-aliased) edges. This behavior is the default, so smooth() only needs to be used when a program needs to set the smoothing in a different way. The level parameter increases the amount of smoothness. This is the level of over sampling applied to the graphics buffer.
With the P2D and P3D renderers, smooth(2) is the default, this is called "2x anti-aliasing." The code smooth(4) is used for 4x anti-aliasing and smooth(8) is specified for "8x anti-aliasing." The maximum anti-aliasing level is determined by the hardware of the machine that is running the software, so smooth(4) and smooth(8) will not work with every computer. The default renderer uses smooth(3) by default. This is bicubic smoothing. The other option for the default renderer is smooth(2), which is bilinear smoothing. With Processing 3.0, smooth() is handled differently than in earlier releases. In 2.x and earlier, it was possible to use smooth() and noSmooth() to turn on and off antialiasing within a sketch. Now, because of how the software has changed, smooth() can only be set once within a sketch. It can be used either at the top of a sketch without a setup(), or after the size() function when used in a sketch with setup(). The noSmooth() function also follows the same rules. When smooth() is used with a PGraphics object, it should be run right after the object is created with createGraphics(), as shown in the Reference in the third example.Examples
void setup() { size(400, 400); smooth(2); noStroke(); } void draw() { background(0); ellipse(120, 192, 144, 144); ellipse(280, 192, 144, 144); }
int x = 0; void setup() { fullScreen(P2D, SPAN); smooth(4); } void draw() { background(0); ellipse(x, height/2, height/4, height/4); x += 1; }
PGraphics pg; int x = 0; void setup() { fullScreen(P2D); pg = createGraphics(width, height, P2D); pg.smooth(4); } void draw() { pg.beginDraw(); pg.background(0); pg.ellipse(x, height/2, height/4, height/4); pg.endDraw(); image(pg, 0, 0); x += 1; }
Syntax
smooth(level)
Parameters
level
(int)
either 2, 3, 4, or 8 depending on the renderer
Return
void
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.