Py5Shape.set_name()#

Assign a name to a Py5Shape object.

Examples#

example picture for set_name()
 1def setup():
 2    s = py5.create_shape(py5.GROUP)
 3    s1 = py5.create_shape(py5.RECT, 10, 10, 35, 35)
 4    s1.set_name("rectangle1")
 5    s.add_child(s1)
 6    s2 = py5.create_shape(py5.RECT, 55, 10, 35, 35)
 7    s2.set_name("rectangle2")
 8    s.add_child(s2)
 9    py5.shape(s)
10
11    s_child1 = s.get_child("rectangle1")
12    s_child1.set_fill("#FF0000")
13    s_child2 = s.get_child("rectangle2")
14    s_child2.set_fill("#00FF00")
15    py5.shape(s, 0, 45)

Description#

Assign a name to a Py5Shape object. This can be used to later find the shape in a GROUP shape.

Underlying Processing method: PShape.setName

Syntax#

set_name(name: str, /) -> None

Parameters#

  • name: str - name to be assigned to shape

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