Py5Shape.get_child_index()

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()

def setup():
    us_map = py5.load_shape("us_map.svg")
    for child in us_map.get_children():
        idx = us_map.get_child_index(child)
        py5.println(child.get_name(), idx)

    py5.background(192)
    py5.scale(0.1)
    py5.translate(25, 225)
    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

Signatures#

get_child_index(
    who: Py5Shape,  # Py5Shape object
    /,
) -> int

Updated on March 06, 2023 02:49:26am UTC