PShape - Is this a processing bug?

When using getChild( index ) to retrieve a child of a PShape loaded from an SVG file, I've found that the child's height and width attributes are not set. However, when I get the same child using getChild( name ) the height and width are set as expected. Similarly, and probably related, if I use shape(child, x, y, w, h) to draw a child shape I retrieved by index, it won't draw at all. But, if I do the same with a child retrieved by name, it works fine.

Once a child shape has been accessed by name, however, accessing it by index no longer presents these problems. So, as a workaround I've been using code like this in setup():

 parent = loadShape("myshape.svg");
  int n = parent.getChildCount();
  for (int i = 0; i < n; i++) { 
      child = parent.getChild(i); 
      String name = child.getName(); 
      child = parent.getChild(name); 
  } 

After that, in draw(), I can access child shapes by index and they work as expected. This doesn't seem ideal to me. Is there a reason it was implemented like this or is it a bug?

Answers

Sign In or Register to comment.