Py5Shape.set_tint()

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

Examples

example picture for set_tint()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)

    s.set_tint(0, "#0000FF")
    s.set_tint(2, "#FF0000")
    py5.shape(s)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def setup():
    py5.size(100, 100, py5.P2D)
    global s
    img = py5.load_image("tower.jpg")
    s = py5.create_shape()
    s.begin_shape()
    s.texture(img)
    s.tint(0, 0, 255)
    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)


def draw():
    if py5.frame_count == 50:
        s.set_tint(False)
    if py5.frame_count == 100:
        s.set_tint("#FF0000")

    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 Java 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 September 11, 2021 16:51:34pm UTC