Py5Shape.get_child()#

Extracts a child Py5Shape object from a parent Py5Shape object that is defined as a GROUP.

Examples#

example picture for get_child()
 1def setup():
 2    states = py5.load_shape("us_map.svg")
 3    ohio = states.get_child("OH")
 4    ohio.disable_style()
 5
 6    py5.background(192)
 7    py5.scale(0.1)
 8    py5.translate(25, 225)
 9    py5.shape(states, 0, 0)
10    py5.fill(255, 0, 0)
11    py5.shape(ohio, 0, 0)

Description#

Extracts a child Py5Shape object from a parent Py5Shape object that is defined as a GROUP. Specify the name of the shape with the target parameter, or use the index with the index parameter. The shape is returned as a Py5Shape object, or None is returned if there is an error.

Underlying Processing method: PShape.getChild

Syntax#

get_child(index: int, /) -> Py5Shape
get_child(target: str, /) -> Py5Shape

Parameters#

  • index: int - the layer position of the shape to get

  • target: str - the name of the shape to get

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