shape_mode()

Modifies the location from which shapes draw.

Examples

example picture for shape_mode()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def setup():
    global bot
    bot = py5.load_shape("bot.svg")


def draw():
    py5.shape_mode(py5.CENTER)
    py5.shape(bot, 35, 35, 50, 50)
    py5.shape_mode(py5.CORNER)
    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 Java method: shapeMode

Syntax

shape_mode(mode: int, /) -> None

Parameters

  • mode: int - either CORNER, CORNERS, CENTER

Updated on September 11, 2021 16:51:34pm UTC