- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Class | PShape
Name | ### addChild()
Examples |
    PShape house;

    void setup() {
      size(200, 200);

      // Make a group PShape
      house = createShape(GROUP);

      // Make three shapes
      PShape path = createShape();
      path.beginShape();
      path.vertex(-20, -20);
      path.vertex(0, -40);
      path.vertex(20, -20);
      path.endShape();
      PShape rectangle = createShape(RECT, -20, -20, 40, 40);
      PShape circle = createShape(ELLIPSE, 0, 0, 20, 20);

      // Add all three as children
      house.addChild(path);
      house.addChild(rectangle);
      house.addChild(circle);
    }

    void draw() {
      background(52);
      translate(mouseX, mouseY);
      shape(house);
    }
Description | Adds a child PShape to a parent PShape that is defined as a GROUP. In the example, the three shapes path, rectangle, and circle are added to a parent PShape variable named house that is a GROUP.
Syntax |
    sh.addChild(who)
    sh.addChild(who, idx)
Parameters |
sh | PShape: any variable of type PShape
who | PShape: any variable of type PShape
idx | int: the layer position in which to insert the new child
Returns | void
Related | getChild()

Updated on January 1, 2021 03:38:09am EST
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.