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

1 2 3 4 5 6 7 8 | def setup():
global img
img = py5.load_image("laDefense.jpg")
def draw():
py5.image_mode(py5.CORNER)
py5.image(img, 10, 10, 50, 50) # draw image using CORNER mode
|

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

1 2 3 4 5 6 7 8 | def setup():
global img
img = py5.load_image("laDefense.jpg")
def draw():
py5.image_mode(py5.CENTER)
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