Py5Graphics.rect_mode()

Py5Graphics.rect_mode()#

Modifies the location from which rectangles are drawn by changing the way in which parameters given to Py5Graphics.rect() are intepreted.

Description#

Modifies the location from which rectangles are drawn by changing the way in which parameters given to Py5Graphics.rect() are intepreted.

The default mode is rect_mode(CORNER), which interprets the first two parameters of Py5Graphics.rect() as the upper-left corner of the shape, while the third and fourth parameters are its width and height.

rect_mode(CORNERS) interprets the first two parameters of Py5Graphics.rect() as the location of one corner, and the third and fourth parameters as the location of the opposite corner.

rect_mode(CENTER) interprets the first two parameters of Py5Graphics.rect() as the shape’s center point, while the third and fourth parameters are its width and height.

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

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

This method is the same as rect_mode() but linked to a Py5Graphics object. To see example code for how it can be used, see rect_mode().

Underlying Processing method: PGraphics.rectMode

Signatures#

rect_mode(
    mode: int,  # either CORNER, CORNERS, CENTER, or RADIUS
    /,
) -> None

Updated on March 06, 2023 02:49:26am UTC