image_mode()#

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

Examples#

example picture for image_mode()
1def setup():
2    global img
3    img = py5.load_image("laDefense.jpg")
4
5
6def draw():
7    py5.image_mode(py5.CORNER)
8    py5.image(img, 10, 10, 50, 50)  # draw image using CORNER mode
example picture for image_mode()
1def setup():
2    global img
3    img = py5.load_image("laDefense.jpg")
4
5
6def draw():
7    py5.image_mode(py5.CORNERS)
8    py5.image(img, 10, 10, 90, 40)  # draw image using CORNERS mode
example picture for image_mode()
1def setup():
2    global img
3    img = py5.load_image("laDefense.jpg")
4
5
6def draw():
7    py5.image_mode(py5.CENTER)
8    py5.image(img, 50, 50, 80, 80)  # draw image using CENTER mode

Description#

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

The default mode is image_mode(CORNER), which interprets the second and third parameters of image() as the upper-left corner of the image. If two additional parameters are specified, they are used to set the image’s width and height.

image_mode(CORNERS) interprets the second and third parameters of image() as the location of one corner, and the fourth and fifth parameters as the opposite corner.

image_mode(CENTER) interprets the second and third parameters of image() as the image’s center point. If two additional parameters are specified, they are used to set the image’s width and height.

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

Underlying Processing method: imageMode

Syntax#

image_mode(mode: int, /) -> None

Parameters#

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

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