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()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def setup():
    states = py5.load_shape("us_map.svg")
    ohio = states.get_child("OH")
    ohio.disable_style()

    py5.background(192)
    py5.scale(0.1)
    py5.translate(25, 225)
    py5.shape(states, 0, 0)
    py5.fill(255, 0, 0)
    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 Java 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 September 11, 2021 16:51:34pm UTC