Draws all geometry with smooth (anti-aliased) edges.
1def setup(): 2 py5.smooth(2) 3 py5.no_stroke() 4 5 6def draw(): 7 py5.background(0) 8 py5.ellipse(30, 48, 36, 36) 9 py5.ellipse(70, 48, 36, 36)
1x = 0 2 3def setup(): 4 py5.full_screen(py5.P2D, py5.SPAN) 5 py5.smooth(4) 6 7 8def draw(): 9 global x 10 py5.background(0) 11 py5.ellipse(x, py5.height//2, py5.height/4, py5.height/4) 12 x += 1
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.
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(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.
smooth() function can only be set once within a Sketch. It is intended to be called from the
settings() function. The no_smooth() function follows the same rules.
When programming in module mode and imported mode, py5 will allow calls to
smooth() from the
setup() function if it is called at the beginning of
setup(). This allows the user to omit the
settings() function, much like what can be done while programming in the Processing IDE. Py5 does this by inspecting the
setup() function and attempting to split it into synthetic
setup() functions if both were not created by the user and the real
setup() function contains a call to
smooth(), or calls to size(), full_screen(), no_smooth(), or pixel_density(). Calls to those functions must be at the very beginning of
setup(), before any other Python code (but comments are ok). This feature is not available when programming in class mode.
Underlying Processing method: smooth
smooth() -> None smooth(level: int, /) -> None
level: int - either 2, 3, 4, or 8 depending on the renderer
Updated on November 12, 2021 11:30:58am UTC