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()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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 Java method: PShape.getChildIndex

Syntax

get_child_index(who: Py5Shape, /) -> int

Parameters

  • who: Py5Shape - Py5Shape object

Updated on September 11, 2021 16:51:34pm UTC