Py5Shape.set_tint()#

Apply a color tint to a shape’s texture map.

Examples#

example picture for set_tint()
 1def setup():
 2    py5.size(100, 100, py5.P2D)
 3    img = py5.load_image("tower.jpg")
 4    s = py5.create_shape()
 5    s.begin_shape()
 6    s.texture(img)
 7    s.vertex(20, 20, 0, 0)
 8    s.vertex(20, 80, 0, 100)
 9    s.vertex(80, 80, 100, 100)
10    s.vertex(80, 20, 100, 0)
11    s.end_shape(py5.CLOSE)
12
13    s.set_tint(0, "#0000FF")
14    s.set_tint(2, "#FF0000")
15    py5.shape(s)
 1def setup():
 2    global s
 3    py5.size(100, 100, py5.P2D)
 4    img = py5.load_image("tower.jpg")
 5    s = py5.create_shape()
 6    s.begin_shape()
 7    s.texture(img)
 8    s.tint(0, 0, 255)
 9    s.vertex(20, 20, 0, 0)
10    s.vertex(20, 80, 0, 100)
11    s.vertex(80, 80, 100, 100)
12    s.vertex(80, 20, 100, 0)
13    s.end_shape(py5.CLOSE)
14
15
16def draw():
17    if py5.frame_count == 50:
18        s.set_tint(False)
19    if py5.frame_count == 100:
20        s.set_tint("#FF0000")
21
22    py5.shape(s)

Description#

Apply a color tint to a shape’s texture map. This can be done for either the entire shape or one vertex.

This method differs from Py5Shape.tint() in that it is only to be used outside the Py5Shape.begin_shape() and Py5Shape.end_shape() methods. This method only works with the P2D and P3D renderers.

Calling this method with the boolean parameter False will delete the assigned tint. A later call with the boolean parameter True will not restore it; you must reassign the tint color, as shown in the second example.

Underlying Processing method: PShape.setTint

Syntax#

set_tint(fill: int, /) -> None
set_tint(index: int, tint: int, /) -> None
set_tint(tint: bool, /) -> None

Parameters#

  • fill: int - color value in hexadecimal notation

  • index: int - vertex index

  • tint: bool - allow tint

  • tint: int - color value in hexadecimal notation

Updated on March 22, 2022 21:53:01pm UTC