Loading...
Logo
Processing Forum

SVG bug

in Programming Questions  •  2 years ago  
I have a SVG that I'm going to use for a video game. When I try to load a child and draw it I can't see anything.

Here's my code.

Copy code
  1. PShape test,test2,test3;

  2. void setup() {
  3.       size(600,200);
  4.       test = loadShape("test.svg");
  5.       test2 = test.getChild("layer1");
  6.       test3 = test2.getChild("0");
  7. }
  8.  
  9. void draw() {
  10.       shape(test3);
  11. }

and here's my SVG
test.svg

test and test2 work fine but test3 shows nothing.
It's like test3 had absolutely no data in it. :(

EDIT:

What I found works best for me (for a video game).
is getting rid of "layer1" and having all the "frames" aligned in the same place (it looks like a mess but it works).

Replies(1)

Re: SVG bug

2 years ago
Copy code
  1.   void draw() {
  2.     translate(-152.63399,-441.51944);
  3.         shape(test3);
  4.   }
 The translate() call is a simple copy/paste from the transformation applied to the layer1 group... When you access a child of this group, it is untranslated by the group, so it is displayed outside of the sketch's area.