ellipse_mode()#

Modifies the location from which ellipses are drawn by changing the way in which parameters given to ellipse() are intepreted.

Examples#

example picture for ellipse_mode()
1def setup():
2    py5.ellipse_mode(py5.RADIUS)  # set ellipse_mode to RADIUS
3    py5.fill(255)  # set fill to white
4    py5.ellipse(50, 50, 30, 30)  # draw white ellipse using RADIUS mode
5
6    py5.ellipse_mode(py5.CENTER)  # set ellipse_mode to CENTER
7    py5.fill(100)  # set fill to gray
8    py5.ellipse(50, 50, 30, 30)  # draw gray ellipse using CENTER mode
example picture for ellipse_mode()
1def setup():
2    py5.ellipse_mode(py5.CORNER)  # set ellipse_mode is CORNER
3    py5.fill(255)  # set fill to white
4    py5.ellipse(25, 25, 50, 50)  # draw white ellipse using CORNER mode
5
6    py5.ellipse_mode(py5.CORNERS)  # set ellipse_mode to CORNERS
7    py5.fill(100)  # set fill to gray
8    py5.ellipse(25, 25, 50, 50)  # draw gray ellipse using CORNERS mode

Description#

Modifies the location from which ellipses are drawn by changing the way in which parameters given to ellipse() are intepreted.

The default mode is ellipse_mode(CENTER), which interprets the first two parameters of ellipse() as the shape’s center point, while the third and fourth parameters are its width and height.

ellipse_mode(RADIUS) also uses the first two parameters of ellipse() as the shape’s center point, but uses the third and fourth parameters to specify half of the shapes’s width and height.

ellipse_mode(CORNER) interprets the first two parameters of ellipse() as the upper-left corner of the shape, while the third and fourth parameters are its width and height.

ellipse_mode(CORNERS) interprets the first two parameters of ellipse() as the location of one corner of the ellipse’s bounding box, and the third and fourth parameters as the location of the opposite corner.

The parameter must be written in ALL CAPS because Python is a case-sensitive language.

Underlying Processing method: ellipseMode

Syntax#

ellipse_mode(mode: int, /) -> None

Parameters#

  • mode: int - either CENTER, RADIUS, CORNER, or CORNERS

Updated on November 12, 2021 11:30:58am UTC