texture_mode()#

Sets the coordinate space for texture mapping.

Examples#

example picture for texture_mode()
 1def setup():
 2    py5.size(100, 100, py5.P3D)
 3    py5.no_stroke()
 4    img = py5.load_image("laDefense.jpg")
 5    py5.texture_mode(py5.IMAGE)
 6    py5.begin_shape()
 7    py5.texture(img)
 8    py5.vertex(10, 20, 0, 0)
 9    py5.vertex(80, 5, 100, 0)
10    py5.vertex(95, 90, 100, 100)
11    py5.vertex(40, 95, 0, 100)
12    py5.end_shape()
example picture for texture_mode()
 1def setup():
 2    py5.size(100, 100, py5.P3D)
 3    py5.no_stroke()
 4    img = py5.load_image("laDefense.jpg")
 5    py5.texture_mode(py5.NORMAL)
 6    py5.begin_shape()
 7    py5.texture(img)
 8    py5.vertex(10, 20, 0, 0)
 9    py5.vertex(80, 5, 1, 0)
10    py5.vertex(95, 90, 1, 1)
11    py5.vertex(40, 95, 0, 1)
12    py5.end_shape()

Description#

Sets the coordinate space for texture mapping. The default mode is IMAGE, which refers to the actual pixel coordinates of the image. NORMAL refers to a normalized space of values ranging from 0 to 1. This function only works with the P2D and P3D renderers.

With IMAGE, if an image is 100 x 200 pixels, mapping the image onto the entire size of a quad would require the points (0,0) (100,0) (100,200) (0,200). The same mapping in NORMAL is (0,0) (1,0) (1,1) (0,1).

Underlying Processing method: textureMode

Syntax#

texture_mode(mode: int, /) -> None

Parameters#

  • mode: int - either IMAGE or NORMAL

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