Py5Shape.get_child_index()#

Get a child Py5Shape object’s index from a parent Py5Shape object that is defined as a GROUP.

Examples#

example picture for get_child_index()
 1def setup():
 2    us_map = py5.load_shape("us_map.svg")
 3    for child in us_map.get_children():
 4        idx = us_map.get_child_index(child)
 5        py5.println(child.get_name(), idx)
 6
 7    py5.background(192)
 8    py5.scale(0.1)
 9    py5.translate(25, 225)
10    py5.shape(us_map, 0, 0)

Description#

Get a child Py5Shape object’s index from a parent Py5Shape object that is defined as a GROUP. Inside Processing, a group Py5Shape object is an ordered list of child shapes. This method will retrieve the index for a particular child in that ordered list. That index value is useful when using other methods such as Py5Shape.get_child() or Py5Shape.remove_child().

Underlying Processing method: PShape.getChildIndex

Syntax#

get_child_index(who: Py5Shape, /) -> int

Parameters#

  • who: Py5Shape - Py5Shape object

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