Py5Shape.texture()

Sets a texture to be applied to a Py5Shape object’s vertex points.

Examples

example picture for texture()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def setup():
    py5.size(100, 100, py5.P2D)
    img = py5.load_image("tower.jpg")
    s = py5.create_shape()
    s.begin_shape()
    s.texture(img)
    s.vertex(20, 20, 0, 0)
    s.vertex(20, 80, 0, 100)
    s.vertex(80, 80, 100, 100)
    s.vertex(80, 20, 100, 0)
    s.end_shape(py5.CLOSE)

    py5.shape(s)

Description

Sets a texture to be applied to a Py5Shape object’s vertex points. The texture() function must be called between Py5Shape.begin_shape() and Py5Shape.end_shape() and before any calls to Py5Shape.vertex(). This method only works with the P2D and P3D renderers.

When textures are in use, the fill color is ignored. Instead, use Py5Shape.tint() to specify the color of the texture as it is applied to the shape.

Underlying Processing method: PShape.texture

Syntax

texture(tex: Py5Image, /) -> None

Parameters

  • tex: Py5Image - reference to a Py5Image object

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