shape_mode()#

Modifies the location from which shapes draw.

Examples#

example picture for shape_mode()
 1def setup():
 2    global bot
 3    bot = py5.load_shape("bot.svg")
 4
 5
 6def draw():
 7    py5.shape_mode(py5.CENTER)
 8    py5.shape(bot, 35, 35, 50, 50)
 9    py5.shape_mode(py5.CORNER)
10    py5.shape(bot, 35, 35, 50, 50)

Description#

Modifies the location from which shapes draw. The default mode is shape_mode(CORNER), which specifies the location to be the upper left corner of the shape and uses the third and fourth parameters of shape() to specify the width and height. The syntax shape_mode(CORNERS) uses the first and second parameters of shape() to set the location of one corner and uses the third and fourth parameters to set the opposite corner. The syntax shape_mode(CENTER) draws the shape from its center point and uses the third and forth parameters of shape() to specify the width and height. The parameter must be written in ALL CAPS because Python is a case sensitive language.

Underlying Processing method: shapeMode

Syntax#

shape_mode(mode: int, /) -> None

Parameters#

  • mode: int - either CORNER, CORNERS, CENTER

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