Name

getChild()

Class

PShape

Description

Extracts a child shape from a parent shape. Specify the name of the shape with the target parameter. The shape is returned as a PShape object, or null is returned if there is an error.

Examples

  • PShape prefecture;
    PShape aichi;
    
    void setup() {
     size(400, 400);
     prefecture = loadShape("prefecture.svg");
     aichi = prefecture.getChild("AICHI"); // id="AICHI" on svg file
    
    }
    
    void draw() {
      aichi.disableStyle();
      background(255);
      fill(255);
      shape(prefecture, 0, 5);
      
      fill(94, 138, 248); // change the color 
      shape(aichi, -10, -10); // move the location a bit
    }
    Image output for example 1

Syntax

  • sh.getChild(index)
  • sh.getChild(target)

Parameters

  • sh(PShape) any variable of type PShape
  • index(int)the layer position of the shape to get
  • target(String)the name of the shape to get

Return

  • PShape